go-defaults
go-defaults copied to clipboard
Go structures with default values using tags
In v1.1.0, setting `default: "1000000000"` for time.Duration was equivalent to "1s". but, In v1.2.0, setting `default: "1000000000"` for time.Duration is equivalent to "0". Therefore, even if time.Duration is set to...
In v1.1.0, setting default: "1000000000" for time.Duration was equivalent to "1s". but, In v1.2.0, setting default: "1000000000" for time.Duration is equivalent to "0". I have made the fixes in [this...
Example: ```go type Widget struct { B []bytes } defaults.SetDefaults(&Widget{}) ``` The `B` field starts out nil, but will be set to an empty byte slice, even though that field...
When this package is used in parallel (for example for web requests), the initialization of filler presents a race condition. This was detected by using go's race detector. The fix...
See #15
```go type Defaults interface { Defaults(raw string) (interface{}, error) } ``` example --- ```go type Duration time.Duration func (d *Duration) Defaults(raw string) (interface{}, error) { return time.ParseDuration(raw) } ```
I'd love it if this library also handled type pointers, so something like this: ```go type test struct { Name *string `default:"test"` } ``` now obviously a string pointer isn't...
How can I get the default value of one field derived from other fields of same struct, For example: type User struct { Name string FirstName string LastName string }...
``` package main import ( "fmt" "gopkg.in/mcuadros/go-defaults.v1" ) func main() { foo := &Parent{} defaults.SetDefaults(foo) fmt.Print(foo) } type Child struct { Name string Age int `default:"10"` } type Parent struct...
Issue #14