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
+11.1k Golang : Secure file deletion with wipe example
+20.1k Golang : Underscore or snake_case to camel case example
+19.5k Golang : Check if os.Stdin input data is piped or from terminal
+8.4k Golang : Find network service name from given port and protocol
+8.4k Golang : HTTP Routing with Goji example
+9k Golang : Changing a RGBA image number of channels with OpenCV
+8.6k Golang : Capture text return from exec function example
+6k Unix/Linux : Use netstat to find out IP addresses served by your website server
+10.1k Swift : Convert (cast) String to Integer
+22.2k Golang : Strings to lowercase and uppercase example
+15.6k Golang : convert string or integer to big.Int type
+4.1k Adding Skype actions such as call and chat into web page examples