• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5package main
6
7// // No C code required.
8import "C"
9
10import (
11	"reflect"
12
13	"testplugin/common"
14)
15
16func F() int {
17	_ = make([]byte, 1<<21) // trigger stack unwind, Issue #18190.
18	return 3
19}
20
21func ReadCommonX() int {
22	return common.X
23}
24
25var Seven int
26
27func call(fn func()) {
28	fn()
29}
30
31func g() {
32	common.X *= Seven
33}
34
35func init() {
36	Seven = 7
37	call(g)
38}
39
40type sameNameReusedInPlugins struct {
41	X string
42}
43
44type sameNameHolder struct {
45	F *sameNameReusedInPlugins
46}
47
48func 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
55func main() {
56	panic("plugin1.main called")
57}
58