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
+10.5k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+6k Golang : Measure execution time for a function
+24.4k Golang : GORM read from database example
+9.1k Golang : does not implement flag.Value (missing Set method)
+6.2k Golang : How to get capacity of a slice or array?
+17.6k Golang : Upload/Receive file progress indicator
+8.4k PHP : How to parse ElasticSearch JSON ?
+15.2k Golang : Get query string value on a POST request
+15.1k Golang : How to check if IP address is in range
+25.3k Golang : Convert long hexadecimal with strconv.ParseUint example
+5.6k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+27.6k PHP : Count number of JSON items/objects