Golang下通过syscall调用win32的dll实现mifare card读写

来源:互联网 发布:战国之道网络连接失败 编辑:程序博客网 时间:2024/06/08 07:50

很多同学比如我虽然很喜欢golang,但是还是需要调用很多遗留项目或者其他优秀的开源项目,这时怎么办呢?我们想到的方法是用package里的syscall结合cgo


注意此处有坑:

在我调试时显示not enough arguments in call to syscall.Syscall

[ `go run dms.go` | done: 260.3744ms ]
# command-line-arguments
.\dms.go:72: not enough arguments in call to syscall.Syscall

exit status 2

因为我参照的是http://golang.org/pkg/syscall/#Syscall ,而其默认的是Linux/Unix的syscall API doc说明,

如何看windows的golang doc呢?


法1:

通过godoc command, 调用 godoc -http=:6060
然后在浏览器打开
http://localhost:6060/pkg/syscall/#Syscall,这才是windows的golang package api

法2:http://golang.org/src/pkg/syscall/syscall_windows.go


项目实战


mifare card读写:

lib:

https://github.com/philsong/golang_samples/blob/master/src/mif/mif.go

testapp:

https://github.com/philsong/golang_samples/tree/master/src/dms


the end.

原创粉丝点击