I'm trying to play with go:linkname, and I wrote a demo for this.

directory structure:

[test]$ tree
.
├── main.go
├── pri
│   └── a.go
└── pub
    ├── issue15006.s
    └── b.go

a.go:

package pri 


import (
    "fmt"
)
func rua() int64 {
    fmt.Println("rua in pri")
    return 1
}

b.go:

package pub 


import (
    "unsafe"
)


var _ = unsafe.Sizeof(0)


//go:noescape
//go:linkname rua test/pri.rua
func rua() int64


func Rua() int64 {
    return rua()
}

main.go:

package main


import (
    "test/pub"
)


func main() {
    println(pub.Rua())
}

issue15006.s is a workaround for issue 15006 
<https://github.com/golang/go/issues/15006> and it's totally empty.

Than I ran `go run main.go` and got an error:

# command-line-arguments
test/pub.Rua: test/pri.rua: not defined
test/pub.Rua: undefined: test/pri.rua

So what's wrong with this demo?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to