mirror of
https://github.com/hanzo-fi/go-libs.git
synced 2026-10-30 20:53:44 +00:00
* refactor: move all packages under pkg/ for v5 Move all 13 top-level Go packages into pkg/ for a cleaner repository structure. All internal import paths updated from github.com/formancehq/go-libs/v5/<pkg> to github.com/formancehq/go-libs/v5/pkg/<pkg>. Also includes cleanup: - Fix .golangci.yml stale v4 CircuitBreaker path - Replace deprecated str.Contains with stdlib slices.Contains - Update TODO(v4) markers to TODO - Delete stale coverage.txt - Fix pgtesting timeout not being propagated to docker pool - Update docs/ARCHITECTURE.md to reflect new structure Co-Authored-By: Claude Opus 4.6 <[email protected]> * chore: remove compatibility aliases, unused params, and stub files - Remove unused type aliases (Authenticator, KeySet) from authnfx - Remove unused `debug` parameter from S3ModuleFromFlags - Delete comment-only stub files in messaging/publish/circuit/ Co-Authored-By: Claude Opus 4.6 <[email protected]> * chore: rename cli.go to flags.go for consistency Standardize naming across all packages: cli.go -> flags.go since these files all serve the same purpose (flag definitions). Co-Authored-By: Claude Opus 4.6 <[email protected]> * chore: rename * chore(deps): update all dependencies Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: resolve package name mismatches in generated mocks Generated mock files had stale package names from before the pkg/ move, causing import cycles and build failures with --build-tags it. Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
1.7 KiB
1.7 KiB
Contributing
Before you start
Read ARCHITECTURE.md to understand the project structure and rules.
Dependency rules checklist
Before submitting a PR, verify:
- Your package does not import
go.uber.org/fx(unless it lives underfx/) - Your package only imports from its own layer or lower layers
- Leaf packages (
types/,query/,errors/) have no internalgo-libsimports - New FX modules live under
fx/<domain>fx/ - No package name ends with
utils
Package structure conventions
Each package should expose:
// Constructor — pure, no side effects beyond allocation
func New(cfg Config) (*Thing, error)
// Config struct with sensible defaults
type Config struct { ... }
// If CLI flags are needed:
func AddFlags(flags *pflag.FlagSet) { ... }
FX module conventions
FX modules under fx/ follow this pattern:
package somefx
func Module() fx.Option {
return fx.Module("name",
fx.Provide(pure.New),
fx.Invoke(func(lc fx.Lifecycle, t *pure.Thing) {
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error { return t.Start(ctx) },
OnStop: func(ctx context.Context) error { return t.Stop(ctx) },
})
}),
)
}
Key rules:
- Module name matches the package concept (e.g.,
"traces","httpserver") - Use
fx.Providefor constructors,fx.Invokefor lifecycle hooks - Never put business logic in FX modules
Testing
- Unit tests go alongside the code (
foo_test.gonext tofoo.go) - Integration tests that need containers use helpers from
testing/platform/ - Test service scaffolding is in
testing/testservice/