当我尝试调试时,go build参数包含-gcflags "all=-N -l",然后我导入net/http,然后构建将失败。
我尝试使用 brew 重新安装 golang,但不起作用。
并在卸载后尝试使用官方安装,不工作。
我正在尝试sudo mv /Library/Developer/CommandLineTools CommandLineTools.old && xcode-select --install,不工作。
在 JimB 的建议下,我尝试go env -w CGO_ENABLED=0了 ,以便我可以正确构建。
有什么建议么?
构建失败消息:
# crypto/x509
In file included from /usr/local/Cellar/go/1.14/libexec/src/crypto/x509/root_cgo_darwin.go:17:
In file included from /System/Library/Frameworks/Security.framework/Headers/Security.h:31:
/System/Library/Frameworks/Security.framework/Headers/SecItem.h:452:49: error: expected ','
API_AVAILABLE(macos(10.7), ios(NA), bridgeos(NA));
^
......
^
In file included from /usr/local/Cellar/go/1.14/libexec/src/crypto/x509/root_cgo_darwin.go:17:
In file included from /System/Library/Frameworks/Security.framework/Headers/Security.h:35:
/System/Library/Frameworks/Security.framework/Headers/SecImportExport.h:317:55: error: expected ','
API_AVAILABLE(macos(10.7), ios(NA), bridgeos(NA));
^
......
/System/Library/Frameworks/Security.framework/Headers/SecImportExport.h:656:49: error: expected ','
API_AVAILABLE(macos(10.7), ios(NA), bridgeos(NA));
^
......
27 errors generated.
package main
import "os"
func main() {
println(os.Args)
}
> go build main.go # success
> go build -gcflags "all=-N -l" main.go # success
--------------------------------------
package main
import "net/http"
func main() {
println(http.DefaultClient)
}
> go build main.go # success
> go build -gcflags "all=-N -l" main.go # fail <-----------
肥皂起泡泡
相关分类