Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultTag ¶ added in v0.300.0
func DefaultTag() reflectkit.TagHandlerProxy[InitDefaultTagValue]
func New ¶
func New[T any]() *T
New will make a new T and call Init function recursively on it if it is implemented.
Example ¶
package main
import (
"go.llib.dev/frameless/pkg/mk"
)
func main() {
v := mk.New[TypeWithInit]()
_ = v
}
type TypeWithInit struct {
V1 string
V2 string
Foo string
Bar int
Baz bool
}
func (v *TypeWithInit) Init() {
v.V1 = "V1i"
v.V2 = "V2i"
}
Example (Nested) ¶
package main
import (
"go.llib.dev/frameless/pkg/mk"
)
func main() {
v := mk.New[NestedType]()
_ = v // initialised
_ = v.Nested // initialised
}
type TypeWithInit struct {
V1 string
V2 string
Foo string
Bar int
Baz bool
}
func (v *TypeWithInit) Init() {
v.V1 = "V1i"
v.V2 = "V2i"
}
type NestedType struct {
V1 string
Nested TypeWithInit
}
func (nt *NestedType) Init() {
nt.V1 = "NT:" + nt.Nested.V1
}
Types ¶
type InitDefaultTagValue ¶ added in v0.300.0
Click to show internal directories.
Click to hide internal directories.