gen

package
v3.1.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateEnums

func GenerateEnums(cfg EnumConfig) error

GenerateEnums generates Go source files for all enums in the config.

func SnakeCase

func SnakeCase(s string) string

SnakeCase converts CamelCase to snake_case.

UserStatus  → user_status
Lang        → lang
HTTPHandler → http_handler

func ToFixed

func ToFixed(s string) string

ToFixed replaces hyphens with underscores for use in Go identifiers.

zh-CN → zh_CN

Types

type Enum

type Enum struct {
	Name      string   // Type name, e.g. "UserStatus"
	Values    []string // Enum values, e.g. ["none", "active", "disabled"]
	Sensitive bool     // If true, UnmarshalJSON is case-sensitive (no ToLower)
}

Enum defines a single enum type configuration.

type EnumConfig

type EnumConfig struct {
	Package string // Target package name, e.g. "constants"
	Output  string // Output directory, defaults to "."
	Enums   []Enum // List of enums to generate
}

EnumConfig is the top-level configuration for enum generation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL