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
+15.3k Golang : Save(pipe) HTTP response into a file
+12.6k Golang : Arithmetic operation with numerical slices or arrays example
+28.6k Golang : Change a file last modified date and time
+10.8k Golang : Get currencies exchange rates example
+4.9k Which content-type(MIME type) to use for JSON data
+14.4k Golang : Recombine chunked files example
+6.8k Golang : Calculate pivot points for a cross
+13.6k Golang : Read XML elements data with xml.CharData example
+17.2k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+39.8k Golang : Remove dashes(or any character) from string
+15.7k Golang : Force download file example