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
+3.7k Golang : Switch Redis database redis.NewClient
+12.5k Golang : flag provided but not defined error
+9.3k Golang : Find the length of big.Int variable example
+28.1k Golang : Connect to database (MySQL/MariaDB) server
+19.2k Golang : Calculate entire request body length during run time
+20.7k Golang : Convert date string to variants of time.Time type examples
+6.6k Golang : Derive cryptographic key from passwords with Argon2
+15k Golang : package is not in GOROOT during compilation
+11.5k SSL : The certificate is not trusted because no issuer chain was provided
+62.6k Golang : Convert HTTP Response body to string
+12.1k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+11.1k Golang : Calculate Relative Strength Index(RSI) example