xiota

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package xiota provides tools for creating and handling iota-like enumerated constants.

type Month int

const (
	January Month = iota + 1
	February
	March
	// ...and so on
)

var longMonthNames = []string{
	"January", "February", "March",
	// ...and so on
}

// Implement fmt.Stringer interface with just one line
func (m Month) String() string {
	return Format(m, longMonthNames, January, December, January-1)
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format[T Number](value T, names []string, min, max, offset T) string

Formatting formats v into the name.

Example
type A uint
fmt.Println(Format[A](2, []string(nil), 0, 0, 0))
Output:

	%!A(2)

func Parse

func Parse[T Number](tab []string, val string, offset int) (T, error)

Parse

Types

type Number

type Number interface {
	~int8 | ~int16 | ~int | ~int32 | ~int64 | ~uint8 | ~uint16 | ~uint | ~uint32 | ~uint64
}

Jump to

Keyboard shortcuts

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