18
我意識到Go沒有類,而是推動了結構的思想。結構的初始化函數
結構體是否有任何類型的初始化函數可以類似於類的__construct()函數調用?
實施例:
type Console struct {
X int
Y int
}
func (c *Console) init() {
c.X = "5"
}
// Here I want my init function to run
var console Console
// or here if I used
var console Console = new(Console)