Documentation ¶
Overview ¶
There are two ways to provide the Go executable hash to "appbom":
1. "go generate" and "embed" 2. "-ldflags"
Using "go generate" to hash the Go binary:
go generate ./... go generate github.com/slimtoolkit/slim/pkg/appbom
With "go generate" you also need to use embedding (enabled by default). If you can't use "embed" you can disable it with the "appbom_noembed" tag:
go build -tags appbom_noembed
If you disable embedding then you'll need to pass the Go executable hash using "-ldflags":
Mac:
go build -ldflags "-X github.com/slimtoolkit/slim/pkg/appbom.GoBinHash=sha256:$(shasum -a 256 $(go env GOROOT)/bin/go | head -c 64)"
Linux:
go build -ldflags "-X github.com/slimtoolkit/slim/pkg/appbom.GoBinHash=sha256:$(sha256sum $(go env GOROOT)/bin/go | head -c 64)"
You can use "-ldflags" instead of go generate/embed if that approach works better for you.
Index ¶
Constants ¶
const ( SettingBuildMode = "-buildmode" // the buildmode flag used SettingCompiler = "-compiler" // the compiler toolchain flag used SettingTags = "-tags" SettingTrimPath = "-trimpath" SettingLdFlags = "-ldflags" SettingMod = "-mod" SettingEnvVarCgoEnabled = "CGO_ENABLED" // the effective CGO_ENABLED environment variable SettingEnvVarCgoCFlags = "CGO_CFLAGS" // the effective CGO_CFLAGS environment variable SettingEnvVarCgoCppFlags = "CGO_CPPFLAGS" // the effective CGO_CPPFLAGS environment variable SettingEnvVarCgoCxxFlags = "CGO_CXXFLAGS" // the effective CGO_CXXFLAGS environment variable SettingEnvVarCgoLdFlags = "CGO_LDFLAGS" // the effective CGO_LDFLAGS environment variable SettingEnvVarGoOs = "GOOS" // the operating system target SettingEnvVarGoArch = "GOARCH" // the architecture target // the architecture feature level for GOARCH SettingEnvVarGoAmd64 = "GOAMD64" SettingEnvVarGoArm64 = "GOARM64" SettingEnvVarGoArm = "GOARM" SettingEnvVarGo386 = "GO386" SettingEnvVarGoPpc64 = "GOPPC64" SettingEnvVarGoMips = "GOMIPS" SettingEnvVarGoMips64 = "GOMIPS64" SettingEnvVarGoWasm = "GOWASM" SettingVcsType = "vcs" // the version control system for the source tree where the build ran SettingVcsRevision = "vcs.revision" // the revision identifier for the current commit or checkout SettingVcsTime = "vcs.time" // the modification time associated with vcs.revision, in RFC3339 format SettingVcsModified = "vcs.modified" // true or false indicating whether the source tree had local modifications )
Known Settings key names
const ( PNBuildMode = ParamName(SettingBuildMode) PNCompiler = ParamName(SettingCompiler) PNTags = ParamName(SettingTags) PNTrimPath = ParamName(SettingTrimPath) PNLdFlags = ParamName(SettingLdFlags) PNMod = ParamName(SettingMod) PNCgoEnabled = ParamName(SettingEnvVarCgoEnabled) PNCgoCFlags = ParamName(SettingEnvVarCgoCFlags) PNCgoCppFlags = ParamName(SettingEnvVarCgoCppFlags) PNCgoCxxFlags = ParamName(SettingEnvVarCgoCxxFlags) PNCgoLdFlags = ParamName(SettingEnvVarCgoLdFlags) PNGoOs = ParamName(SettingEnvVarGoOs) PNGoArch = ParamName(SettingEnvVarGoArch) PNGoAmd64 = ParamName(SettingEnvVarGoAmd64) PNGoArm64 = ParamName(SettingEnvVarGoArm64) PNGoArm = ParamName(SettingEnvVarGoArm) PNGo386 = ParamName(SettingEnvVarGo386) PNGoPpc64 = ParamName(SettingEnvVarGoPpc64) PNGoMips = ParamName(SettingEnvVarGoMips) PNGoMips64 = ParamName(SettingEnvVarGoMips64) PNGoWasm = ParamName(SettingEnvVarGoWasm) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildParams ¶
type BuildParams struct { BuildMode *ParamInfo `json:"build_mode,omitempty"` Compiler *ParamInfo `json:"compiler,omitempty"` CgoEnabled *ParamInfo `json:"cgo_enabled,omitempty"` CgoCFlags *ParamInfo `json:"cgo_cflags,omitempty"` CgoCppFlags *ParamInfo `json:"cgo_cppflags,omitempty"` CgoCxxFlags *ParamInfo `json:"cgo_cxxflags,omitempty"` CgoLdFlags *ParamInfo `json:"cgo_ldflags,omitempty"` Os *ParamInfo `json:"os,omitempty"` Arch *ParamInfo `json:"arch,omitempty"` ArchFeature *ParamInfo `json:"arch_feature,omitempty"` }
type Info ¶
type Info struct { BuilderHash string `json:"builder_hash,omitempty"` Runtime string `json:"runtime"` Entrypoint MainPackageInfo `json:"entrypoint"` BuildParams BuildParams `json:"build_params"` OtherParams map[string]string `json:"other_params,omitempty"` SourceControl *SourceControlInfo `json:"source_control,omitempty"` Includes []*PackageInfo `json:"includes,omitempty"` }