generator

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(config Config) ([]byte, error)

Generate creates Go source code from the error definitions.

Types

type Config

type Config struct {
	Package string
	Errors  []ErrorDefinition
}

Config holds the configuration for code generation.

type ErrorDefinition

type ErrorDefinition struct {
	Code    uint64 `json:"code" yaml:"code"`
	Key     string `json:"key" yaml:"key"`
	Message string `json:"message" yaml:"message"`
	HTTP    int    `json:"http" yaml:"http"`
	GRPC    int    `json:"grpc" yaml:"grpc"`
	Desc    string `json:"desc" yaml:"desc"`
}

ErrorDefinition represents a single error definition from the input file.

func ParseInput

func ParseInput(reader io.Reader, filename string) ([]ErrorDefinition, error)

ParseInput reads and parses the input file (YAML or JSON) into error definitions.

Jump to

Keyboard shortcuts

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