我在Windows上安装了go。GOPATH被设定为:
c:\go-workspace我在这个目录中有一个名为login.go的文件:
C:\go-workspace\src\github.com\llnw\loginlogin.go包含以下内容:
package main
func main() {
fmt.Printf("login\n")
}我尝试了以下方法来构建:
go build github.com/llnw/login/login但我知道这个错误:
can't load package: package github.com/llnw/login/login: cannot find package "github.com/llnw/login/login" in any of:
C:\Go\src\github.com\llnw\login\login (from $GOROOT)
C:\go-workspace\src\github.com\llnw\login\login (from $GOPATH)我做错了什么?
发布于 2016-10-23 05:36:51
来自go build -h
用法: build -o output build标志Build编译由导入路径命名的包以及它们的依赖项,但是它没有安装结果。如果要生成的参数是.go文件的列表,则生成将它们视为指定单个包的源文件列表。
在您的示例中,github.com/llnw/login/login看起来既不像包,也不像.go文件的列表。可能你在找这个:
go build github.com/llnw/login假设在执行此命令时,存在相对路径github.com/llnw/login。
https://stackoverflow.com/questions/40199028
复制相似问题