Created
December 31, 2020 17:57
-
-
Save 178inaba/b30efdbdb663f966578610a5085372c1 to your computer and use it in GitHub Desktop.
Append empty slice in struct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type classRoom struct { | |
ids []int | |
} | |
func main() { | |
var cr classRoom | |
for i := 0; i < 100; i++ { | |
cr.ids = append(cr.ids, i+1) | |
} | |
fmt.Println(cr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment