Golang : constant 20013 overflows byte error message
Haven't been updating the tutorials portion for a while as I was busy writing up examples for Golang bytes package. While executing the bytes.Buffer.WriteByte function example. The program exited with the error message "constant 20013 overflows byte error message".
Upon further investigation, it was caused by this line in the code
buff.WriteByte('中')
To fix this error which is attempting to write UTF8 character, simply replace WriteByte() with WriteRune() function.
buff.WriteRune('中')
Hope this will be helpful to whoever that encounter this error message.
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
+8.6k Golang : Heap sort example
+9.8k Golang : Test a slice of integers for odd and even numbers
+30.5k Golang : Interpolating or substituting variables in string examples
+31.2k Golang : How to convert(cast) string to IP address?
+12.8k Golang : Calculate elapsed years or months since a date
+12k Golang : Encrypt and decrypt data with x509 crypto
+12.8k Golang : How to calculate the distance between two coordinates using Haversine formula
+11.1k Android Studio : Create custom icons for your application example
+12k Golang : Display list of countries and ISO codes
+12.3k Golang : Arithmetic operation with numerical slices or arrays example
+20.9k Golang : Convert(cast) string to rune and back to string example