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

missing or invalid package binary for binary-only package when buildmode=plugin #21451

Closed
jerrybean opened this issue Aug 15, 2017 · 3 comments
Closed

Comments

@jerrybean
Copy link

jerrybean commented Aug 15, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8.3 linux/amd64

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

GOARCH="amd64"
GOBIN="/root/work/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/work/go"
GORACE=""
GOROOT="/usr/local/go1.8.3"
GOTOOLDIR="/usr/local/go1.8.3/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build055567438=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

  1. I have one file in /root/work/go/src/say named say.go
package say
import "fmt"
func Say(s string) string {
	return fmt.Sprintf("hello %s", s)
}
  1. I try to build it to .a file go build -i -o $GOPATH/pkg/linux_amd64/say.a

  2. change /root/work/go/src/say/say.go to

//go:binary-only-package

package say
  1. another file /root/work/go/src/say/work/v1.go
package v1
import (
	"fmt"
	"say"
)
func SayToBob() {
	fmt.Println(say.Say("Bob"))
}
  1. the main file /root/work/go/src/say/work/main.go
package main
import (
	"say/work/v1"
)
func main() {
	v1.SayToBob()
}
  1. run main.go go run /root/work/go/src/say/work/main.go
go run main.go
hello Bob

that's right

  1. but in fact, i need to build SayToBob as plugin to hot reload,run
    go build -buildmode=plugin -o /root/work/go/src/say/work/v1/plugin.so /root/work/go/src/say/work/v1/v1.go

missing or invalid package binary for binary-only package say

What did you expect to see?

can build plugin

What did you see instead?

can't build plugin
missing or invalid package binary for binary-only package say

did I do something wrong? thanks!

@ianlancetaylor
Copy link
Member

In general don't run commands like go build -i -o $GOPATH/pkg/linux_amd64/say.a. Instead, run go install say.

The error binary-only package say implies that some .go file in that directory has a comment //go:binary-only-package.

Closing because I don't think there is a Go bug here. For questions about using Go, please see https://golang.org/wiki/Questions .

@twyvip
Copy link

twyvip commented Dec 12, 2017

hello jerrybean
Have you solved the problem
I had the same problem
my golang version is 1.9.2
How can I solve this problem
go build -buildmode=plugin -o test.so *.go
missing or invalid package binary for binary-only package

@ianlancetaylor
Copy link
Member

@twyvip This issue is closed. To ask questions, please use a forum; see https://golang.org/wiki/Questions. Thanks.

@golang golang locked and limited conversation to collaborators Dec 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants