Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Find ¶
Find returns the first value of a struct field from the given list of field names with a type matching the default value type. If the name list is empty or contains a star (`*`), the first matching field in order of the struct declaration is returned as fallback. If no matching field is found, the default value is returned.
The `param` object can be a struct, a pointer to a struct, or an arbitrary value matching the default value type. In the last case, the arbitrary value is returned as is.
func Name ¶
Name returns the normalized test case name for the given default name and parameter set. If the default name is empty, the test name is resolved from the parameter set using the `name` field. The resolved value is normalized before being returned. If no test name can be resolved an empty string is returned.
Types ¶
type Builder ¶
type Builder[T any] interface { // Getter is a generic interface that allows you to access unexported fields // of a (pointer) struct by field name. Getter[T] // Finder is a generic interface that allows you to access unexported fields // of a (pointer) struct by field name. Finder[T] // Setter is a generic fluent interface that allows you to modify unexported // fields of a (pointer) struct by field name. Setter[T] }
Builder is a generic, partially fluent interface that allows you to access and modify unexported fields of a (pointer) struct by field name.
func NewAccessor ¶
NewAccessor creates a generic builder/accessor for a given target struct. The builder allows you to access and modify unexported fields of the struct by field name.
If the target is a pointer to a struct (template), the pointer is stored and the instance is modified directly. If the pointer is nil a new instance is created and stored for modification.
If the target is a struct, it cannot be modified directly and a new pointer struct is created to circumvent the access restrictions on private fields. The pointer struct is stored for modification.
func NewBuilder ¶
NewBuilder creates a generic builder for a target struct type. The builder allows you to access and modify unexported fields of the struct by field name.
type Finder ¶
type Finder[T any] interface { // Find returns the first value of a field from the given list of field // names with a type matching the default value type. If the name list is // empty or contains a star (`*`), the first matching field in order of the // struct declaration is returned as fallback. If no matching field is // found, the default value is returned. Find(dflt any, names ...string) any }
Finder is a generic interface that allows you to access unexported fields of a (pointer) struct by field name.
type Getter ¶
type Getter[T any] interface { // Get returns the value of the field with the given name. If the name is // empty, the stored target instance is returned. Get(name string) any }
Getter is a generic interface that allows you to access unexported fields of a (pointer) struct by field name.
type Setter ¶
type Setter[T any] interface { // Set sets the value of the field with the given name. If the name is empty, // and of the same type the stored target instance is replaced by the given // value. Set(name string, value any) Setter[T] // Build returns the created or modified target instance of the builder. Build() T }
Setter is a generic fluent interface that allows you to modify unexported fields of a (pointer) struct by field name.