package main import ( "encoding/json" "fmt" "os" ) const VERSION = "0.1" type Config struct { Sql struct { Host string Dbname string Username string Password string } } var ( config Config ) func loadConfig() { file, err := os.Open("config/local.json") if err != nil { fmt.Println("Error: cannot open config file") os.Exit(-1) } decoder := json.NewDecoder(file) decoder.Decode(&config) } func main() { fmt.Println("transmet ", VERSION) fmt.Println("Loading...") loadConfig() }