go工程例子

设置go代理
go env -w GOPROXY=https://goproxy.cn,direct

go mod init hid 生成go.mod
go mod tidy

****************main.go
package main
import (
"github.com/karalabe/hid"
"fmt"
)
func main() {
d := hid.Enumerate(0,0)
fmt.Println(d)
}


交叉编译
GOOS=linux CC=/usr/bin/arm-linux-gnueabihf-gcc GOARCH=arm64 CGO_ENABLED=1 go build

 

# 编译目标平台linux 64位
GOOS=linux GOARCH=amd64 go build main.go

# 编译目标平台windows 64位
GOOS=windows GOARCH=amd64 go build main.go

posted @ 2022-10-09 18:12  ahuo  阅读(21)  评论(0编辑  收藏  举报