We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package controllers import ( "fmt" "github.com/creasty/defaults" ) func main() { foo := &Parent{} if err := defaults.Set(foo); err != nil { fmt.Println(err) } fmt.Print(foo) } type Child struct { Name string Age int `default:"33"` } type Parent struct { children []Child }
output: &{[]}
The text was updated successfully, but these errors were encountered:
default for slice is nil, that is right
Sorry, something went wrong.
// Doesn't even work with: type Parent struct { children []Child `default:"[]"` } // or this: type Parent struct { children []Child `default:"[{}]"` }
default
No branches or pull requests
output: &{[]}
The text was updated successfully, but these errors were encountered: