aboutsummaryrefslogtreecommitdiff
path: root/cmd/main
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-12-19 09:57:42 +0000
committerdakkar <dakkar@thenautilus.net>2024-12-19 09:57:42 +0000
commit3132bce2a8166e3f9818059af4de8d69a09bbf12 (patch)
treee92a1cbb61dba41a4a2dcd99ed72babb480e8ccf /cmd/main
parentminimal example (diff)
downloadgo-example-3132bce2a8166e3f9818059af4de8d69a09bbf12.tar.gz
go-example-3132bce2a8166e3f9818059af4de8d69a09bbf12.tar.bz2
go-example-3132bce2a8166e3f9818059af4de8d69a09bbf12.zip
move more code in the factory
Diffstat (limited to 'cmd/main')
-rw-r--r--cmd/main/main.go22
1 files changed, 3 insertions, 19 deletions
diff --git a/cmd/main/main.go b/cmd/main/main.go
index ac7f788..7ad978b 100644
--- a/cmd/main/main.go
+++ b/cmd/main/main.go
@@ -1,33 +1,17 @@
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)
+ factory := factorypkg.NewFromConfig()
something := factory.Something()
- err = something.DoSomething()
+ err := something.DoSomething()
if err != nil {
+ log := factory.Logger()
log.Error().Err(err).Msg("Can't do the thing")
}
}