-
Notifications
You must be signed in to change notification settings - Fork 465
Open
Labels
goPull requests that update Go codePull requests that update Go codegood first issueGood for newcomersGood for newcomers
Description
Is your feature request related to a problem? Please describe.
Currently, every cmd code uses log.Fatal to handle the exit of the program, this is really bad since it calls os.Exit directly and it is very hard to implement a stopper in the cmd.Run function.
Describe the solution you'd like
Use context.WithCancel to pass a cancellable context, the underlying functions can call cancel in case of an error that requires the entire program to exit.
Then cmd.Run can have a exit handler that can listen to this context to gracefully clean up its resources.
This context can also be used by underlying functions.
Metadata
Metadata
Assignees
Labels
goPull requests that update Go codePull requests that update Go codegood first issueGood for newcomersGood for newcomers