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
+19.9k Golang : Get password from console input without echo or masked
+15.2k Golang : Convert slice to array
+7.8k Golang : Heap sort example
+17.8k Golang : Fix cannot download, $GOPATH not set error
+32.8k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+33.9k Golang : Get file last modified date and time
+13.5k Golang : Execute function at intervals or after some delay
+5k Golang : Calculate US Dollar Index (DXY)
+15.3k Golang : Send email and SMTP configuration example
+8.2k Golang : How to get garbage collection data?
+4.9k Golang : How to search a list of records or data structures
+25k Golang : Convert file content into array of bytes