From 0856527144f76bc4685ed58d9db2b66db8a149bc Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Mon, 27 Apr 2015 08:31:51 -0700 Subject: [PATCH] stub main, load config --- .gitignore | 3 +++ config/local.json | 8 ++++++++ main.go | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 config/local.json create mode 100644 main.go diff --git a/.gitignore b/.gitignore index daf913b..63160bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ # Compiled Object files, Static and Dynamic libs (Shared Objects) +transmet +.project +*~ *.o *.a *.so diff --git a/config/local.json b/config/local.json new file mode 100644 index 0000000..e5156bd --- /dev/null +++ b/config/local.json @@ -0,0 +1,8 @@ +{ + "Sql": { + "Host": "localhost", + "Dbname": "transmet", + "Username": "transmet", + "Password": "asdfasdf" + } +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..4dd71fc --- /dev/null +++ b/main.go @@ -0,0 +1,40 @@ +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() + +}