forked from cloudfoundry/route-registrar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_service.go
53 lines (41 loc) · 786 Bytes
/
test_service.go
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
49
50
51
52
53
package main
import (
"github.com/pivotal-cf-experimental/service-config"
"flag"
"fmt"
"os"
)
type ShipConfig struct {
Name string
ID int
Crew Crew
Active bool
}
type Crew struct {
Officers []Officer
Passengers []Passenger
}
type Officer struct {
Name string
Role string
}
type Passenger struct {
Name string
Title string
}
func main() {
serviceConfig := service_config.New()
flags := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
serviceConfig.AddDefaults(ShipConfig{
Active: true,
})
serviceConfig.AddFlags(flags)
flags.Parse(os.Args[1:])
var config ShipConfig
err := serviceConfig.Read(&config)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to read config: %s\n", err.Error())
os.Exit(1)
}
fmt.Printf("Config: %#v\n", config)
}