Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //______________________________________________________________________________
- type Config struct {
- BBoltFile string `json:"bbolt_file"`
- SqliteFile string `json:"sqlite_file"`
- BucketPath string `json:"bucket_path"`
- TableName string `json:"table_name"`
- Fields []Corr `json:"fields"`
- }
- //______________________________________________________________________________
- type Corr struct {
- ReadName string `json:"read"`
- WriteName string `json:"write"`
- }
- //______________________________________________________________________________
- // Reads config.json and decode into AppConfig
- func loadAppConfig(configFile string, appcfg *Config) {
- file, err := os.Open(configFile)
- defer file.Close()
- if err != nil {
- log.Fatalf("[loadConfig] File: %s Error: %s\n", configFile, err)
- }
- decoder := json.NewDecoder(file)
- err = decoder.Decode(&appcfg)
- if err != nil {
- fmt.Println("configuration's reading report: ", err.Error())
- os.Exit(-1)
- }
- fmt.Printf("%+v\n", appcfg)
- }
- /*
- {
- "bbolt_file": "",
- "sqlite_file": "",
- "bucket_path": "",
- "table_name": "",
- "fields": [
- {
- "read": "",
- "write": ""
- },
- {
- "read": "",
- "write": ""
- },
- {
- "read": "",
- "write": ""
- },
- {
- "read": "",
- "write": ""
- },
- {
- "read": "",
- "write": ""
- },
- {
- "read": "",
- "write": ""
- },
- {
- "read": "",
- "write": ""
- }
- ]
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement