Source file src/cmd/cgo/internal/testplugin/testdata/method2/main.go
1 // Copyright 2021 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 // A type can be passed to a plugin and converted to interface 6 // there. So its methods need to be live. 7 8 package main 9 10 import ( 11 "plugin" 12 13 "testplugin/method2/p" 14 ) 15 16 var t p.T 17 18 type I interface{ M() } 19 20 func main() { 21 pl, err := plugin.Open("method2.so") 22 if err != nil { 23 panic(err) 24 } 25 26 f, err := pl.Lookup("F") 27 if err != nil { 28 panic(err) 29 } 30 31 f.(func(p.T) interface{})(t).(I).M() 32 } 33