Please answer these questions before submitting your issue. Thanks!
go version)?go version go1.11 linux/amd64
Yes
go env)?GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mido/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mido/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build510519474=/tmp/go-build -gno-record-gcc-switches"
A simple plugin code :
package main
import "fmt"
type greeting string
func (g greeting) Greet() {
fmt.Println("Hello Universe")
}
// exported as symbol named "Greeter"
var Greeter greeting
And the following commands:
go build -buildmode=plugin -o a.so a.go
To generate a.so file. It works perfectly fine in go version go1.10 linux/amd64
# runtime
/usr/local/go/src/runtime/map.go:64:2: bucketCntBits redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:64:18
/usr/local/go/src/runtime/map.go:65:2: bucketCnt redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:65:23
/usr/local/go/src/runtime/map.go:69:2: loadFactorNum redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:69:18
/usr/local/go/src/runtime/map.go:70:2: loadFactorDen redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:70:18
/usr/local/go/src/runtime/map.go:76:2: maxKeySize redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:76:17
/usr/local/go/src/runtime/map.go:77:2: maxValueSize redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:77:17
/usr/local/go/src/runtime/map.go:82:2: dataOffset redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:85:4
/usr/local/go/src/runtime/map.go:91:2: empty redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:91:19
/usr/local/go/src/runtime/map.go:92:2: evacuatedEmpty redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:92:19
/usr/local/go/src/runtime/map.go:93:2: evacuatedX redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:93:19
/usr/local/go/src/runtime/map.go:93:2: too many errors
I tested it with go 1.10.4 and it compiles with no error. It's only happening with go 1.11
Was the main go binary and the plugin compiled with go1.11?
/usr/local/go/src/runtime/hashmap.go does not exist in go1.11 but in go1.10 so it seems this is mixing go1.11 and go1.10 code/binaries or the go1.11 installation was not clean and was unpacked over a go1.10 installation.
Please recompile all code involved with go1.11 and make sure that installation was clean as /usr/local/go/src/runtime/hashmap.go should not exist in go1.11.
@martisch , yes that was it. I probably didn't remove the previous go installation properly. Thanks!!!
same problem. same solution. thanks guys!
Most helpful comment
Was the main go binary and the plugin compiled with go1.11?
/usr/local/go/src/runtime/hashmap.go does not exist in go1.11 but in go1.10 so it seems this is mixing go1.11 and go1.10 code/binaries or the go1.11 installation was not clean and was unpacked over a go1.10 installation.
Please recompile all code involved with go1.11 and make sure that installation was clean as /usr/local/go/src/runtime/hashmap.go should not exist in go1.11.