我有一个具有以下结构的项目:
myapp/
-services/
-services/
-exch.go
-services.go
-server.go
将 $GOPATH 设置/home/dev/dev/go
为此是如何server.go
命名它的包和导入:
//server.go
package main
import (
"net/http"
"github.com/labstack/echo"
"myapp/services"
)
这是services.go
:
//services.go
package services
import (
"fmt"
"myapp/services/exch"
)
这是exch.go
:
//exch.go
package exch
import (
"net/http"
"fmt"
"io/ioutil"
"encoding/json
)
现在,server.go
进口package services
正常,但services.go
找不到package exch
. 我尝试以多种方式更改导入路径,但无法使其正常工作。我错过了什么吗?
知道 /myapp 位于此处可能很有用:/home/dev/dev/go/src