我正在尝试运行一个简单的 hello world 样式程序,该程序从单独的自定义包中导入打印功能,但尽管$GOPATH设置了正确的等,Go 仍无法找到它。
缺少什么会使文件被拾取?
etherk1ll@ubuntu:~/Development/GoWorkSpace/src/sonarparser$ echo $GOPATH
/home/etherk1ll/Development/GoWorkSpace/
etherk1ll@ubuntu:~/Development/GoWorkSpace/src/sonarparser$ pwd
/home/etherk1ll/Development/GoWorkSpace/src/sonarparser
etherk1ll@ubuntu:~/Development/GoWorkSpace/src/sonarparser$ ls
jsonparser.go main.go
etherk1ll@ubuntu:~/Development/GoWorkSpace/src/sonarparser$ go run main.go
main.go:5:2: cannot find package "sonarparser/jsonparser" in any of:
/usr/local/go/src/sonarparser/jsonparser (from $GOROOT)
/home/etherk1ll/Development/GoWorkSpace/src/sonarparser/jsonparser (from $GOPATH)
main.go
package main
import (
"fmt"
"jsonparser"
)
func main() {
fmt.Println("Hello world 1")
fmt.Println(jsonparser.HelloTwo)
}
jsonparser.go
package jsonparser
import "fmt"
func HelloTwo() {
fmt.Println("Hello world 2")
}
慕桂英4014372
相关分类