go - 无法加载包 : package .:没有可构建的 Go 源文件

标签 go

这是错误信息:

% go get     
can't load package: package .: no buildable Go source files in /Users/7yan00

% echo $GOPATH     
/Users/7yan00/Golang

您将如何解决该错误?

最佳答案

确保您在 Go 项目源文件夹中使用该命令(如 /Users/7yan00/Golang/src/myProject)。

另一种选择(similar to this bug) 是使用 -d 选项(参见 go get command)

go get -d

The -d flag instructs get to stop after downloading the packages; that is, it instructs get not to install the packages.

看看这对你的情况是否有帮助。


但更一般地说,如 in this thread 所述:

go get is for package(s), not for repositories.

so if you want a specific package, say, go.text/encoding, then use

go get code.google.com/p/go.text/encoding

if you want all packages in that repository, use ... to signify that:

go get code.google.com/p/go.text/...

关于go - 无法加载包 : package .:没有可构建的 Go 源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24095004/

相关文章:

go - 如何使用GCE Go客户端oauth2认证实现自动认证

arrays - 如何创建包含唯一字符串的数组?

go - 限制来自 channel 的已处理消息的数量

javascript - 将 jQuery.ajax() 替换为 Go REST API 端点的 fetch() - 空负载

c# - F#'s async state machines the same as C#' 是 async 还是 go-lang 的 go 命令?

json - 将 JSON 解析为结构

go - 在 Golang 中传递 interface{} 或 []interface{}

go - 'go install' 尝试安装到/usr/lib/go 而不是我的 GOPATH。没有权限

go - 从字节 slice 到不安全结构的类型转换

vim 去 : Can't get autocompletion