cat test.go
package main
import "builtin"
func main() {
return
}
go run test.go
can't find import: "builtin"
我只是好奇,因为该文件存在并且已正确打包。但不能像其他包一样导入。
/usr/local/go/src/pkg/builtin/builtin.go
您不需要导入它。默认导入。
From http://golang.org/pkg/builtin http://golang.org/pkg/builtin:
内置包提供了 Go 预先声明的文档
身份标识。此处记录的物品实际上并不在包装中
内置的,但它们的描述允许 godoc 呈现
该语言的特殊标识符的文档。
如果你看一下内容http://golang.org/src/pkg/builtin/builtin.go http://golang.org/src/pkg/builtin/builtin.go你会注意到只有声明
// The copy built-in function copies elements from a source slice into a
// destination slice. (As a special case, it also will copy bytes from a
// string to a slice of bytes.) The source and destination may overlap. Copy
// returns the number of elements copied, which will be the minimum of
// len(src) and len(dst).
func copy(dst, src []Type) int
正如@Anonymous所说,编译器会跳过它:http://golang.org/src/cmd/go/build.go?#L558 http://golang.org/src/cmd/go/build.go?#L558
if p.Standard {
switch p.ImportPath {
case "builtin", "unsafe":
// Fake packages - nothing to build.
return a
}
// gccgo standard library is "fake" too.
if _, ok := buildToolchain.(gccgoToolchain); ok {
// the target name is needed for cgo.
a.target = p.target
return a
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)