Passing the optimization flag to the Go compiler?

To compile the Go program you type in go build myprogram.go, can you pass optimization flags or is the code always compiled in the same way? I'm talking about speed optimizations, code size optimizations, or other optimizations.

I know if you use gccgo, you just go through -O2or -O0, but my question is about the official Go compiler go.

+4
source share
1 answer

There are actually no explicit flags, this link to the wiki page shows the optimization performed by the Go compiler, and the golang-nuts topic was discussed in this thread .

Go gc .

-gcflags '-N -l'
  • -N:
  • -l:
+4

Source: https://habr.com/ru/post/1681082/


All Articles