I'm attempting to do this segment of the documentation in golang example, unfortunately the syntax is no longer recognised on new versions of the golang sdk. I tried fixing the code so that I could write a merge request to fix the documentation but I was not able to make it work, here is my code ifx attemp:
import (
"context"
"fmt"
"math"
"math/rand"
)
type Example struct{}
// Build and publish a project using a Wolfi container
func (m *Example) BuildAndPublish(ctx context.Context, buildSrc *Directory, buildArgs []string) (string, error) {
var zippedBuildArgs []BuildArg
for i := 0; i < len(buildArgs); i+=2{
zippedBuildArgs = append(zippedBuildArgs, BuildArg{Name: buildArgs[i], Value: buildArgs[i]})
}
ctr := dag.Wolfi().Container()
return ctr.
Build(buildSrc, ContainerBuildOpts{BuildArgs: zippedBuildArgs}).
Publish(ctx, fmt.Sprintf("ttl.sh/my-hello-container-%.0f", math.Floor(rand.Float64()*10000000))) //#nosec
}```
What is the correct translation of the example using the new syntax?