Browse Source

check err and remove some warnings

juliendsv 2 years ago
parent
commit
838b559c75

+ 1 - 4
chapter3/collections/functions.go

@@ -21,9 +21,6 @@ func IncrementVersion(w WorkWith) WorkWith {
 // the specified amount
 func OldVersion(v int) func(w WorkWith) bool {
 	return func(w WorkWith) bool {
-		if w.Version >= v {
-			return true
-		}
-		return false
+		return w.Version >= v
 	}
 }

+ 3 - 1
chapter3/encoding/base64.go

@@ -38,7 +38,9 @@ func Base64ExampleEncoder() error {
 	encoder := base64.NewEncoder(base64.StdEncoding, &buffer)
 
 	// be sure to close
-	encoder.Close()
+	if err := encoder.Close(); err != nil {
+		return err
+	}
 	if _, err := encoder.Write([]byte("encoding some other data")); err != nil {
 		return err
 	}

+ 1 - 1
chapter3/nulls/nullencoding.go

@@ -26,7 +26,7 @@ func (v *nullInt64) UnmarshalJSON(b []byte) error {
 	v.Valid = false
 	if b != nil {
 		v.Valid = true
-		json.Unmarshal(b, &v.Int64)
+		return json.Unmarshal(b, &v.Int64)
 	}
 	return nil
 }