Documentation
¶
Overview ¶
Package sugar provides convenience functions for keeping code clean and less repetitive.
Index ¶
- Variables
- func BoolPtr(v bool) *bool
- func BytePtr(v byte) *byte
- func Check(err error)
- func CheckExit(err error, code ...int)
- func CheckPanic(err error)
- func Complex64Ptr(v complex64) *complex64
- func Complex128Ptr(v complex128) *complex128
- func Float32Ptr(v float32) *float32
- func Float64Ptr(v float64) *float64
- func Int8Ptr(v int8) *int8
- func Int16Ptr(v int16) *int16
- func Int32Ptr(v int32) *int32
- func Int64Ptr(v int64) *int64
- func IntPtr(v int) *int
- func RunePtr(v rune) *rune
- func StrPtr(v string) *string
- func StringPtr(v string) *string
- func Uint8Ptr(v uint8) *uint8
- func Uint16Ptr(v uint16) *uint16
- func Uint32Ptr(v uint32) *uint32
- func Uint64Ptr(v uint64) *uint64
- func UintPtr(v uint) *uint
- type StrSet
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorWriter = os.Stderr ErrorPrefix = "Error:" ErrorFmt = "%s %+v" StandardExitCode = 1 PanicFunc = func(err error) { panic(err) } ErrorPrintFunc = func(err error) { fmt.Fprintf(ErrorWriter, ErrorFmt, ErrorPrefix, err) } ExitFunc = func(code int) { os.Exit(code) } )
Functions ¶
func Check ¶
func Check(err error)
Check takes an error and prints it if it is not nil; but will continue.
func CheckExit ¶
CheckExit takes an error and will print it and exit if it is not nil. If no exit code is provided, the StandardExitCode will be used. Any exit codes beyond the first one one provided will be discarded.
func CheckPanic ¶
func CheckPanic(err error)
CheckPanic takes an error and will panic if it is not nil.
func Complex64Ptr ¶
Complex64Ptr takes a complex64 literal and returns a pointer.
func Complex128Ptr ¶
func Complex128Ptr(v complex128) *complex128
Complex128Ptr takes a complex128 literal and returns a pointer.
func Float32Ptr ¶
Float32Ptr takes float32 literal and returns a pointer.
func Float64Ptr ¶
Float64Ptr takes a float64 literal and returns a pointer.
Types ¶
Click to show internal directories.
Click to hide internal directories.