Migration: pkg/browser → go/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/browserno longer exists. It now lives atgitlab.com/phpboyscout/go/browser. - The public API is identical. The package name is still
browser;OpenURL,WithOpener,AllowedSchemes,MaxURLLength, theOpener/Optiontypes, and theErrInvalidURL/ErrDisallowedSchemesentinels 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/browserdirectly; all URL-opening (the telemetry deletionmailto:flow, GitHub device-login, docs-server launch) routes throughbrowser.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.