英文:
Import go module in project to another module in the same project
问题
我有以下的项目结构:
.
├── daos
│ ├── daos.go
│ ├── daos.iml
│ ├── go.mod
│ └── go.sum
├── entities
│ ├── entities
│ │ └── pets.go
│ ├── entities.iml
│ └── go.mod
└── pkg.iml
我想将模块entities
导入到daos
中,但是出现了以下错误:
go: 找不到 github.com/goncharovmvdev/pets/entities/pets 包的模块
github.com/goncharovmvdev/pets/daos 导入
github.com/goncharovmvdev/pets/entities/pets: 找到模块 github.com/goncharovmvdev/pets@latest (v0.0.0-20220625073141-e49db91a04de),但不包含包 github.com/goncharovmvdev/pets/entities/pets
英文:
I have the following project structure:
<br/>
.
├── daos
│   ├── daos.go
│   ├── daos.iml
│   ├── go.mod
│   └── go.sum
├── entities
│   ├── entities
│   │   └── pets.go
│   ├── entities.iml
│   └── go.mod
└── pkg.iml
I want to import module entities
to daos
, but get the following error:
go: finding module for package github.com/goncharovmvdev/pets/entities/pets
github.com/goncharovmvdev/pets/daos imports
github.com/goncharovmvdev/pets/entities/pets: module github.com/goncharovmvdev/pets@latest found (v0.0.0-20220625073141-e49db91a04de), but does not contain package github.com/goncharovmvdev/pets/entities/pets
答案1
得分: 1
如果你想将实体导入到daos中,有两种方法:
- 将实体的源代码推送到你的Github上。
- 你可以使用类似这样的替换指令(https://go.dev/doc/tutorial/call-module-code)。
英文:
If you want to import the entities to daos, there are 2 ways:
- Push the entities' source code to your Github.
- You can use the replace directive like this (https://go.dev/doc/tutorial/call-module-code)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论