Documentation
¶
Overview ¶
Package golang provides spell incantations for Go toolchain commands.
Index ¶
- func CompileFormula(opts ...Option) []string
- type MixinImproveDebugging
- type MixinImproveEscapeAnalysis
- type MixinInjectBuildTimeVariableValues
- type MixinStripDebugMetadata
- type Option
- func WithAsmFlags(asmFlags ...string) Option
- func WithEnv(env map[string]string) Option
- func WithFlags(flags ...string) Option
- func WithFlagsPrefixAll(flagsPrefixAll bool) Option
- func WithGcFlags(gcFlags ...string) Option
- func WithLdFlags(ldFlags ...string) Option
- func WithMixins(mixins ...spell.Mixin) Option
- func WithRaceDetector(enableRaceDetector bool) Option
- func WithTags(tags ...string) Option
- func WithTrimmedPath(enableTrimPath bool) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileFormula ¶
CompileFormula compiles the formula for shared Go toolchain command options.
Types ¶
type MixinImproveDebugging ¶
type MixinImproveDebugging struct{}
MixinImproveDebugging is a spell.Mixin for golang.Options to add linker flags to improve the debugging of binary artifacts. This includes the disabling of inlining and all compiler optimizations tp improve the compatibility for debuggers.
Note that this mixin adds the "all" prefix for "-gcflags" parameters to make sure all packages are affected. If you disabled the "all" prefix on purpose you need to handle this conflict on your own, e.g. by creating more than one binary artifact each with different build options.
Run `go help build`, `go tool compile -help` for the documentation of supported flags. See the official Go documentations and other resources for more details:
type MixinImproveEscapeAnalysis ¶
type MixinImproveEscapeAnalysis struct{}
MixinImproveEscapeAnalysis is a spell.Mixin for golang.Options to add linker flags to improve the escape analysis of binary artifacts. Enables 2/4 level for reporting verbosity, higher levels are too noisy and rarely necessary.
Note that this mixin removes the "all" prefix for "-gcflags" parameters to make sure only the target package is affected, otherwise reports for (traverse) dependencies would be included as well. If you enabled the "all" prefix on purpose you need to handle this conflict on your own, e.g. by creating more than one binary artifact each with different build options.
Run `go help build`, `go tool compile -help` for the documentation of supported flags. See the official Go documentations and other resources for more details:
type MixinInjectBuildTimeVariableValues ¶
type MixinInjectBuildTimeVariableValues struct { // Data is the map of key/value pairs to inject to variables at build-time. // The key must be the path to the variable in form of "<IMPORT_PATH>.<VARIABLE_NAME>", // e.g. "pkg/internal/support/app.version". // The value is the actual value that will be assigned to the variable, e.g. the application version. Data map[string]string // GoModuleID is the ID of the target Go module to inject the given key/value pairs into. GoModuleID *project.GoModuleID }
MixinInjectBuildTimeVariableValues is a spell.Mixin for golang.Options to inject build-time values through the `-X` linker flags to populate e.g. application metadata variables.
See `go help build`, `go tool compile -help` and the `go` command documentations for more details:
type MixinStripDebugMetadata ¶
type MixinStripDebugMetadata struct{}
MixinStripDebugMetadata is a spell.Mixin for golang.Options to add linker flags to strip debug information from binary artifacts. This includes DWARF tables needed for debuggers, but keeps annotations needed for stack traces so panics are still readable. It also shrinks the file size and memory overhead as well as reducing the chance for possible security related problems due to enabled development features or debug information leaks.
Run `go tool compile -help`, `go doc cmd/link` for the documentation of supported flags.
See the official Go documentations and other resources for more details:
- https://golang.org/cmd/link
- https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies
- https://rakyll.org/go-tool-flags
- https://github.com/golang/go/wiki/CompilerOptimizations
- https://blog.filippo.io/shrink-your-go-binaries-with-this-one-weird-trick
Note that this mixin adds the "all" prefix for "-gcflags" parameters to make sure all packages are affected If you disabled the "all" prefix on purpose you need to handle this conflict on your own, e.g. by creating more than one binary artifact each with different build options.
See `go help build`, `go tool compile -help` and the `go` command documentations for more details:
- https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies
- https://golang.org/doc/go1.10#build
A subsequent optimization could be the usage of UPX (https://github.com/upx/upx) to compress the binary artifact afterwards.
type Option ¶
type Option func(*Options)
Option is a pencil option.
func WithAsmFlags ¶
WithAsmFlags sets flags to pass on each `go tool asm` invocation.
See `go help buildmode`, `go help build` and the `go` command documentations for more details:
func WithFlags ¶
WithFlags sets additional Go toolchain command flags.
See `go help build` and the `go` command documentations for more details:
func WithFlagsPrefixAll ¶
WithFlagsPrefixAll indicates whether the values of `-asmflags` and `-gcflags` should be prefixed with the `all=` pattern in order to apply to all packages. As of Go 1.10 (https://golang.org/doc/go1.10#build), the value specified to `-asmflags` and `-gcflags` are only applied to the current package, therefore the `all=` pattern is used to apply the flag to all packages.
See `go help build` and the `go` command documentations for more details:
func WithGcFlags ¶
WithGcFlags sets flags to pass on each `go tool compile` invocation.
See `go help buildmode`, `go help build` and the `go` command documentations for more details:
func WithLdFlags ¶
WithLdFlags sets flags to pass on each `go tool link` invocation.
See `go help buildmode`, `go help build` and the `go` command documentations for more details:
func WithMixins ¶
WithMixins sets spell mixins that can be applied by option consumers.
func WithRaceDetector ¶
WithRaceDetector indicates whether the race detector should be enabled.
See `go help build` and the `go` command documentations for more details:
func WithTags ¶
WithTags sets Go toolchain tags.
See `go help build` and the `go` command documentations for more details:
func WithTrimmedPath ¶
WithTrimmedPath indicates whether all file system paths should be removed from the resulting executable. This is done by adding compiler and linker flags to remove the absolute path to the project root directory from binary artifacts.
See `go help build` and the `go` command documentations for more details:
type Options ¶
type Options struct { // AsmFlags are the arguments for the `-asmflags` flag that are passed to each `go tool asm` invocation. // // See `go help buildmode`, `go help build` and the `go` command documentations for more details: // - https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies AsmFlags []string // EnableRaceDetector indicates whether the race detector should be enabled. // // See `go help build` and the `go` command documentations for more details: // - https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies // - https://golang.org/cmd/go/#hdr-Testing_flags EnableRaceDetector bool // EnableTrimPath indicates whether all file system paths should be removed from the resulting executable. // This is done by adding compiler and linker flags to remove the absolute path to the project root directory from // binary artifacts. // // See `go help build` and the `go` command documentations for more details: // - https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies // - https://golang.org/doc/go1.13#go-command EnableTrimPath bool // Env are Go toolchain command specific environment variables. Env map[string]string // Flags are additional flags passed to the `go` command. // // See `go help build` and the `go` command documentations for more details: // - https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies Flags []string // FlagsPrefixAll indicates whether the values of `-asmflags` and `-gcflags` should be prefixed with the `all=` // pattern in order to apply to all packages. // As of Go 1.10 (https://golang.org/doc/go1.10#build), the value specified to `-asmflags` and `-gcflags` are only // applied to the current package, therefore the `all=` pattern is used to apply the flag to all packages. // // See `go help build` and the `go` command documentations for more details: // - https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies // - https://golang.org/doc/go1.10#build FlagsPrefixAll bool // GcFlags are the arguments for the `-gcflags` flag that are passed to each `go tool compile` invocation. // // See `go help buildmode`, `go help build` and the `go` command documentations for more details: // - https://golang.org/cmd/go/#hdr-Build_modes // - https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies GcFlags []string // LdFlags are the arguments for the `-ldflags` flag that are passed to each `go tool link` invocation. // // See `go help buildmode`, `go help build` and the `go` command documentations for more details: // - https://golang.org/cmd/go/#hdr-Build_modes // - https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies LdFlags []string // Tags are the Go tags. // // See `go help build` and the `go` command documentations for more details: // - https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies Tags []string // contains filtered or unexported fields }
Options are shared Go toolchain commands options.
References ¶
- https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies
func NewOptions ¶
NewOptions creates new shared Go toolchain command options.
Directories
¶
Path | Synopsis |
---|---|
Package build provides a spell incantation for the "build" command of the Go toolchain.
|
Package build provides a spell incantation for the "build" command of the Go toolchain. |
Package test provide a spell incantation for the "test" command of the Go toolchain.
|
Package test provide a spell incantation for the "test" command of the Go toolchain. |