导入本地模块

时间:2018-11-18 16:32:30

标签: go module

我正在导入本地go模块,但是我不断收到以下错误消息:

main.go:6:2: unknown import path "github.com/getset0/kamona/database": cannot find module providing package github.com/getset0/kamona/database client.go:5:2: unknown import path "github.com/getset0/kamona/kauth": cannot find module providing package github.com/getset0/kamona/kauth

这些文件位于我的项目根目录下,而我的go.mod如下:

module github.com/getset0/kamona

require (
    github.com/dgrijalva/jwt-go v3.2.0+incompatible
    github.com/golang/protobuf v1.2.0
    github.com/grpc-ecosystem/grpc-gateway v1.5.1
    github.com/mitchellh/mapstructure v1.1.2
    golang.org/x/net v0.0.0-20181114220301-adae6a3d119a
    golang.org/x/vgo v0.0.0-20180912184537-9d567625acf4 // indirect
    google.golang.org/grpc v1.16.0
)

replace github.com/getset0/kamona/kauth => ./kauth

replace github.com/getset0/kamona/database => ./database

我在做什么错了?

1 个答案:

答案 0 :(得分:3)

您在go.mod./kauth中是否有./database个文件?

通常,go.mod位于项目的根目录(即github.com/getset0/kamona)。这也意味着您不需要require github.com/getset0/kamona/kauthgithub.com/getset0/kamona/database

这还意味着您不需要replace语句。