stub main, load config
This commit is contained in:
parent
79c556eb1d
commit
0856527144
|
@ -1,4 +1,7 @@
|
|||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
transmet
|
||||
.project
|
||||
*~
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"Sql": {
|
||||
"Host": "localhost",
|
||||
"Dbname": "transmet",
|
||||
"Username": "transmet",
|
||||
"Password": "asdfasdf"
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
|
||||
}
|
Loading…
Reference in New Issue