stub main, load config

This commit is contained in:
Dan Ballard 2015-04-27 08:31:51 -07:00
parent 79c556eb1d
commit 0856527144
3 changed files with 51 additions and 0 deletions

3
.gitignore vendored
View File

@ -1,4 +1,7 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
transmet
.project
*~
*.o
*.a
*.so

8
config/local.json Normal file
View File

@ -0,0 +1,8 @@
{
"Sql": {
"Host": "localhost",
"Dbname": "transmet",
"Username": "transmet",
"Password": "asdfasdf"
}
}

40
main.go Normal file
View File

@ -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()
}