无法从模块中获取软件包 [英] Unable to get the package from the module
问题描述
我正在尝试创建一个微服务应用程序,该应用程序依赖于包含一般错误的 net
模块(因此,我不必在所有模块中复制"它们).
I am trying to create a microservice application, which depends on my net
module which contains general errors (so i don't have to "replicate" them across all of my modules).
问题是由于某种原因,它能够找到该模块,但随后告诉我该模块没有软件包( net
模块没有 main.go
文件,因为它只是在其他项目中使用的一组文件)
The issue is that for some reason it is able to find the module, but then telling me that the modules has no package (the net
module does not have the main.go
file, since it is just a group of files which are used across other projects)
go: finding github.com/USERNAME/net latest
build github.com/USERNAME/micro-helix: cannot load github.com/USERNAME/net: module github.com/USERNAME/net@latest found (v0.0.0-20191209010811-97a65ac0928c), but does not contain package github.com/USERNAME/net
这是 go.mod
文件,其中包含所有必要的要求(就我而言):
And here is the go.mod
file containing all the necessary requirements (as far as i am concerned):
module github.com/USERNAME/micro-helix
go 1.13
require (
github.com/USERNAME/net v0.0.0-20191209010811-97a65ac0928c
github.com/USERNAME/service v0.0.0-20191209005400-57ee0eb02082
github.com/golang/protobuf v1.3.2
github.com/hashicorp/consul/api v1.3.0 // indirect
github.com/micro/go-micro v1.17.1
github.com/micro/go-plugins v1.5.1 // indirect
github.com/nats-io/nats-streaming-server v0.16.2 // indirect
github.com/nats-io/stan.go v0.5.2 // indirect
github.com/nicklaw5/helix v0.5.4
github.com/spf13/viper v1.5.0 // indirect
)
net
模块的 go.mod
文件非常简单:
The go.mod
file for the net
module is as simple as:
module github.com/USERNAME/net
go 1.13
如果您需要任何进一步的说明,我在这里提供.我知道这可能是一些菜鸟错误(配置错误),但这实际上是我第一次尝试用Go编写东西.
If you need any further clarification, i am here to provide. I know that this might be some rookie mistake (misconfiguration) but this is my first week actually trying to write something in Go.
更新#1
这是 github.com/USERNAME/net
模块的结构
/-
errors/
- error.go // github.com/USERNAME/net/errors
- code.go // github.com/USERNAME/net/errors
proto/
- error.pb.go // github.com/USERNAME/net/proto
- response.pb.go // github.com/USERNAME/net/proto
errors.proto
go.mod // module github.com/USERNAME/net
response.proto
推荐答案
可能是您从 github.com/USERNAME/micro-helix
作为 github.com/USERNAME/net
.
您必须通过完整路径(如
You must import all of subpackages (which you use in that file) by there full paths like
import (
"github.com/USERNAME/net/errors"
"github.com/USERNAME/net/proto"
)
这篇关于无法从模块中获取软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!