summaryrefslogtreecommitdiff
path: root/vendor/github.com/go-pg/zerochecker
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/go-pg/zerochecker')
-rw-r--r--vendor/github.com/go-pg/zerochecker/LICENSE24
-rw-r--r--vendor/github.com/go-pg/zerochecker/go.mod3
-rw-r--r--vendor/github.com/go-pg/zerochecker/zerochecker.go126
3 files changed, 0 insertions, 153 deletions
diff --git a/vendor/github.com/go-pg/zerochecker/LICENSE b/vendor/github.com/go-pg/zerochecker/LICENSE
deleted file mode 100644
index 7751509b8..000000000
--- a/vendor/github.com/go-pg/zerochecker/LICENSE
+++ /dev/null
@@ -1,24 +0,0 @@
-Copyright (c) 2013 github.com/go-pg/pg Authors. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/github.com/go-pg/zerochecker/go.mod b/vendor/github.com/go-pg/zerochecker/go.mod
deleted file mode 100644
index f01e8a9f4..000000000
--- a/vendor/github.com/go-pg/zerochecker/go.mod
+++ /dev/null
@@ -1,3 +0,0 @@
-module github.com/go-pg/zerochecker
-
-go 1.13
diff --git a/vendor/github.com/go-pg/zerochecker/zerochecker.go b/vendor/github.com/go-pg/zerochecker/zerochecker.go
deleted file mode 100644
index 61bd207c9..000000000
--- a/vendor/github.com/go-pg/zerochecker/zerochecker.go
+++ /dev/null
@@ -1,126 +0,0 @@
-package zerochecker
-
-import (
- "database/sql/driver"
- "reflect"
-)
-
-var driverValuerType = reflect.TypeOf((*driver.Valuer)(nil)).Elem()
-var appenderType = reflect.TypeOf((*valueAppender)(nil)).Elem()
-var isZeroerType = reflect.TypeOf((*isZeroer)(nil)).Elem()
-
-type isZeroer interface {
- IsZero() bool
-}
-
-type valueAppender interface {
- AppendValue(b []byte, flags int) ([]byte, error)
-}
-
-type Func func(reflect.Value) bool
-
-func Checker(typ reflect.Type) Func {
- if typ.Implements(isZeroerType) {
- return isZeroInterface
- }
-
- switch typ.Kind() {
- case reflect.Array:
- if typ.Elem().Kind() == reflect.Uint8 {
- return isZeroBytes
- }
- return isZeroLen
- case reflect.String:
- return isZeroLen
- case reflect.Bool:
- return isZeroBool
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return isZeroInt
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return isZeroUint
- case reflect.Float32, reflect.Float64:
- return isZeroFloat
- case reflect.Interface, reflect.Ptr, reflect.Slice, reflect.Map:
- return isNil
- }
-
- if typ.Implements(appenderType) {
- return isZeroAppenderValue
- }
- if typ.Implements(driverValuerType) {
- return isZeroDriverValue
- }
-
- return isZeroFalse
-}
-
-func isZeroInterface(v reflect.Value) bool {
- if v.Kind() == reflect.Ptr && v.IsNil() {
- return true
- }
- return v.Interface().(isZeroer).IsZero()
-}
-
-func isZeroAppenderValue(v reflect.Value) bool {
- if v.Kind() == reflect.Ptr {
- return v.IsNil()
- }
-
- appender := v.Interface().(valueAppender)
- value, err := appender.AppendValue(nil, 0)
- if err != nil {
- return false
- }
- return value == nil
-}
-
-func isZeroDriverValue(v reflect.Value) bool {
- if v.Kind() == reflect.Ptr {
- return v.IsNil()
- }
-
- valuer := v.Interface().(driver.Valuer)
- value, err := valuer.Value()
- if err != nil {
- return false
- }
- return value == nil
-}
-
-func isZeroLen(v reflect.Value) bool {
- return v.Len() == 0
-}
-
-func isNil(v reflect.Value) bool {
- return v.IsNil()
-}
-
-func isZeroBool(v reflect.Value) bool {
- return !v.Bool()
-}
-
-func isZeroInt(v reflect.Value) bool {
- return v.Int() == 0
-}
-
-func isZeroUint(v reflect.Value) bool {
- return v.Uint() == 0
-}
-
-func isZeroFloat(v reflect.Value) bool {
- return v.Float() == 0
-}
-
-func isZeroBytes(v reflect.Value) bool {
- b := v.Slice(0, v.Len()).Bytes()
- for _, c := range b {
- if c != 0 {
- return false
- }
- }
- return true
-}
-
-func isZeroFalse(v reflect.Value) bool {
- return false
-}