www.byjp.me/tools/shared/helpers.go
JP Hastings-Spital e7c8e60bcc Facebook import
I kinda screwed with everything else to homogenise all the functions - the FB stuff works, but I've definitely broken some of the other importers.

I can work on fixing them in the future if I need them; otherwise others can look at previous commits!
2024-04-04 17:11:14 +01:00

25 lines
363 B
Go

package shared
import (
"fmt"
"os"
)
func Check(err error, msg string) {
if err != nil {
ExitMessage(fmt.Sprintf("%s\n %v", msg, err))
}
}
func ExitMessage(msg string, args ...interface{}) {
fmt.Fprintf(os.Stderr, msg+"\n", args...)
os.Exit(1)
}
type closer interface {
Close() error
}
func DoClose(c closer, msg string) {
Check(c.Close(), msg)
}