x_src/x.go

package x

import "fmt"

func init() {
   fmt.Println("x package init..")
}
func Add(x, y int) int {
   return x + y
}

func Hello(name string) {
   fmt.Printf("Hello %s\n", name)
}
go build -o x.a -i   // 编译静态库,然后复制到 $GOPATH/pkg/windows_amd64/git.dllhook.com/piao/binary-only-pkg/x.a   // 以Windows64bit为例



x/x.go

//go:binary-only-package

package x

// 下面代码不是必须,只是提供给开发人员看的
func Add(x, y int) int {
   return 0
}

func Hello(name string) {

}




main.go

package main

import (
   "fmt"
   "git.dllhook.com/piao/binary-only-pkg/x"
)

func main() {
   x.Hello("Piao")
   fmt.Printf("result=%d\n", x.Add(1, 2))
}






你可能感兴趣的文章

评论区

发表评论

必填

选填

选填

必填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。