mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-08 01:07:05 -05:00
35 lines
591 B
Go
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:]
|
|
}
|