[WSL] cgo: C compiler 'gcc' not found

When I first time built a Golang project from VS Code wsl mode, I got the below error: Build Error: go build -o /home/oscar/source/github.com/xx/xx/__debug_bin -gcflags all=-N -l . # runtime/cgo cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH (exit status 2) My first reaction for this error is to install the gcc compiler in my Windows environment. However, the solution is actually to install gcc compiler in the wsl environment. ...

DigitalOcean Referral Badge
Sign up to get $200, 60-day account credit !