CLI reference
mkunion is a tool dependency in go.mod, so every command runs through go tool:
mkunion watch
Generates union types and shapes for all packages under the given paths, runs go generate ./..., and keeps watching for changes:
-g,--generate-only- generate once and exit (CI, scripts)-G,--dont-run-go-generate- skip the automaticgo generate ./...step--type-registry- generatetypes_reg_gen.gotype registries (default:true)-v,--verbose- debug-level logging
mkunion
Generates code for specific files instead of whole packages:
-i,--input-go-file- Go file(s) to generate code for; falls back to$GOFILE, which makes it usable in//go:generatedirectives-n,--name- union name(s) to generate--type-registry- generatetypes_reg_gen.gotype registry (default:true)-v,--verbose- debug-level logging
mkunion shape-export
Exports Go types as TypeScript definitions for end-to-end type safety:
--lang,--language- output language (default:typescript)-o,--output-dir- directory to write exported types to-i,--input-go-file- Go file(s) to export; falls back to$GOFILE-v,--verbose- debug-level logging
mkunion clean
Removes all mkunion-generated files, giving you a clean slate before regeneration:
go tool mkunion clean -n ./... # preview what would be removed
go tool mkunion clean ./... # remove for real
-n,--dry-run- list files that would be removed, without removing them-v,--verbose- debug-level logging
A file is removed only when its name matches a generated pattern (*_union_gen.go, *_shape_gen.go, *_serde_gen.go, *_match_gen.go, types_reg_gen.go) and its first line is the mkunion header (// Code generated by mkunion. DO NOT EDIT.). Hand-written files and files from other generators (e.g. moq mocks) are left untouched.