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

Closed
cleblanc189 opened this issue Jun 16, 2020 · 3 comments
Closed

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

cleblanc189 opened this issue Jun 16, 2020 · 3 comments
Labels
FrozenDueToAge modules WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@cleblanc189
Copy link

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 GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\chris_Leblanc\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
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 CGO_ENABLED=1
set GOMOD=C:\eng\PeterFreshman\test.go\src\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-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
o-record-gcc-switches

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.

https://github.com/cleblanc189/test.go
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)

@bcmills
Copy link
Contributor

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.)

@bcmills bcmills added modules WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jun 17, 2020
@bcmills
Copy link
Contributor

bcmills commented Jun 17, 2020

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

@cleblanc189
Copy link
Author

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)

@golang golang locked and limited conversation to collaborators Jun 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants