enumx

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Example
package main

import (
	"context"
	"os"
	"path/filepath"

	"github.com/xoctopus/x/misc/must"

	"github.com/xoctopus/genx/pkg/genx"
)

func main() {
	cwd := must.NoErrorV(os.Getwd())

	entry := filepath.Join(cwd, "..", "testdata", "enumx")

	ctx := genx.NewContext(&genx.Args{
		Entrypoint: []string{entry},
	})

	if err := ctx.Execute(context.Background(), genx.Get()...); err != nil {
		panic(err)
	}

}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Span added in v0.1.8

func Span() func() time.Duration

Types

type Enum

type Enum struct {
	// contains filtered or unexported fields
}

func (*Enum) Attr

func (e *Enum) Attr(ctx context.Context, attr, option string) s.Snippet

func (*Enum) Attrs

func (e *Enum) Attrs() []string

func (*Enum) IsValid

func (e *Enum) IsValid() bool

func (*Enum) StringToValueCases

func (e *Enum) StringToValueCases(ctx context.Context) s.Snippet

StringToValueCases generates code snippet cases from string to const value

func (*Enum) ValueToStringCases

func (e *Enum) ValueToStringCases(ctx context.Context) s.Snippet

ValueToStringCases generates code snippet cases from enum value to string

func (*Enum) ValueToTextCases

func (e *Enum) ValueToTextCases(ctx context.Context) s.Snippet

ValueToTextCases generates code snippet cases from enum value to text

func (*Enum) Values

func (e *Enum) Values(ctx context.Context) s.Snippet

Values generates code snippet of const value list

type Enums

type Enums struct {
	// contains filtered or unexported fields
}

func NewEnums

func NewEnums(g genx.Context) *Enums

func (*Enums) Resolve

func (es *Enums) Resolve(t types.Type) (*Enum, bool)

Jump to

Keyboard shortcuts

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