github.com/epfl-dcsl/gotee@v0.0.0-20200909122901-014b35f5e5e9/misc/cgo/testplugin/src/plugin2/plugin2.go (about) 1 // Copyright 2016 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 package main 6 7 //#include <errno.h> 8 //#include <string.h> 9 import "C" 10 11 // #include 12 // void cfunc() {} // uses cgo_topofstack 13 14 import ( 15 "common" 16 "reflect" 17 "strings" 18 ) 19 20 func init() { 21 _ = strings.NewReplacer() // trigger stack unwind, Issue #18190. 22 C.strerror(C.EIO) // uses cgo_topofstack 23 common.X = 2 24 } 25 26 type sameNameReusedInPlugins struct { 27 X string 28 } 29 30 type sameNameHolder struct { 31 F *sameNameReusedInPlugins 32 } 33 34 func UnexportedNameReuse() { 35 h := sameNameHolder{} 36 v := reflect.ValueOf(&h).Elem().Field(0) 37 newval := reflect.New(v.Type().Elem()) 38 v.Set(newval) 39 } 40 41 func main() { 42 panic("plugin1.main called") 43 }