Some linter errors.

This commit is contained in:
go-jet 2019-10-18 10:09:56 +02:00
parent 947d2df47e
commit 0b00a6b12c
4 changed files with 12 additions and 7 deletions

View file

@ -113,6 +113,13 @@ func IsNil(v interface{}) bool {
return v == nil || (reflect.ValueOf(v).Kind() == reflect.Ptr && reflect.ValueOf(v).IsNil()) return v == nil || (reflect.ValueOf(v).Kind() == reflect.Ptr && reflect.ValueOf(v).IsNil())
} }
// MustBeTrue panics when condition is false
func MustBeTrue(condition bool, errorStr string) {
if !condition {
panic(errorStr)
}
}
// MustBe panics with errorStr error, if v interface is not of reflect kind // MustBe panics with errorStr error, if v interface is not of reflect kind
func MustBe(v interface{}, kind reflect.Kind, errorStr string) { func MustBe(v interface{}, kind reflect.Kind, errorStr string) {
if reflect.TypeOf(v).Kind() != kind { if reflect.TypeOf(v).Kind() != kind {
@ -165,6 +172,7 @@ func ErrorCatch(err *error) {
} }
} }
// StringSliceContains checks if slice of strings contains a string
func StringSliceContains(strings []string, contains string) bool { func StringSliceContains(strings []string, contains string) bool {
for _, str := range strings { for _, str := range strings {
if str == contains { if str == contains {

View file

@ -69,7 +69,7 @@ var COUNT = jet.COUNT
// EVERY is aggregate function. Returns true if all input values are true, otherwise false // EVERY is aggregate function. Returns true if all input values are true, otherwise false
var EVERY = jet.EVERY var EVERY = jet.EVERY
// MAXf is aggregate function. Returns maximum value of expression across all input values // MAX is aggregate function. Returns maximum value of expression across all input values
var MAX = jet.MAX var MAX = jet.MAX
// MAXf is aggregate function. Returns maximum value of float expression across all input values // MAXf is aggregate function. Returns maximum value of float expression across all input values

View file

@ -212,9 +212,7 @@ func (s *scanContext) rowElem(index int) interface{} {
valuer, ok := s.row[index].(driver.Valuer) valuer, ok := s.row[index].(driver.Valuer)
if !ok { utils.MustBeTrue(ok, "jet: internal error, scan value doesn't implement driver.Valuer")
panic("jet: internal error, scan value doesn't implement driver.Valuer")
}
value, err := valuer.Value() value, err := valuer.Value()

View file

@ -50,9 +50,8 @@ func getSliceElemPtrAt(slicePtrValue reflect.Value, index int) reflect.Value {
} }
func appendElemToSlice(slicePtrValue reflect.Value, objPtrValue reflect.Value) error { func appendElemToSlice(slicePtrValue reflect.Value, objPtrValue reflect.Value) error {
if slicePtrValue.IsNil() { utils.MustBeTrue(!slicePtrValue.IsNil(), "jet: internal, slice is nil")
panic("jet: internal, slice is nil")
}
sliceValue := slicePtrValue.Elem() sliceValue := slicePtrValue.Elem()
sliceElemType := sliceValue.Type().Elem() sliceElemType := sliceValue.Type().Elem()