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.9k Golang : Find change in a combination of coins example
+14.5k Golang : Find network of an IP address
+16.6k Golang : Get IP addresses of a domain name
+20.6k Golang : Pipe output from one os.Exec(shell command) to another command
+10.5k Swift : Convert (cast) String to Integer
+15.7k Chrome : ERR_INSECURE_RESPONSE and allow Chrome browser to load insecure content
+11k Android Studio : Checkbox for user to select options example
+15.4k Golang : How to get Unix file descriptor for console and file
+9.7k Golang : Quadratic example
+7.5k Linux : How to fix Brother HL-1110 printing blank page problem
+11.8k Golang : Find age or leap age from date of birth example