Skip to content

Instantly share code, notes, and snippets.

@xcoulon
Last active November 19, 2017 15:28
Show Gist options
  • Save xcoulon/7d0d61743b97b21d8c157dd536c13530 to your computer and use it in GitHub Desktop.
Save xcoulon/7d0d61743b97b21d8c157dd536c13530 to your computer and use it in GitHub Desktop.
Nested structs in Golang (resource for the story on Medium)
config := Config{
Server: struct {
Host string `json:"host"`
Port string `json:"port"`
}{
Host: "localhost",
Port: "8080",
},
Postgres: struct {
Host string `json:"host"`
User string `json:"user"`
Password string `json:"password"`
DB string `json:"db"`
}{
Host: "localhost",
User: "db_user",
Password: "supersecret",
DB: "my_db",
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment