golang reproducable binary - changing buildId

174 views Asked by At

Currently trying to work out why building twice from same source creates different buildid and more specifically different actionID part.

I have vendored the dependencies with the following main.go

package main

import (
    "context"
    "fmt"

    awsConfig "github.com/aws/aws-sdk-go-v2/config"
)

func main() {
    awsCfg, err := awsConfig.LoadDefaultConfig(context.Background())
    if err != nil {
        fmt.Println(err)
    }
    _ = awsCfg
    fmt.Println("hello world")
}
go build -o bootstrap -mod=vendor -trimpath -buildvcs=false cmd/main.go
go clean --cache
go build -o bootstrap2 -mod=vendor -trimpath -buildvcs=false cmd/main.go

will produce the following difference respectively:

4PSJ2COQu-WEdQUCy9GF/bEj2KquhCFU77YWE3s8m/M-Eq01RmuZNuSlF4NvKh/Sw9yCoyvM-OHIpXpdNG5
1B4wdixPXI9YqxSglbgJ/bEj2KquhCFU77YWE3s8m/M-Eq01RmuZNuSlF4NvKh/Sw9yCoyvM-OHIpXpdNG5

This is causing updates to a lambda function has the produced hash from aws-cdk differs between builds on circleci even if nothing within the actual function has changed. I understand we could pass ldflags=-buildid= as a build argument (??) but want to understand what could be causing this change in actionId

This change is not consistent and sometimes produces the same buildId

go version go1.19 darwin/amd64

edit:

The following issue 33772 states this was resolved when using -trimpath

0

There are 0 answers