]> Cypherpunks.ru repositories - gostls13.git/blob - src/cmd/cgo/internal/testplugin/testdata/plugin1/plugin1.go
runtime: remove crash_cgo_test CgoRaceSignal timeout
[gostls13.git] / src / cmd / cgo / internal / testplugin / testdata / plugin1 / plugin1.go
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 // // No C code required.
8 import "C"
9
10 import (
11         "reflect"
12
13         "testplugin/common"
14 )
15
16 func F() int {
17         _ = make([]byte, 1<<21) // trigger stack unwind, Issue #18190.
18         return 3
19 }
20
21 func ReadCommonX() int {
22         return common.X
23 }
24
25 var Seven int
26
27 func call(fn func()) {
28         fn()
29 }
30
31 func g() {
32         common.X *= Seven
33 }
34
35 func init() {
36         Seven = 7
37         call(g)
38 }
39
40 type sameNameReusedInPlugins struct {
41         X string
42 }
43
44 type sameNameHolder struct {
45         F *sameNameReusedInPlugins
46 }
47
48 func UnexportedNameReuse() {
49         h := sameNameHolder{}
50         v := reflect.ValueOf(&h).Elem().Field(0)
51         newval := reflect.New(v.Type().Elem())
52         v.Set(newval)
53 }
54
55 func main() {
56         panic("plugin1.main called")
57 }