...

Source file src/cmd/cgo/internal/testplugin/testdata/plugin2/plugin2.go

Documentation: cmd/cgo/internal/testplugin/testdata/plugin2

     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  	"reflect"
    16  	"strings"
    17  
    18  	"testplugin/common"
    19  )
    20  
    21  func init() {
    22  	_ = strings.NewReplacer() // trigger stack unwind, Issue #18190.
    23  	C.strerror(C.EIO)         // uses cgo_topofstack
    24  	common.X = 2
    25  }
    26  
    27  type sameNameReusedInPlugins struct {
    28  	X string
    29  }
    30  
    31  type sameNameHolder struct {
    32  	F *sameNameReusedInPlugins
    33  }
    34  
    35  func UnexportedNameReuse() {
    36  	h := sameNameHolder{}
    37  	v := reflect.ValueOf(&h).Elem().Field(0)
    38  	newval := reflect.New(v.Type().Elem())
    39  	v.Set(newval)
    40  }
    41  
    42  func main() {
    43  	panic("plugin1.main called")
    44  }
    45  

View as plain text