Documentation
¶
Index ¶
- Variables
- func ExtractPrefix(name string) string
- func FileHeader(commentPrefix, langLabel string) string
- func GenerateLicense(logger *slog.Logger, outputDir string) error
- func GenerateReadme(logger *slog.Logger, outputDir string) error
- func GetVersion() (string, error)
- func NormalizeGoType(goType string) (base string, isSlice bool, isPointer bool)
- func ParseVersion(version string) (major, minor, patch int)
- func SanitizeLeadingDigit(name string) string
- func SortedStringKeys(m map[string]any) []string
- func ToCamelCase(s string) string
- func ToPascalCase(s string) string
- func ToSnakeCase(s string) string
- func TrimPrefixAndSanitize(full string) (prefix, member string)
Constants ¶
This section is empty.
Variables ¶
var Version = ""
Version is set via ldflags at build time: -ldflags "-X viiper/internal/codegen/common.Version=x.y.z"
Functions ¶
func ExtractPrefix ¶
ExtractPrefix extracts the common prefix from a constant name for enum grouping Examples: "Key_A" -> "Key_", "ModifierShift" -> "Modifier", "LED1" -> "LED"
func FileHeader ¶
FileHeader returns a standard two-line autogenerated header for generated files. commentPrefix is the line comment token for the target language (e.g., "//"). langLabel is a human readable language label to include (e.g., "TypeScript", "C#").
func GetVersion ¶
GetVersion returns the version string that was set at build time via ldflags. Returns "0.0.1-dev" if Version is empty (development builds only). For production releases, Version MUST be set via: go build -ldflags "-X viiper/internal/codegen/common.Version=x.y.z"
func NormalizeGoType ¶
NormalizeGoType strips pointer and slice prefixes from a Go type string and reports whether the original type was a slice or pointer. Examples: "*MyType" -> ("MyType", false, true), "[]uint8" -> ("uint8", true, false)
func ParseVersion ¶
ParseVersion extracts major, minor, patch from version string like "1.2.3" or "1.2.3-dirty" Returns major, minor, patch as integers.
func SanitizeLeadingDigit ¶
SanitizeLeadingDigit prefixes names that start with a digit with "Num" to keep identifiers valid in target languages.
func SortedStringKeys ¶
SortedStringKeys returns the sorted keys of a map[string]any.
func ToCamelCase ¶
func ToPascalCase ¶
func ToSnakeCase ¶
func TrimPrefixAndSanitize ¶
TrimPrefixAndSanitize splits a constant full name into its enum prefix and member, and sanitizes the member (e.g., leading digits -> "Num..."). Example: "Key_1" => ("Key_", "Num1"), "ModifierShift" => ("Modifier", "Shift").
Types ¶
This section is empty.