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 Cash Flow : 50 days to pay your credit card debt
+30.1k Golang : Get time.Duration in year, month, week or day
+15.8k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+8.6k Android Studio : Import third-party library or package into Gradle Scripts
+9.9k Golang : Function wrapper that takes arguments and return result example
+9.8k Golang : List available AWS regions
+12.8k Golang : zlib compress file example
+11.1k Golang : Create S3 bucket with official aws-sdk-go package
+5.4k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+4.7k MariaDB/MySQL : How to get version information
+5.8k Unix/Linux : Get reboot history or check when was the last reboot date
+4.9k Unix/Linux : secure copying between servers with SCP command examples