Installation
Requirements
Section titled “Requirements”- Go 1.26 or later
GOEXPERIMENT=jsonv2enabled (this library usesencoding/json/v2)- An active Go module (
go.mod)
Install
Section titled “Install”Run this in your project directory:
GOEXPERIMENT=jsonv2 go get github.com/larsartmann/go-branded-idEnable GOEXPERIMENT=jsonv2
Section titled “Enable GOEXPERIMENT=jsonv2”This library imports encoding/json/v2, which requires the jsonv2 experiment flag. Set it for all Go commands:
export GOEXPERIMENT=jsonv2For a permanent setup, add it to your shell profile (~/.bashrc, ~/.zshrc) or to go env:
go env -w GOEXPERIMENT=jsonv2Quick Usage
Section titled “Quick Usage”package main
import ( "fmt"
"github.com/larsartmann/go-branded-id")
type UserBrand struct{}
type UserID = id.ID[UserBrand, string]
func main() { userID := id.NewID[UserBrand]("user-123") fmt.Println(userID.Get()) // user-123}Verify Installation
Section titled “Verify Installation”GOEXPERIMENT=jsonv2 go list -m github.com/larsartmann/go-branded-idNext Steps
Section titled “Next Steps”- Follow the Quick Start for complete examples
- Learn about Named Brands for debug-visible IDs
- See Serialization for JSON, SQL, and more