Estou assistindo agora algumas apresentações que não pude ver ao vivo durante o FOSDEM 2025. E uma dessas foi sobre como compilar Go! corretamente feita pelo Dimitri John Ledkov.

O palestrante não é programador Go! mas enpacotador pra várias distros. E conhece bem sobre quais parâmetros usar.

Eu alterei meu Makefile do programa negofetch, uma re-escrita em Go! do neofetch que estou fazendo, pra usar as dicas dele.

  
BINARY = negofetch

BUILD_OPTIONS = -modcacherw
#BUILD_OPTIONS += -race
BUILD_OPTIONS += -ldflags="-w -X 'main.Version=$$(git tag -l --sort taggerdate | tail -1)'"
BUILD_OPTIONS += -buildmode=pie
BUILD_OPTIONS += -tags netgo,osusergo
BUILD_OPTIONS += -trimpath

all: $(SOURCES) dependencies $(BINARY)

dependencies:
        go mod tidy

$(BINARY): $(SOURCES)
        env GOAMD64=v2 \
                CGO_ENABLED=1 \
        go build $(BUILD_OPTIONS) .    
  

Olhando pelo govulncheck, que ele também recomenda usar, parece bom.

  
❯ govulncheck -mode=binary negofetch
Scanning your binary for known vulnerabilities...

No vulnerabilities found.

Share feedback at https://go.dev/s/govulncheck-feedback.    
  

Pra quem estiver interessado, esse é o vídeo:



https://fosdem.org/2025/schedule/event/fosdem-2025-4406-build-better-go-release-binaries/
We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.