Source File
anynil.go
Belonging Package
github.com/jackc/pgx/v5/internal/anynil
package anynil
import
// Is returns true if value is any type of nil. e.g. nil or []byte(nil).
func ( any) bool {
if == nil {
return true
}
:= reflect.ValueOf()
switch .Kind() {
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice:
return .IsNil()
default:
return false
}
}
// Normalize converts typed nils (e.g. []byte(nil)) into untyped nil. Other values are returned unmodified.
func ( any) any {
if Is() {
return nil
}
return
}
// NormalizeSlice converts all typed nils (e.g. []byte(nil)) in s into untyped nils. Other values are unmodified. s is
// mutated in place.
func ( []any) {
for := range {
if Is([]) {
[] = nil
}
}
}
![]() |
The pages are generated with Golds v0.6.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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |