Source File
decode.go
Belonging Package
github.com/goforj/httpx
package httpximport ()type rawKind intconst (rawNone rawKind = iotarawStringrawBytes)func rawKindOf[ any]() rawKind {:= reflect.TypeOf((*)(nil)).Elem()switch .Kind() {case reflect.String:return rawStringcase reflect.Slice:if .Elem().Kind() == reflect.Uint8 {return rawBytes}}return rawNone}func decodeRaw[ any]( *req.Response) {varswitch rawKindOf[]() {case rawString:= any(.String()).()case rawBytes:= any(.Bytes()).()}return}func ensureNonNil[ any]( *) {if == nil {return}:= reflect.TypeOf((*)(nil)).Elem():= reflect.ValueOf().Elem()switch .Kind() {case reflect.Slice:if .IsNil() {.Set(reflect.MakeSlice(, 0, 0))}case reflect.Map:if .IsNil() {.Set(reflect.MakeMapWithSize(, 0))}}}func isEmptyBody( *req.Response) bool {if == nil {return false}return len(bytes.TrimSpace(.Bytes())) == 0}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |