golang - different ways of initializing your struct /class
Different ways of initializing your struct
// Util.go
package main type StringHelper struct { } func (sh StringHelper ) ToUpper() string{ return "TOUPPER"}
Different ways of initializing :
// 1st
var a StringHelper
a.ToUpper()// 2nd b := new(StringHelper) b.ToUpper()// 3rdc := StringHelper{} c.ToUpper()I kinda prefer 3rd way of doing it.
Comments