Files
opencloud/vendor/github.com/gookit/goutil/stdutil/stdutil.go
2023-04-19 20:24:34 +02:00

35 lines
591 B
Go

// Package stdutil provide some standard util functions for go.
package stdutil
import (
"fmt"
"runtime"
)
// DiscardE discard error
func DiscardE(_ error) {}
// PanicIfErr if error is not empty
func PanicIfErr(err error) {
if err != nil {
panic(err)
}
}
// PanicIf if error is not empty
func PanicIf(err error) {
if err != nil {
panic(err)
}
}
// Panicf format panic message use fmt.Sprintf
func Panicf(format string, v ...any) {
panic(fmt.Sprintf(format, v...))
}
// GoVersion get go runtime version. eg: "1.18.2"
func GoVersion() string {
return runtime.Version()[2:]
}