-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
48 lines (37 loc) · 762 Bytes
/
main.go
File metadata and controls
48 lines (37 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"flag"
"fmt"
"log"
"os"
"code.google.com/p/gcfg"
)
type Config struct {
Service struct {
Port int
}
}
func ConfigFromFile(configFile string) (Config, error) {
var Cfg Config
if _, err := os.Stat(configFile); err != nil {
return Cfg, err
}
err := gcfg.ReadFileInto(&Cfg, configFile)
return Cfg, err
}
var gitversion string
func main() {
file := flag.String("config", "config/development.ini", "Config file location")
version := flag.Bool("gitversion", false, "Print godex git version")
flag.Parse()
if *version {
fmt.Println(gitversion)
os.Exit(0)
}
config, err := ConfigFromFile(*file)
if err != nil {
log.Fatal(err.Error())
os.Exit(1)
}
log.Printf("Binding to Port %d\n", config.Service.Port)
}