https://github.com/sug0/go-exit
Finally respect your damn deferred function calls on `err != nil`
https://github.com/sug0/go-exit
different err exit fatal go log nil
Last synced: 11 months ago
JSON representation
Finally respect your damn deferred function calls on `err != nil`
- Host: GitHub
- URL: https://github.com/sug0/go-exit
- Owner: sug0
- Created: 2018-05-29T23:49:30.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-05T23:56:07.000Z (about 7 years ago)
- Last Synced: 2025-02-13T08:54:16.676Z (about 1 year ago)
- Topics: different, err, exit, fatal, go, log, nil
- Language: Go
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Who is this for?
For our naive gophers who call `log.Fatal(err)` or `os.Exit(1)` after
doing some shit like `defer f.Close()`.
# Usage
Buckle up boys and galz...
```go
package main
import (
"os"
"fmt"
"exit"
)
type ExitStatus int
func (s ExitStatus) ExitCode() int {
fmt.Fprintln(os.Stderr, "OMG IT ALL WENT DOWN THE SHITTER")
return int(s)
}
func main() {
defer exit.Handler()
defer fmt.Println("it worked I guess")
exit.WithStatus(ExitStatus(2))
}
```