Skip to content

Instantly share code, notes, and snippets.

@oxlb
Created May 16, 2020 14:27
Show Gist options
  • Save oxlb/0d1195748302be30b6e16543138d3251 to your computer and use it in GitHub Desktop.
Save oxlb/0d1195748302be30b6e16543138d3251 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/tkanos/gonfig"
"fmt"
)
type Configuration struct {
DB_USERNAME string
DB_PASSWORD string
DB_PORT string
DB_HOST string
DB_NAME string
}
func GetConfig(params ...string) Configuration {
configuration := Configuration{}
env := "dev"
if len(params) > 0 {
env = params[0]
}
fileName := fmt.Sprintf("./%s_config.json", env)
gonfig.GetConf(fileName, &configuration)
return configuration
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment