Go build package error: TARGET_OS_MAC & IOMasterPort

Go build packaging Error:


../../../../go/pkg/mod/github.com/shirou/[email protected]+incompatible/cpu/cpu_darwin_cgo.go:13:5: 
warning: 'TARGET_OS_MAC' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]

warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]

note: 'IOMasterPort' has been explicitly marked deprecated here

I don’t know the cause of the problem at present. It may be caused by the upgrade of the MAC system

My version is MacOS Monterey 12.3

Solution (not necessarily effective)

Modify CGO_ENABLED,default is CGO_ENABLED="1"

go env -w CGO_ENABLED="0"

Read More: