Hi, I’ve been stuck on can’t this and can’t compile, checked my variable names and imports start with github…My other external package imports are fine. Could there be an issue with the import because of the structure with there being a subdirectory? I did create a go.mod file that utilizes the parent directory.
In my adapter file I’m getting an error: undefined: "github.com/org/app/internal/config".ServerConfig
However, in VS code when I hover over that variable and I see the struct I defined just fine.
adapter code github.com/org/app/subdirectory/pkg/adapters/adapter.go
:
import (
"github.com/org/app/internal/config"
)
type ServerAdapter struct {
config config.serverConfig
}
func (h *ServerAdapter) Setup(cfg *config.serverConfig) {
//do something
}
config structs code github.com/org/app/internal/config/app.go
:
type AppConfig struct {
Env string
Server ServerConfig
}
type ServerConfig struct {
Domain string
Service string
HostPort string
}
main file code github.com/org/app/subdirectory/cmd/main.go
:
import (
adapter "github.com/org/app/subdirectory/pkg/adapters"
"github.com/org/app/internal/config"
)
func main() {
cfg := config.New()
cfg.Print()
}