| title | Code Conventions — Go Style | ||||||
|---|---|---|---|---|---|---|---|
| category | code-conventions | ||||||
| tags |
|
||||||
| confidence | high | ||||||
| source | internal/, cmd/, Makefile, .golangci.yml | ||||||
| updated | 2026-07-22 |
Commands are defined with cobra. New commands are registered in manager.InitCommands() and executed via manager.Execute().
Viper is used for config loading. Configuration is loaded once at startup; the global config.Default is the singleton accessor. Never parse the YAML config manually.
sirupsen/logrus is used. Log level is set from config. Use structured fields: log.WithFields(log.Fields{...}).Error(msg).
Composite errors are wrapped with validation.ErrComposite from assets-go-libs. Use service.UnwrapComposite(err) to flatten them for logging. Never swallow errors in validators — append to ErrComposite.
golangci-lint v1.50.1 is used (.golangci.yml). Run via make lint. All checks must pass before merging.
Unit tests via go test -race -cover. Run with make test. Coverage report written to coverage.txt.
go build -o bin/assets ./cmd — outputs a single binary. All commands (check, fix, update-auto, etc.) are subcommands of this binary.
Key deps: trustwallet/assets-go-libs (file, path, validation), trustwallet/go-primitives (coin, asset, path types). Both are Trust Wallet-maintained public repos — updates must coordinate with those repos.