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

cmd/go: can't use internal package in a module #27022

Closed
ghost opened this issue Aug 16, 2018 · 4 comments
Closed

cmd/go: can't use internal package in a module #27022

ghost opened this issue Aug 16, 2018 · 4 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ghost
Copy link

ghost commented Aug 16, 2018

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

go version go1.11rc1 darwin/amd64

Does this issue reproduce with the latest release?

Yes. Also with 1.11beta1 and 1.11beta3, although not with 1.11beta2.

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/eo/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/eo/.go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go/1.11rc1"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/1.11rc1/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/eo/Projects/foo/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dz/8jn4vxsn7lz3h7ttrffxb79w0000gn/T/go-build195675254=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

% pwd
/Users/eo/Projects/foo
% echo $GOPATH
/Users/eo/.go
% cat go.mod
module github.com/eolamey/foo
% cat cmd/foo/main.go
package main

import "github.com/eolamey/foo/internal/bar"

func main() {
	bar.Hello()
}
% cat internal/bar/bar.go
package bar

import "fmt"

func Hello() {
	fmt.Println("Hello")
}
% /usr/local/go/1.11beta1/bin/go run cmd/foo/main.go
cmd/foo/main.go:3:8: use of internal package github.com/eolamey/foo/internal/bar not allowed
% /usr/local/go/1.11beta2/bin/go run cmd/foo/main.go
Hello
% /usr/local/go/1.11beta3/bin/go run cmd/foo/main.go
build main: cannot find module for path main
% /usr/local/go/1.11rc1/bin/go run cmd/foo/main.go
cmd/foo/main.go:3:8: use of internal package github.com/eolamey/foo/internal/bar not allowed

What did you expect to see?

I expect to command to compile, as it does in 1.11beta2 (and 1.10).

What did you see instead?

The command does not compile as the internal package cannot be imported.

@ALTree ALTree added this to the Go1.11 milestone Aug 16, 2018
@ALTree ALTree added modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 16, 2018
@amenzhinsky
Copy link
Contributor

amenzhinsky commented Aug 17, 2018

I'm having the same problem with go1.11rc1 run or when I'm trying to go1.11rc1 build a particular file, building a whole package with go1.11rc1 build works fine though.

@apparentlymart
Copy link

The way I encountered it was running go1.11rc1 test ./..., but same symptom nonetheless.

go1.11rc1 install of the same application works as expected, which I think agrees with @amenzhinsky's experience that go1.11rc1 build was working.

@gopherbot
Copy link

Change https://golang.org/cl/129798 mentions this issue: cmd/go: allow 'go run x.go' to use nearby internal imports in module mode

@apparentlymart
Copy link

👍 Confirmed that this is now working as expected with Go 1.11rc2.

@golang golang locked and limited conversation to collaborators Aug 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants