Created
July 25, 2014 15:30
-
-
Save pedromg/bd49e4ac4d2f3360e402 to your computer and use it in GitHub Desktop.
This file contains 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 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