github.com/flyinox/gosm@v0.0.0-20171117061539-16768cb62077/misc/cgo/testplugin/src/plugin1/plugin1.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  // // No C code required.
     8  import "C"
     9  
    10  import "common"
    11  
    12  func F() int {
    13  	_ = make([]byte, 1<<21) // trigger stack unwind, Issue #18190.
    14  	return 3
    15  }
    16  
    17  func ReadCommonX() int {
    18  	return common.X
    19  }
    20  
    21  var Seven int
    22  
    23  func call(fn func()) {
    24  	fn()
    25  }
    26  
    27  func g() {
    28  	common.X *= Seven
    29  }
    30  
    31  func init() {
    32  	Seven = 7
    33  	call(g)
    34  }
    35  
    36  func main() {
    37  	panic("plugin1.main called")
    38  }