[英]Golang package imports - cannot find package
This is my first time asking a question here, anyway, I am wondering why it says it can't find the package, even though github.com/JohnDoe/temperature/conversion/conv
is inside the $GOPATH
无论如何,这是我第一次在这里问一个问题,尽管
github.com/JohnDoe/temperature/conversion/conv
位于$GOPATH
内,但我想知道为什么它说找不到包
[johndoe@johndoe temperature]$ go run main.go
main.go:5:2: cannot find package "github.com/JohnDoe/temperature/conversion/conv" in any of:
/usr/local/go/src/github.com/JohnDoe/temperature/conversion/conv (from $GOROOT)
/home/johndoe/Workspace/Go/src/github.com/JohnDoe/temperature/conversion/conv (from $GOPATH)
more details: 更多细节:
[johndoe@johndoe conversion]$ pwd
/home/johndoe/Workspace/Go/src/github.com/JohnDoe/temperature/conversion
[johndoe@johndoe conversion]$ ls
conv.go
Thoughts? 有什么想法吗?
You're mistaking packages and file. 您误装了软件包和文件。 In go (contrary to say… python), a package is represented by a directory, and files in this directory are nothing more than code.
在go中(与之相反……python),一个包由一个目录表示,该目录中的文件仅是代码。 So you should import the
github.com/JohnDoe/temperature/conversion
package. 因此,您应该导入
github.com/JohnDoe/temperature/conversion
包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.