我需要读取以GBK编码的文本文件.Go编程语言中的标准库假定所有文本都以UTF-8编码.
如何读取其他编码中的文件?
j:=1
Run Code Online (Sandbox Code Playgroud)
Kind的j就是reflect.Int,符合市场预期.
var j interface{} = 1
Run Code Online (Sandbox Code Playgroud)
Kind的j也是reflect.Int.
哪种价值是reflect.Interface什么?
我安装了一个test0软件包$gopath\pkg\windows_386\hello\test0.a,但是当我构建一个依赖于该test0软件包的主软件包时,编译器会说:import "hello/test0": cannot find package。
为什么会这样?
我有两个文件:
$gopath/src/hello.go
package main
import (
"fmt"
"hello/test0"
)
func main() {
fmt.Println(test0.Number)
}
Run Code Online (Sandbox Code Playgroud)
$gopath/src/hello/test0/test0.go
package test0
const (
Number int = 255
)
Run Code Online (Sandbox Code Playgroud)
首先,我运行go install hello/test0,它生成了$gopath\pkg\windows_386\hello\test0.a
然后,我删除目录 $gopath/src/hello
终于,我运行了go build hello.go,编译器说hello.go:5:2: import "hello/test0": cannot find package
类型标识规则指出:
Two named types are identical if their type names originate in the same TypeSpec
我不太明白两个类型名称是如何来自同一个TypeSpec的.你能解释一下或给我看一个例子吗?