test.go的Go代码如下:
package main
import 'fmt'
func main(){
var a int32 = 1
fmt.Println(a)
}
go run test.go后出现的问题:test.go:3:8: illegal rune literal
解决:将 'fmt' 改成 "fmt" 单引号改成双引号;Go语言的单引号一般用来表示「rune literal」,即——码点字面量(应该是Unicode编码表)。
结论:在Go语言中不倾向于使用单引号来表示字符串,请根据需要使用双引号或反引号。
参考:
https://crazyof.me/blog/archives/2539.html
https://golang.org/ref/spec#String_literals