can a sub-directory package of a module be imported?

84 views
Skip to first unread message

Jason E. Aten

unread,
Jun 30, 2020, 12:34:48 AM6/30/20
to golang-nuts
I have a files laid out like this (OSX):



~/go/src/github.com/user/fish/cmd/demo $ go build  ## with GO111MODULE unset, under go1.14.4. Also GOPRIVATE=github.com/user   and GOPATH=$HOME/go
 
go: finding module for package github.com/liked/movies/v2/api/client
main.go:4:2: module github.com/liked/movies/v2@latest found (v2.0.0-alpha.1), but does not contain package github.com/liked/movies/v2/api/client

So the demo/main.go import of the client package is not resolved. Is it possible, in general, to import a package within a module? 

If so, how does one do it?

Volker Dobler

unread,
Jun 30, 2020, 2:18:54 AM6/30/20
to golang-nuts
Yes, of course.

Start of by deciding whether you want to use Go Modules or
GOPATH builds and set GO111MODULE accordingly. Your
setup uses the defaults which change from release to release
and doing it in a deterministic way.

Then: You did not show the package clause of wanda.go.

It is strange that cmd/demo doesn't recognize its own module.
Is there a fundamental reason to name the module github.com/liked/movies
while the repo is github.com/user/fish ?

Last: Did you try a replace directive?

V.
 
 
Reply all
Reply to author
Forward
0 new messages