Skip to content

Instantly share code, notes, and snippets.

@pedromg
Created July 25, 2014 15:30
Show Gist options
  • Save pedromg/bd49e4ac4d2f3360e402 to your computer and use it in GitHub Desktop.
Save pedromg/bd49e4ac4d2f3360e402 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Person struct {
Name string
age int // not Exported
}
func main() {
data := []Person{Person{"Alice", 94}}
// data = append(data, Person{"Bob"}) // Error: too few values in struct initializer
data = append(data, Person{Name:"Bob"}) // Use Named Literals
fmt.Println(data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment