Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spell mixins for Go toolchain options
To support common use cases for debugging and production optimization, some spell mixins [1] have been implemented in the "golang" [2] package: - 🆂 `MixinImproveDebugging` - A `struct` type that adds 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. - 🆂 `MixinImproveEscapeAnalysis` - A `struct` type that adds linker flags to improve the escape analysis of binary artifacts. 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. - 🆂 `MixinStripDebugMetadata` - A `struct` type that adds 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. 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. - 🆂 `MixinInjectBuildTimeVariableValues` - A `struct` type that injects build-time values through the `-X` linker flags to populate e.g. application metadata variables. It store a `map[string]string` 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. A field of type `*project.GoModuleID` [3] stores partial information about the target Go module to inject the key/value pairs from the data map into. [1]: https://pkg.go.dev/github.com/svengreb/wand/pkg/spell#Mixin [2]: https://pkg.go.dev/github.com/svengreb/wand/pkg/spell/golang [3]: https://pkg.go.dev/github.com/svengreb/wand/pkg/project#GoModuleID GH-37
- Loading branch information