Closed
Description
What version of Go are you using (go version
)?
go version go1.10 linux/amd64
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="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/godev"
GORACE=""
GOROOT="/root/go"
GOTMPDIR=""
GOTOOLDIR="/root/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build085446828=/tmp/go-build"
What did you do?
test-binary-package/main.go
package main
import (
"fmt"
"test-binary-package/myframework"
)
func main() {
fmt.Println("test:", myframework.Hello("golang"))
}
test-binary-package/myframework/hello.go
package myframework
import "fmt"
import "test-binary-package/myname"
func Hello(name string) string {
return fmt.Sprintf("Hello, %s! I am %s", name, myname.MYNAME)
}
test-binary-package/myname/myname.go
package myname
const MYNAME = "golang"
I run go install
in test-binary-package/myframework
and test-binary-package/myname
dir then replace the content code with:
//go:binary-only-package
package myframework
and
//go:binary-only-package
package myname
Then go build
the test program.
What did you expect to see?
The test code works well with go1.9:
# go build -v -x
WORK=/tmp/go-build397500380
test-binary-package
mkdir -p $WORK/test-binary-package/_obj/
mkdir -p $WORK/test-binary-package/_obj/exe/
cd /root/godev/src/test-binary-package
/root/go/pkg/tool/linux_amd64/compile -o $WORK/test-binary-package.a -trimpath $WORK -goversion go1.9 -p main -complete -buildid 1fe88b276335f95449725f3118d43fc70f104d57 -D _/root/godev/src/test-binary-package -I $WORK -I /root/godev/pkg/linux_amd64 -pack ./main.go
cd .
/root/go/pkg/tool/linux_amd64/link -o $WORK/test-binary-package/_obj/exe/a.out -L $WORK -L /root/godev/pkg/linux_amd64 -extld=gcc -buildmode=exe -buildid=1fe88b276335f95449725f3118d43fc70f104d57 $WORK/test-binary-package.a
mv $WORK/test-binary-package/_obj/exe/a.out test-binary-package
What did you see instead?
Error with go1.10:
# go build -v -x
WORK=/tmp/go-build337943129
test-binary-package/myframework
test-binary-package
mkdir -p $WORK/b001/
cat >$WORK/b001/importcfg << 'EOF' # internal
# import config
packagefile fmt=/root/go/pkg/linux_amd64/fmt.a
packagefile test-binary-package/myframework=/root/godev/pkg/linux_amd64/test-binary-package/myframework.a
packagefile runtime=/root/go/pkg/linux_amd64/runtime.a
EOF
cd /root/godev/src/test-binary-package
/root/go/pkg/tool/linux_amd64/compile -o $WORK/b001/_pkg_.a -trimpath $WORK/b001 -p main -complete -buildid BIGdoXiIkuDDnICLqC05/BIGdoXiIkuDDnICLqC05 -goversion go1.10 -D "" -importcfg $WORK/b001/importcfg -pack -c=4 ./main.go
/root/go/pkg/tool/linux_amd64/buildid -w $WORK/b001/_pkg_.a # internal
cp $WORK/b001/_pkg_.a /root/.cache/go-build/94/9484f19284c521d729eebdc97357259fc03d90c12eb4217a7d3625fffcbacb4f-d # internal
cat >$WORK/b001/importcfg.link << 'EOF' # internal
packagefile test-binary-package=$WORK/b001/_pkg_.a
packagefile fmt=/root/go/pkg/linux_amd64/fmt.a
packagefile test-binary-package/myframework=/root/godev/pkg/linux_amd64/test-binary-package/myframework.a
packagefile runtime=/root/go/pkg/linux_amd64/runtime.a
packagefile errors=/root/go/pkg/linux_amd64/errors.a
packagefile io=/root/go/pkg/linux_amd64/io.a
packagefile math=/root/go/pkg/linux_amd64/math.a
packagefile os=/root/go/pkg/linux_amd64/os.a
packagefile reflect=/root/go/pkg/linux_amd64/reflect.a
packagefile strconv=/root/go/pkg/linux_amd64/strconv.a
packagefile sync=/root/go/pkg/linux_amd64/sync.a
packagefile unicode/utf8=/root/go/pkg/linux_amd64/unicode/utf8.a
packagefile runtime/internal/atomic=/root/go/pkg/linux_amd64/runtime/internal/atomic.a
packagefile runtime/internal/sys=/root/go/pkg/linux_amd64/runtime/internal/sys.a
packagefile sync/atomic=/root/go/pkg/linux_amd64/sync/atomic.a
packagefile internal/cpu=/root/go/pkg/linux_amd64/internal/cpu.a
packagefile internal/poll=/root/go/pkg/linux_amd64/internal/poll.a
packagefile internal/testlog=/root/go/pkg/linux_amd64/internal/testlog.a
packagefile syscall=/root/go/pkg/linux_amd64/syscall.a
packagefile time=/root/go/pkg/linux_amd64/time.a
packagefile unicode=/root/go/pkg/linux_amd64/unicode.a
packagefile internal/race=/root/go/pkg/linux_amd64/internal/race.a
EOF
mkdir -p $WORK/b001/exe/
cd .
/root/go/pkg/tool/linux_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -buildmode=exe -buildid=VRqrpvfeQkTyAVOZ5Wtp/BIGdoXiIkuDDnICLqC05/2AsWVWQk98D3OTEb1GW0/VRqrpvfeQkTyAVOZ5Wtp -extld=gcc $WORK/b001/_pkg_.a
# test-binary-package
cannot find package test-binary-package/myname (using -importcfg)
/root/go/pkg/tool/linux_amd64/link: cannot open file : open : no such file or directory
It seems there miss packagefile define for the nested package test-binary-package/myname
.