github.com/yunabe/lgo@v0.0.0-20190709125917-42c42d410fdf/cmd/runner/initmodule.go (about)

     1  // Function declarations to access unexported methods in runtime package.
     2  // This technique to access unexported methods is used in other packages
     3  // (e.g. byteIndex in https://golang.org/src/net/parse.go)
     4  //
     5  // Do not add import "C" to this file because //go:linkname w/o function body is ignored for some reason
     6  // if import "C" is declared in the same file.
     7  // (See "Getting go:linkname to work" in http://www.alangpierce.com/blog/2016/03/17/adventures-in-go-accessing-unexported-functions/)
     8  
     9  package runner
    10  
    11  import (
    12  	_ "unsafe" // for go:linkname
    13  )
    14  
    15  //go:linkname modulesinit runtime.modulesinit
    16  func modulesinit()
    17  
    18  //go:linkname typelinksinit runtime.typelinksinit
    19  func typelinksinit()
    20  
    21  //go:linkname itabsinit runtime.itabsinit
    22  func itabsinit()