Documentation ¶
Overview ¶
Config helper go package. It provides configuration handling functionality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field[T any] struct { NameDisplay string // Name to show in form etc. Name string // Field name Type string // Field type ValueStr string // Field value as string Value any // Field with real struct value // Field entry is a custom field which can be used in GetFields and // SetValues callbacks Entry T }
Field is a struct that contains metadata and values for a single field of a struct or map[string]any that is passed to the GetFields function. It allows associating additional data with each field through the generic Entry field. The NameDisplay field contains a display name for the field that can be used in UIs.
func (*Field[T]) SetValue ¶ added in v0.0.5
SetValue sets the value of a field in a struct or map.
The function takes in the following parameters:
- p: An interface{} value representing the struct or map.
- field: A pointer to the Field[T] struct, which contains information about the field to be set.
- value: A string representing the value to be set.
The function returns an error if the field cannot be set. The error message provides information about the field name, value, and type.
The function supports setting values for fields of the following types: string, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64.
If the value cannot be converted to the field's type, an error is returned.
If the parameter 'p' is not a pointer to a struct or a map, the function panics.
The function does not modify the 'p' parameter directly, but it modifies the value of the specified field.
The function does not have any return values.
func (*Field[T]) ValidateValue ¶ added in v0.0.5
ValidateValue validates the value of a given field.
The function takes in two parameters: field, a pointer to a Field[T] struct, and value, a string representing the value to be validated. The field struct contains information about the field's type and name. The value parameter is a string that will be converted to the appropriate type based on the field's type.
The function returns an error if the value is not of the expected type.
type Fields ¶
Fields is a slice of Field pointers for the generic type T. It allows operating on a group of fields together.
func GetFields ¶
GetFields generates a list of fields from the given object and calls a function for each detected field.
The function accepts two parameters:
- o: the object from which to extract the fields. It may be a struct or a map[string]any.
- f: the function to be called for each field, which takes a pointer to a Field[T] struct as its parameter. Where T is the type of the Entry fied in the Field struct.
It returns a Fields[T] which is a slice of pointers to Field[T] structs.
func (Fields[T]) SetValues ¶
SetValues iterates over each field in the Fields collection and sets their values based on the provided function.
Parameters:
- p: The target object where the field values will be set.
- f: A function that takes a pointer to a Field and returns a string representing the field value.
type Number ¶
type Number interface { constraints.Integer | constraints.Float }
Number is an interface that combines the Integer and Float interfaces from the constraints package. This allows code to accept numbers of either integer or floating point types through the single Number interface.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
conf
Config helper go package GUI sample application using Fyne widgets to show json config data.
|
Config helper go package GUI sample application using Fyne widgets to show json config data. |
context
The context package example.
|
The context package example. |
fyne
|
|
form
Packages form create fine-go forms widget.
|
Packages form create fine-go forms widget. |