Skip to content

Migration: pkg/controlsgo/controls

The service-lifecycle supervisor has been extracted out of go-tool-base into the standalone module gitlab.com/phpboyscout/go/controls (v0.1.0). It is framework-free — its only external dependency is cockroachdb/errors and its only logging seam is a nil-safe *slog.Logger, so any project can adopt it without pulling in the framework.

What changed

  • The package gitlab.com/phpboyscout/go-tool-base/pkg/controls no longer exists. It now lives at gitlab.com/phpboyscout/go/controls.
  • The public API is identical. The package name is still controls; all types, interfaces, functional options (NewController, WithStart, WithStop, WithStatus, WithLiveness, WithReadiness, WithRestartPolicy, WithRestartResetInterval, WithLogger, WithShutdownTimeout, WithoutSignals, WithValidError), and behaviours are unchanged.
  • There is no GTB adapter and no compatibility shim — this is a clean pre-1.0 import-path change.

How to migrate

Repoint the import path — nothing else changes:

-import "gitlab.com/phpboyscout/go-tool-base/pkg/controls"
+import "gitlab.com/phpboyscout/go/controls"

Then add the module and tidy:

go get gitlab.com/phpboyscout/go/[email protected]
go mod tidy

Because the package name and every symbol are unchanged, no call-site edits are required beyond the import line. A repository-wide substitution is sufficient:

grep -rl 'go-tool-base/pkg/controls' --include='*.go' . \
  | xargs sed -i 's#gitlab.com/phpboyscout/go-tool-base/pkg/controls#gitlab.com/phpboyscout/go/controls#g'
go mod tidy

Notes

  • go-tool-base itself now consumes go/controls directly; its pkg/http, pkg/grpc, and pkg/gateway servers register as controllable services against the module's Controller.
  • Full documentation for the supervisor lives at controls.go.phpboyscout.uk; the API reference is on pkg.go.dev.
  • Keep the module at a version compatible with your go-tool-base version; both track the same supervisor behaviour post-extraction.