diff options
author | dakkar <dakkar@thenautilus.net> | 2024-12-19 09:42:17 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2024-12-19 09:42:17 +0000 |
commit | c940ac4f72e7e55ef1a7aa35cc0fc32684716977 (patch) | |
tree | df46d71d6b0ea49a979f90fc43b6947617942b04 /cmd/main/main.go | |
download | go-example-c940ac4f72e7e55ef1a7aa35cc0fc32684716977.tar.gz go-example-c940ac4f72e7e55ef1a7aa35cc0fc32684716977.tar.bz2 go-example-c940ac4f72e7e55ef1a7aa35cc0fc32684716977.zip |
minimal example
Diffstat (limited to 'cmd/main/main.go')
-rw-r--r-- | cmd/main/main.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/cmd/main/main.go b/cmd/main/main.go new file mode 100644 index 0000000..ac7f788 --- /dev/null +++ b/cmd/main/main.go @@ -0,0 +1,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") + } +} |