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
+5.8k Golang : Get expvar(export variables) to work with multiplexer
+4.8k Golang : Use NLP to get sentences for each paragraph example
+8.8k Golang : Check a web page existence with HEAD request example
+16.5k Golang : How to log each HTTP request to your web server?
+40.6k Golang : Convert []byte to image
+8.1k Golang : Generate Codabar
+8.4k Facebook : Getting the friends list with PHP return JSON format
+28k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+11.2k Golang : Listen and Serve on sub domain example
+5.2k Javascript : Generate random key with specific length
+10.6k Golang : Handle API query by curl with Gorilla Queries example
+13.6k Golang : Missing Bazaar command