Please answer these questions before submitting your issue. Thanks!
go version)?go 1.11rc1
go env)?win 10x64
set GOARCH=amd64
set GOBIN=d:\soft\bin
set GOCACHE=C:\Users\Alexander.go\cache
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Alexander.go\go
set GOPROXY=
set GORACE=
set GOROOT=d:\soft\go
set GOTMPDIR=
set GOTOOLDIR=d:\soft\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\Dev\go\scratch\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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ALEXAN~1\AppData\Local\Temp\go-build973572782=/tmp/go-build -gno-record-gcc-switches
scratch/go.mod
module scratch
scratch/main.go
package main
import "scratch/internal"
func main() {
internal.F()
}
scratch/internal/f.go
package internal
func F() {}
go build main.go
Compilation success
main.go:3:8 use of internal package scratch/internal not allowed
internal/f.go should be scratch/internal/f.go? If yes, that works for me with go1.11rc2.
Yes, should be scratch/internal/f.go
May you try go1.11rc2? It works for me.
Yes, go 1.11rc2 fixed this.
What version of Go are you using (go version)?
go 1.11rc1
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/bramkumar/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/bramkumar/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/vt/6qhm_2156k10_l3g8g_nzxcm0000gp/T/go-build940353526=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
$ pwd
/Users/bramkumar/go/src/github.com/WeConnect/identity-subjects
$ cat cmd/subjects/subjects.go
package main
import (
"database/sql"
"io"
"net"
"net/http"
"strings"
"github.com/golang/protobuf/ptypes/empty"
server "github.com/weconnect/identity-subjects/internal"
log "github.com/sirupsen/logrus"
)
$ pwd
/Users/bramkumar/go/src/github.com/WeConnect/identity-subjects/internal
$ cat server.go
package internal
import (
"context"
)
What did you expect to see?
Compilation success
What did you see instead?
$go build cmd/subjects/subjects.go
cmd/subjects/subjects.go:10:2: use of internal package github.com/weconnect/identity-subjects/internal not allowed
Its the same for me with go1.11rc2
$ go1.11rc2 build cmd/subjects/subjects.go
cmd/subjects/subjects.go:10:2: use of internal package github.com/weconnect/identity-subjects/internal not allowed
go 1.11rc1
Current Go version is 1.12.6. Why you use a release candidate?
It is also better to update an open issue (https://github.com/golang/go/issues/32622) with a proper description than to continue the discussion on the closed one.
Hi @AlekSi it is mentioned in this thread that go1.1rc2 fixed the internal linking issue. I tried it and it did not seem to fix it in my case.
The right thing to ideally would be to re-open this issue #27200 and not keep re-creating new issues as duplicates just because the previous one is marked closed.
Also Go 1.12.6 released 3 days ago !
Hi @BhuvanRK , have you resolved this on your machine? I'm also getting use of internal package github.com/pion/webrtc/v2/examples/internal/signal not allowed in both go1.12.6 windows/amd64 and go1.12.6 darwin/amd64. Simple to recreate the issue: I only have a single main.go file in the root of my project (as well as go.mod and go.sum). That single Go file is this pion demo file. The error occurs when I execute go build and does not compile.
You can't import internal packages of another package: https://golang.org/doc/go1.4#internalpackages
Ah, thank you @AlekSi.
@AlekSi There is no specification that you can't in the concerned versions of go:
https://golang.org/doc/go1.12
There is: https://golang.org/cmd/go/#hdr-Internal_Directories
There is: https://golang.org/cmd/go/#hdr-Internal_Directories
@AlekSi Thanks for finding this. I'm asking because I'm a part of a new organization, and I'm using the VSCode Go extension, which complains when I'm importing a package "github.com/myorg/myapp/internal/pkg/common" into go/src/github.com/myorg/myapp/internal/app/myservice/api.go that the use of internal package ...common not allowed. It still builds fine with a docker-compose - but because the linter views this issue as more severe, it doesn't catch things that actually halt the compile process, like unused vars, etc. I figured the reason the linter was complaining about this _seeming non-issue_ was because the linter was assuming an earlier version of go (from the one you linked above) that didn't allow the import of another internal package. Instead, it turns out the build works regardless, but the linter still complains! What gives?
My guess would be incorrect GOPATH setting.
That being said, closed issues (and GitHub issues in general) is not a good place to ask questions. See https://github.com/golang/go/wiki/Questions for a list of much better places. Please ask there with more details.
@AlekSi Actually it ended up being an issue with my local directory structure. I'm new to an organization, and I was told to clone my repo into $GOPATH/src/github.enterprisename.com instead of manually creating a new folder called /myorg in which to clone my repo into. My linter was complaining about something valid, yet my build process was still succeeding, because it looked to the linter as if I was importing from a separate repo altogether when I was working on the project. Hopefully this helps someone else with this literally rookie mistake...
Basiscally, _my_ issue was:
I cloned myapp into $GOPATH/src/github.enterprisename.com instead of $GOPATH/src/github.enterprisename.com/myorg, so the docker build worked but the linter was confused. (unforced developer error)
Most helpful comment
@AlekSi Actually it ended up being an issue with my local directory structure. I'm new to an organization, and I was told to clone my repo into
$GOPATH/src/github.enterprisename.cominstead of manually creating a new folder called/myorgin which to clone my repo into. My linter was complaining about something valid, yet my build process was still succeeding, because it looked to the linter as if I was importing from a separate repo altogether when I was working on the project. Hopefully this helps someone else with this literally rookie mistake...Basiscally, _my_ issue was:
I cloned
myappinto$GOPATH/src/github.enterprisename.cominstead of$GOPATH/src/github.enterprisename.com/myorg, so the docker build worked but the linter was confused. (unforced developer error)