Documentation ¶
Index ¶
- func BoolYNToStr(b bool) string
- func BytesToStr(b []byte) string
- func Def[T comparable](t *T) (n T)
- func Default[T comparable](t T, def ...T) (tt T)
- func DropBlankSpace(r rune) rune
- func ExtractRequest(r *http.Request) map[string]any
- func ExtractRequestHeader(r http.Request) map[string]any
- func Ptr[T comparable](t T) *T
- func StrToBytes(s string) (b []byte)
- func StrYNToBool(s string) bool
- func ToSnake(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolYNToStr ¶
BoolYNToStr return 'yes' if true otherwise return 'no' instead.
func BytesToStr ¶
BytesToStr zero allocation bytes to string conversion. Because default string([]byte) take allocation so this helper may help with performance improvement but should be used in caution and appropriately.
Caution: Make sure the given b bytes will never change.
Refs:
func Def ¶
func Def[T comparable](t *T) (n T)
Def return the value of given pointer and return the default value of that type instead if nil.
func Default ¶
func Default[T comparable](t T, def ...T) (tt T)
Default return the default value while it's present and t is blank.
func DropBlankSpace ¶
DropBlankSpace return -1 if given rune is blank space ' ', this intended to be used in strings.Map to remove any blank space from string.
func ExtractRequest ¶
ExtractRequest encode given request to json and just return {} if the request body is empty.
func ExtractRequestHeader ¶
ExtractRequestHeader extract header from given request and return it as json encoded string.
func StrToBytes ¶
StrToBytes zero allocation string to bytes conversion. Because default []byte("string") take allocation so this helper may help with performance improvement but should be used in caution and appropriately.
Caution: Make sure the given s string will never change.
Refs:
func StrYNToBool ¶
StrYNToBool return true only if given s is 'yes' otherwise will return false.
Types ¶
This section is empty.