Skip to content

Commit

Permalink
Merge pull request #3 from luizvnasc/enhancement/json_example
Browse files Browse the repository at this point in the history
created a json example
  • Loading branch information
luizvnasc authored Dec 15, 2019
2 parents 8918e02 + 54c4575 commit 7042617
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/json/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": "1.0.0",
"desc": "An example using json",
"redis": {
"host": "127.0.0.1",
"port": 6379
}
}
23 changes: 23 additions & 0 deletions examples/json/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"fmt"

"github.com/luizvnasc/gonfig"
)

//Config struct to store the app configuration
type Config struct {
Version string `json:"version"`
Description string `json:"desc"`
Redis struct {
Host string `json:"host"`
Port uint `json:"port"`
} `json:"redis"`
}

func main() {
var config Config
gonfig.Load("config.json", &config)
fmt.Printf("%v", config)
}

0 comments on commit 7042617

Please sign in to comment.