我正在使用go1.13.4,下面是我的項目結構:src/types/type.gosrc/utils/util.gogo.mod在 go.mod 中:module example.com/graphqlgo 1.13require github.com/graph-gophers/graphql-go v0.0.0-20191031232829-adde0d0f76a3在 src/types/type.go 中:package typestype USER struct { ...}在 src/utils/util.go 中,package utilsimport ( "example.com/graphql/types" "fmt" "io/ioutil" "os")構建項目時出現 tan 錯誤:$ go build ./...src/utils/utils.go:4:2: cannot find module providing package example.com/graphql/types我想知道為什么找不到包example.com/graphql/types?我正在閱讀https://blog.golang.org/using-go-modulesgo.mod并且我已經在項目根目錄的文件中設置了模塊名稱。
1 回答

繁花如伊
TA貢獻2012條經驗 獲得超12個贊
根據您當前的布局,導入路徑types
是example.com/graphql/src/types
。
go.mod
src
如果你有那個結構的話應該在里面?;蛘吒玫霓k法是擺脫src
. go.mod
必須位于types
和utils
文件夾旁邊。
- 1 回答
- 0 關注
- 131 瀏覽
添加回答
舉報
0/150
提交
取消