I have a CLI utility written in Go 1.22 and it works great! However, I’m interested in trying out gccgo (included in a gcc-snapshot with Go 1.18) for potential performance and file size improvements.
When I try to compile my code with gccgo, I get a bunch of import errors for standard library packages:
could not import encoding/json (no required module provides package
“encoding/json”) could not import time (no required module provides
package “time”) …
I’ve tried setting GOPATH/GOBIN and disabling Go modules (go env -w GO111MODULE=off), but I’m still having issues.
I have following project structure:
user
go
dev
utility
So, I have tried to set GOPATH=//home/user/go, GOBIN=$GOPATH/bin.
I have also tried to move dev/utility to go/src/utility, but none of that helped.
What do I need to do to get my Go 1.22 code to compile with gccgo (Go 1.18)?
Additionally, based on your experience, is it worth the effort to switch to gccgo for my use case (CLI tool)?