Posted on 9th September 2024|600 views
How can I set the default values to Golang structs?
Posted on 9th September 2024| views
You can write a separate constructor function.
type anything struct{
text string
Defaulttext string
}
func Newanything(text string) anything{
anything := anything{}
anything.text = text
anything.Defaulttext = “default text”
return anything
}