Created
May 16, 2020 14:27
-
-
Save oxlb/0d1195748302be30b6e16543138d3251 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
"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