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

plugin: doc example doesn't work #17693

Closed
aclements opened this issue Oct 31, 2016 · 1 comment
Closed

plugin: doc example doesn't work #17693

aclements opened this issue Oct 31, 2016 · 1 comment
Milestone

Comments

@aclements
Copy link
Member

What did you do?

Attempted to use the example from the plugin package documentation to try it out:

cat >x.go <<EOF
package main

// // No C code needed.
import "C"

import "fmt"

var V int

func F() { fmt.Println("Hello, number %d", V) }
EOF
cat >y.go <<EOF
package main

import "plugin"

func main() {
	_, err := plugin.Open("x.so")
	if err != nil {
		panic(err)
	}
}
EOF
go build -buildmode=plugin x.go
go run y.go

What did you expect to see?

Nothing.

What did you see instead?

panic: plugin.Open: could not find symbol V: /home/austin/tmp/x.so: undefined symbol: x.V

goroutine 1 [running]:
panic(0x49ce40, 0xc42000c1a0)
	/home/austin/go.dev/src/runtime/panic.go:531 +0x1cf
main.main()
	/home/austin/tmp/y.go:8 +0x63
exit status 2

System details

go version devel +f135106 Sun Oct 30 19:14:08 2016 +0000 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/austin/r/go"
GORACE=""
GOROOT="/home/austin/go.dev"
GOTOOLDIR="/home/austin/go.dev/pkg/tool/linux_amd64"
TERM="dumb"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build979699063=/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"
uname -sr: Linux 4.2.0-42-generic
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04.5 LTS
Release:	14.04
Codename:	trusty
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu EGLIBC 2.19-0ubuntu6.9) stable release version 2.19, by Roland McGrath et al.
gdb --version: GNU gdb (GDB) 7.9-gg19
@aclements aclements added this to the Go1.8 milestone Oct 31, 2016
@crawshaw
Copy link
Member

This was fixed in 9da7058, which your toolchain is two commits behind.

@golang golang locked and limited conversation to collaborators Oct 31, 2017
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

3 participants