Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't seem to import modules from other directory trees #39618

cleblanc189 opened this issue Jun 16, 2020 · 3 comments

Can't seem to import modules from other directory trees #39618

cleblanc189 opened this issue Jun 16, 2020 · 3 comments


Copy link

@cleblanc189 cleblanc189 commented Jun 16, 2020

I've been going through hell coverting out project to use modules. I now realize the module name can't end in v1 but I still can't seem to solve all the problems. I created a simple minimal example to show the error.

What version of Go are you using (go version)?

$ go version
go version go1.13 windows/amd64

Does this issue reproduce with the latest release?

Not sure

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\chris_Leblanc\AppData\Local\go-build
set GOENV=C:\Users\chris_Leblanc\AppData\Roaming\go\env
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\chris_Leblanc\go
set GOPROXY=,direct
set GOROOT=c:\go
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=c:/cygwin/bin/x86_64-w64-mingw32-gcc.exe
set CXX=g++
set GOMOD=C:\eng\PeterFreshman\test.go\src\go.mod
set CGO_CFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\CHRIS_~1\AppData\Local\Temp\go-build311953050=/tmp/go-build -gn

What did you do?

I've created two servers that require the use of two services, but I can't seem to properly include the service module from my server module.
cd src && go mod tidy

What did you expect to see?

What did you see instead?

go: test.go/src/server/v1beta1@v0.0.0 requires
test.go/src/service/v1beta1@v0.0.0: unrecognized import path "test.go/src/service/v1beta1" (https fetch: Get https://test.go/src/ser
vice/v1beta1?go-get=1: dial tcp: lookup test.go: no such host)

Copy link

@bcmills bcmills commented Jun 17, 2020

You have added a replace directive for test.go/src/server/v1beta1. The error occurs when resolving test.go/src/service/v1beta1.

(However, note that for the vast majority of uses, we recommend a single module at the repo root rather than nested modules for subdirectories. This would be a lot simpler with a single module for test.go/src as a whole.)

Copy link

@bcmills bcmills commented Jun 17, 2020

(Note that, by design, only replace directives from the main module's go.mod file are applied.)

Copy link

@cleblanc189 cleblanc189 commented Jun 17, 2020

Thanks Brian. Not sure how I got the idea that I needed modules everywhere. It was my mistake. I eventually found the error was caused by some files generated from protobufs which didn't have the correct include path. A more verbose output would have helped me a lot (I come from the land of C compilers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.