Skip to content

External access to Internal package in workspace #71218

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

Closed
okm-8 opened this issue Jan 10, 2025 · 2 comments
Closed

External access to Internal package in workspace #71218

okm-8 opened this issue Jan 10, 2025 · 2 comments

Comments

@okm-8
Copy link

okm-8 commented Jan 10, 2025

Go version

go version go1.23.3 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='~/Library/Caches/go-build'
GOENV='~/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='~/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='~/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.3'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='~/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK='~/projects/sandbox/go_internal_package_issue/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/xk/mlc_37qd2jj8pcjkmsf9gqb40000gn/T/go-build302425133=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

We made some project

.
├── go.work
├── module-a
│   ├── go.mod
│   └── internal
│       └── test.go
└── module-b
    ├── cmd
    │   └── main.go
    └── go.mod

I am not going to deep, but by coincidence we get

// module-a/go.mod

module moduleA

go 1.23
// module-b/go.mod

module moduleA/moduleB

go 1.23

so module B contains moduleA as part of its path in workspace

and, than, we do that

// module-b/cmd/main.go

package main

import "moduleA/internal"

func main() {
	internal.Test()
}

What did you see happen?

All is compiling and working

What did you expect to see?

Should not even compiling, because moduleB is trying to call an internal function of moduleA

@mvdan
Copy link
Member

mvdan commented Jan 10, 2025

Duplicate of #30569.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants