// define structure typetype my_struct struct { a int b rune}// declare slice of my_structvar a []my_struct// declare and initialise struct with one element b := make([]my_struct, 1)// create structure and save itb[0] = my_struct{1, 'a'}// append a new oneb = append(b, my_struct{2, 'b'})您絕對必須閱讀https://golang.org/doc/effective_go.html,尤其是關(guān)于結(jié)構(gòu)和切片的內(nèi)容,如果您想了解更多的話。
- 2 回答
- 0 關(guān)注
- 203 瀏覽
添加回答
舉報
0/150
提交
取消