mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-10 02:26:08 +01:00
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!
25 lines
363 B
Go
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)
|
|
}
|