2

I have the following project structure:

.
├── 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
    "I want to import module entities" you cannot import modules, only packages can be imported. Please consult the official Tutorial on go.dev on how to write Go code, create modules and import packages from that module. – Volker Jun 25 '22 at 09:41

1 Answers1

1

If you want to import the entities to daos, there are 2 ways:

  1. Push the entities' source code to your Github.
  2. You can use the replace directive like this (https://go.dev/doc/tutorial/call-module-code)
nohattee
  • 66
  • 1
  • 5