-2

I published a go module in github: github.com/zhaoyi0113/test-go-module. The go.mod file is in apps folder rather than root folder.

When I import it from another project, I run go get github.com/zhaoyi0113/test-go-module@0.0.2 and it runs successfully. However, I get the error when compiling:

main.go

import (
log "github.com/zhaoyi0113/test-go-module/apps/logger"
)

log.Test()
main.go:11:2: no required module provides package github.com/zhaoyi0113/test-go-module/apps/logger; to add it:
        go get github.com/zhaoyi0113/test-go-module/apps/logger

I get error when import the sub folder:

> go get github.com/zhaoyi0113/test-go-module/apps/logger@v0.0.2
go: module github.com/zhaoyi0113/test-go-module@v0.0.2 found, but does not contain package github.com/zhaoyi0113/test-go-module/apps/logger

How should I solve this issue?

Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523

1 Answers1

0

after Go 1.18 you can use go work command to enable working with multi-modules in the root folder

checkout this tutorial for more https://go.dev/doc/tutorial/workspaces