Skip to content
/ go-exit Public

Finally respect your damn deferred function calls on `err != nil`

Notifications You must be signed in to change notification settings

sug0/go-exit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

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...

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))
}

About

Finally respect your damn deferred function calls on `err != nil`

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages