illegal rune literal
Problem : While writing out Go codes for tutorial today I came across this error message for the first time :
illegal rune literal
Diagnostic :
Based on the error information spitted out by the compiler. It pointed the fault to line 3:
import (
'fmt'
)
From the first glance everything seems to be ok and not sure why Go compiler refused to compile the code. Initially I taught it was a bug in Go compiler which reported the wrong line of code. But upon closer inspection ..... it has something to do with the single quote around 'fmt'
Solution :
Apparently, the compiler insisted on using double quote "
instead of '
to wrap around fmt
for all the packages to be imported properly.
Changing to "fmt"
solved the issue once and for all. The illegal rune literal
error just magically disappeared.
Sometimes, the error message spitted out by Go can be vague ... such as illegal rune literal
. Perhaps in future, the error message could be refined further to add more detailed description.
Reference :
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
+50.4k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+10.6k Golang : How to transmit update file to client by HTTP request example
+5.1k Javascript : Shuffle or randomize array example
+5.7k Golang : Detect variable or constant type
+10.7k Golang : Fix go.exe is not compatible with the version of Windows you're running
+23.7k Golang : Call function from another package
+19.7k Golang : Reset or rewind io.Reader or io.Writer
+17.1k Golang : Check if IP address is version 4 or 6
+16.4k Golang : Gzip file example
+17.3k Golang : [json: cannot unmarshal object into Go value of type]
+45.6k Golang : Read tab delimited file with encoding/csv package
+29.5k Golang : How to get HTTP request header information?