Skip to content

Instantly share code, notes, and snippets.

@178inaba
Created December 31, 2020 17:57
Show Gist options
  • Save 178inaba/b30efdbdb663f966578610a5085372c1 to your computer and use it in GitHub Desktop.
Save 178inaba/b30efdbdb663f966578610a5085372c1 to your computer and use it in GitHub Desktop.
Append empty slice in struct.
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