Debian Codegraph @

libgo/misc/cgo/testplugin/testdata/method/main.go

raw
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Issue 42579: methods of symbols exported from plugin must be live.
6
7 package main
8
9 import (
10 "plugin"
11 "reflect"
12 )
13
14 func main() {
15 p, err := plugin.Open("plugin.so")
16 if err != nil {
17 panic(err)
18 }
19
20 x, err := p.Lookup("X")
21 if err != nil {
22 panic(err)
23 }
24
25 reflect.ValueOf(x).Elem().MethodByName("M").Call(nil)
26 }