aboutsummaryrefslogtreecommitdiff
path: root/cmd/main/main.go
blob: ac7f788b0eba8478a5d3944e9e972804503b8aee (plain)
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
package main
 
import (
"fmt"
"os"
 
"www.thenautilus.net/cgit/go-example/config"
factorypkg "www.thenautilus.net/cgit/go-example/factory"
"www.thenautilus.net/cgit/go-example/logging"
)
 
func main() {
// this is the main binary, so the config file is in
// the same directory as the executable
config, err := config.GetMainConfig(".")
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
 
log := logging.Logger(config.Logger)
 
log.Info().Object("config", &config).Msg("configuration")
 
factory := factorypkg.New(log, &config)
 
something := factory.Something()
 
err = something.DoSomething()
if err != nil {
log.Error().Err(err).Msg("Can't do the thing")
}
}