Golang : Clean up null characters from input data
Problem :
You have input data in slice of bytes and you want to remove the null characters in the data. How to do that ?
Solution : Use the bytes.Trim()
function to remove the null characters from your input. Null character in byte format is \x00
and use this example :
withoutNull = bytes.Trim(withNull, "\x00")
References :
See also : Golang :Trim white spaces from a string
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+15k Golang : Basic authentication with .htpasswd file
+6k Golang : Denco multiplexer example
+6.9k Golang : Muxing with Martini example
+12.4k Golang : Get month name from date example
+20.3k Golang : Count number of digits from given integer value
+7.5k Linux : How to fix Brother HL-1110 printing blank page problem
+8.9k Golang : HTTP Routing with Goji example
+22.3k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+13.6k Golang : How to get year, month and day?
+14.2k Golang : Compress and decompress file with compress/flate example
+16.5k Golang : Test floating point numbers not-a-number and infinite example
+9.7k Golang : How to extract video or image files from html source code