// GolangBuildCommand This step will execute a golang build.
funcGolangBuildCommand()*cobra.Command{
constSTEP_NAME="golangBuild"
metadata:=golangBuildMetadata()
varstepConfiggolangBuildOptions
varstartTimetime.Time
varlogCollector*log.CollectorHook
varsplunkClient*splunk.Splunk
telemetryClient:=&telemetry.Telemetry{}
varcreateGolangBuildCmd=&cobra.Command{
Use:STEP_NAME,
Short:"This step will execute a golang build.",
Long:`Thisstepwillbuildagolangproject.
Itwillalsoexecutegolang-basedtestsusing[gotestsum](https://github.com/gotestyourself/gotestsum) and with that allows for reporting test results and test coverage.
cmd.Flags().StringSliceVar(&stepConfig.BuildFlags,"buildFlags",[]string{},"Defines list of build flags to be used.")
cmd.Flags().BoolVar(&stepConfig.CgoEnabled,"cgoEnabled",false,"If active: enables the creation of Go packages that call C code.")
cmd.Flags().StringVar(&stepConfig.CoverageFormat,"coverageFormat",`html`,"Defines the format of the coverage repository.")
cmd.Flags().BoolVar(&stepConfig.CreateBOM,"createBOM",false,"Creates the bill of materials (BOM) using CycloneDX plugin.")
cmd.Flags().StringSliceVar(&stepConfig.CustomTLSCertificateLinks,"customTlsCertificateLinks",[]string{},"List of download links to custom TLS certificates. This is required to ensure trusted connections to instances with repositories (like nexus) when publish flag is set to true.")
cmd.Flags().BoolVar(&stepConfig.ExcludeGeneratedFromCoverage,"excludeGeneratedFromCoverage",true,"Defines if generated files should be excluded, according to [https://golang.org/s/generatedcode](https://golang.org/s/generatedcode).")
cmd.Flags().StringVar(&stepConfig.LdflagsTemplate,"ldflagsTemplate",os.Getenv("PIPER_ldflagsTemplate"),"Defines the content of -ldflags option in a golang template format.")
cmd.Flags().StringVar(&stepConfig.Output,"output",os.Getenv("PIPER_output"),"Defines the build result or output directory as per `go build` documentation.")
cmd.Flags().StringSliceVar(&stepConfig.Packages,"packages",[]string{},"List of packages to be build as per `go build` documentation.")
cmd.Flags().BoolVar(&stepConfig.Publish,"publish",false,"Configures the build to publish artifacts to a repository.")
cmd.Flags().BoolVar(&stepConfig.ReportCoverage,"reportCoverage",true,"Defines if a coverage report should be created.")
cmd.Flags().BoolVar(&stepConfig.RunTests,"runTests",true,"Activates execution of tests using [gotestsum](https://github.com/gotestyourself/gotestsum).")
cmd.Flags().BoolVar(&stepConfig.RunIntegrationTests,"runIntegrationTests",false,"Activates execution of a second test run using tag `integration`.")
cmd.Flags().StringSliceVar(&stepConfig.TargetArchitectures,"targetArchitectures",[]string{`linux,amd64`},"Defines the target architectures for which the build should run using OS and architecture separated by a comma.")
cmd.Flags().StringSliceVar(&stepConfig.TestOptions,"testOptions",[]string{},"Options to pass to test as per `go test` documentation (comprises e.g. flags, packages).")
cmd.Flags().StringVar(&stepConfig.TestResultFormat,"testResultFormat",`junit`,"Defines the output format of the test results.")
cmd.Flags().StringVar(&stepConfig.PrivateModules,"privateModules",os.Getenv("PIPER_privateModules"),"Tells go which modules shall be considered to be private (by setting [GOPRIVATE](https://pkg.go.dev/cmd/go#hdr-Configuration_for_downloading_non_public_code)).")
cmd.Flags().StringVar(&stepConfig.PrivateModulesGitToken,"privateModulesGitToken",os.Getenv("PIPER_privateModulesGitToken"),"GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line.")
{Name:"golangPrivateModulesGitTokenCredentialsId",Description:"Jenkins 'Username with password' credentials ID containing username/password for http access to your git repos where your go private modules are stored.",Type:"jenkins"},