Bug: run go run main.go on mac and report an error, fork/exec /var/fold/T/go-build269/b001/ex

Bug: run go run main.go on mac and report an error, fork/exec /var/fold/T/go-build269/b001/ex

When I executed go run main.go through goland today to run the go code I wrote locally, I found an error fork/exec / xxx

Solution

method one:

Because the current build environment of go is wrong, for example: I am a mac system, but the GOOS configuration in go before is linux, which leads to an error

# 设置为正确的GOOS
go env -w GOOS="darwin"
# GOOS=darwin GOARCH=amd64 go build -o  http -v ./main.go

Method Two:

It may be because after reinstalling or updating the go version, it is not updated in env

  • /var/folders/ty/q11880gn5797hjv_tnk2m_k80000gn/ path.
    Delete go env while uninstalling golang :
# 卸载golang同时删除之前的go env配置
% rm -rf /usr/local/go 
% rm -rf /etc/paths.d/go
% go env GOENV                                           
/Users/biandong/Library/Application Support/go/env
% cd /Users/biandong/Library/Application Support/
% rm -rf go

After the execution is complete, reinstall golang.

tips: Common shortcut keys for Mac to operate Goland

command+L: Jump to the specified line

command+option+L: format code

command+F: search in the current file

command+shift+F: global search

command+shift+T: set go_test.go

command+N: enter generate

Guess you like

Origin blog.csdn.net/weixin_45565886/article/details/132569561