KubeArmor
KubeArmor copied to clipboard
makefile go build && go mod tidy behaves differently starting with Go 1.21, leading to unknown directive toolchain errors
Feature Request
Short Description
My local go version is 1.18.1. When I run make
or go mod tidy
, it shows
cd /home/stan/KubeArmor/KubeArmor; make -C ../protobuf
make[1]: Entering directory '/home/stan/KubeArmor/protobuf'
go get .
go: errors parsing go.mod:
/home/stan/KubeArmor/protobuf/go.mod:5: unknown directive: toolchain
make[1]: *** [Makefile:13: go.sum] Error 1
make[1]: Leaving directory '/home/stan/KubeArmor/protobuf'
make: *** [Makefile:43: protobuf] Error 2
---------
go: errors parsing go.mod:
/home/stan/KubeArmor/KubeArmor/go.mod:5: unknown directive: toolchain
**Is your feature request related to a problem? User with go version lower than 1.21 try to build the KubeArmor.
A description of what the problem/use case is.
Describe the solution you'd like
After update Go module version to 1.21 and use toolchain directive. Any previous CI/CD process, or any other developer in the team that's using a different version of go can no longer build/test/run the code because of the toolchain directive.The go directive sets the minimum version of Go required to use this module. Before Go 1.21, the directive was advisory only; now it is a mandatory requirement: Go toolchains refuse to use modules declaring newer Go versionshttps://go.dev/doc/toolchain
I have researched and consulted the compatibility concerns outlined in the GitHub issue and the discussion on Hacker News (https://news.ycombinator.com/item?id=36455694). We should set GOTOOLCHAIN to local.Or add a GOFLAGS directive at the top of the file, specifying the -go flag to set the GOTOOLCHAIN environment variable:
When GOTOOLCHAIN is set to local, the go command always runs the bundled Go toolchain.
Describe alternatives you've considered
A description of any alternative solutions or features you've considered. E.g, Alternatively, KubeArmor could shower flower petals on alien invaders and win their hearts with humanity.
please assign this task to me