我安装了一个test0
包$gopath\pkg\windows_386\hello\test0.a
,但是当我构建一个依赖于test0
包的主包时,编译器说:import "hello/test0": cannot find package
.
为什么会这样?
我有两个 go 文件:
$gopath/src/hello.go
package main
import (
"fmt"
"hello/test0"
)
func main() {
fmt.Println(test0.Number)
}
$gopath/src/hello/test0/test0.go
package test0
const (
Number int = 255
)
起初,我运行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