labels

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: BSD-3-Clause Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FriendlyMapLabel

func FriendlyMapLabel(v reflect.Value) string

FriendlyMapLabel returns a user-friendly label for the given map value.

func FriendlySliceLabel

func FriendlySliceLabel(v reflect.Value) string

FriendlySliceLabel returns a user-friendly label for the given slice value.

func FriendlyStructLabel

func FriendlyStructLabel(v reflect.Value) string

FriendlyStructLabel returns a user-friendly label for the given struct value.

func FriendlyTypeName

func FriendlyTypeName(typ reflect.Type) string

FriendlyTypeName returns a user-friendly version of the name of the given type. It transforms it into sentence case, excludes the package, and converts various builtin types into more friendly forms (eg: "int" to "Number").

func ToLabel

func ToLabel(v any) string

ToLabel returns the GUI-appropriate label for an item, using the Labeler interface if it is defined, and falling back on reflectx.ToString converter otherwise.

func ToLabeler

func ToLabeler(v any) (string, bool)

ToLabeler returns the Labeler label, true if it was defined, else "", false

Types

type Labeler

type Labeler interface {

	// Label returns a GUI-appropriate label for item
	Label() string
}

Labeler interface provides a GUI-appropriate label for an item, via a Label string method. See ToLabel and ToLabeler.

type SliceLabeler

type SliceLabeler interface {

	// ElemLabel returns a GUI-appropriate label for slice element at given index.
	ElemLabel(idx int) string
}

SliceLabeler interface provides a GUI-appropriate label for a slice item, given an index into the slice.

Jump to

Keyboard shortcuts

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