Last active
May 16, 2021 21:49
-
-
Save madflojo/0551ed6fe5c82caabf703c120c76e36c to your computer and use it in GitHub Desktop.
Viper Article - App Run and Stop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package app | |
| import ( | |
| // imports go here | |
| "github.com/madflojo/go-quick/config" | |
| ) | |
| // Common errors returned by this app. | |
| var ( | |
| ErrShutdown = fmt.Errorf("application shutdown gracefully") | |
| ) | |
| // cfg is used across the app package to contain configuration. | |
| var cfg config.Config | |
| // Run starts the primary application. It handles starting background services, | |
| // populating package globals & structures, and clean up tasks. | |
| func Run(c config.Config) error { | |
| // Apply config provided by main | |
| cfg = c | |
| // Application logic goes here | |
| } | |
| // Stop is used to gracefully shutdown the server. | |
| func Stop() { | |
| // Stop logic goes here | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment