package main import "C" import "fmt" //export PrintBye func PrintBye() { fmt.Println("From DLL:Bye!") } //export Sum func Sum(a int, b int) int { return a + b } func main() { }
1、红色的注释是必须的,否则函数无法导出
2、main函数也是必须的
在命令行调用
go build -buildmode=c-shared -o test1.dll test1.go