Skip to content

Migration: pkg/browsergo/browser

The safe URL-opening helper has been extracted out of go-tool-base into the standalone module gitlab.com/phpboyscout/go/browser (v0.1.0). It is framework-free (cli/browser + cockroachdb/errors only), so any project can adopt it without pulling in the framework.

What changed

  • The package gitlab.com/phpboyscout/go-tool-base/pkg/browser no longer exists. It now lives at gitlab.com/phpboyscout/go/browser.
  • The public API is identical. The package name is still browser; OpenURL, WithOpener, AllowedSchemes, MaxURLLength, the Opener/Option types, and the ErrInvalidURL/ErrDisallowedScheme sentinels are unchanged.
  • No GTB adapter and no compatibility shim — a clean pre-1.0 import-path change.

How to migrate

-import "gitlab.com/phpboyscout/go-tool-base/pkg/browser"
+import "gitlab.com/phpboyscout/go/browser"
go get gitlab.com/phpboyscout/go/[email protected]
go mod tidy

A repository-wide substitution is sufficient (package name and symbols unchanged):

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

Notes

  • go-tool-base itself now consumes go/browser directly; all URL-opening (the telemetry deletion mailto: flow, GitHub device-login, docs-server launch) routes through browser.OpenURL. Tools built on GTB must do the same rather than calling the OS opener directly.
  • Full threat model and guidance: browser.go.phpboyscout.uk; API reference on pkg.go.dev.