我是新来的,去和工作的一个示例代码,我想本地化。
在原来的 main.go
进口报表中,它是:
import (
"log"
"net/http"
"github.com/foo/bar/myapp/common"
"github.com/foo/bar/myapp/routers"
)
现在我有 common
和 routers
在 /home/me/go/src/myapp
包
所以我将 import 语句转换为:
import (
"log"
"net/http"
"./common"
"./routers"
)
但是当我运行 go install myapp
时,我会得到这些错误:
can't load package: /home/me/go/src/myapp/main.go:7:3: local import "./common" in non-local package
另外,当我在 import 语句中使用 common
和 routers
而不是 ./common
和 ./routers
时,我得到:
myapp/main.go:7:3: cannot find package "common" in any of:
/usr/local/go/src/common (from $GOROOT)
/home/me/go/src/common (from $GOPATH)
myapp/main.go:8:2: cannot find package "routers" in any of:
/usr/local/go/src/routers (from $GOROOT)
/home/me/go/src/routers (from $GOPATH)
我该怎么补救?