mirror of
https://github.com/rwxrob/bonzai
synced 2024-11-18 15:25:45 +00:00
Remove check.Blank
This commit is contained in:
parent
bae4731293
commit
95af083494
@ -2,26 +2,6 @@ package check
|
||||
|
||||
import "reflect"
|
||||
|
||||
// Blank checks that the passed string, []byte (or slice of either)
|
||||
// contains something besides an empty string.
|
||||
func Blank(i interface{}) bool {
|
||||
switch v := i.(type) {
|
||||
case nil:
|
||||
return false
|
||||
case string:
|
||||
return v != ""
|
||||
case []byte:
|
||||
return string(v) != ""
|
||||
case []string:
|
||||
return v != nil && len(v) != 0 && v[0] != ""
|
||||
case [][]byte:
|
||||
return v != nil && len(v) != 0 && string(v[0]) != ""
|
||||
default:
|
||||
panic("cannot check if type is blank")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsNil is a shortcut for reflect.ValueOf(foo).IsNil() and should only
|
||||
// be used when foo == nil is in question, such as whenever the value of
|
||||
// foo is an interface of any kind. In fact, every interface should use
|
||||
|
@ -7,26 +7,6 @@ import (
|
||||
"github.com/rwxrob/bonzai/check"
|
||||
)
|
||||
|
||||
func ExampleBlank() {
|
||||
fmt.Println(check.Blank(""))
|
||||
fmt.Println(check.Blank(nil))
|
||||
fmt.Println(check.Blank([]string{""}))
|
||||
fmt.Println(check.Blank([][]byte{}))
|
||||
// and now for true
|
||||
fmt.Println(check.Blank("some"))
|
||||
fmt.Println(check.Blank([]string{"some"}))
|
||||
fmt.Println(check.Blank([][]byte{{'a'}}))
|
||||
|
||||
// Output:
|
||||
// false
|
||||
// false
|
||||
// false
|
||||
// false
|
||||
// true
|
||||
// true
|
||||
// true
|
||||
}
|
||||
|
||||
func ExampleIsNil() {
|
||||
var names []string
|
||||
var namesi interface{}
|
||||
|
Loading…
Reference in New Issue
Block a user