From 45411666b8b887846c00f4e917a1dff8ac539d54 Mon Sep 17 00:00:00 2001 From: XIAO YU Date: Sat, 20 Apr 2024 00:19:42 +0900 Subject: [PATCH] Refactor error handling in decode_struct.go (#51) This commit simplifies the error handling process within the decode_struct.go file. It removes an unnecessary nested conditional check around the existence of the 'Second' field, streamlining the code for better readability and efficiency. --- pkl/decode_struct.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkl/decode_struct.go b/pkl/decode_struct.go index 874a1bb..77dc4ed 100644 --- a/pkl/decode_struct.go +++ b/pkl/decode_struct.go @@ -228,10 +228,8 @@ func (d *decoder) decodePair(typ reflect.Type) (*reflect.Value, error) { } secondField, exists := typ.FieldByName("Second") if !exists { - if !exists { - return nil, &InternalError{ - err: errors.New("unable to find field `Second` on pkl.Pair"), - } + return nil, &InternalError{ + err: errors.New("unable to find field `Second` on pkl.Pair"), } } second, err := d.Decode(secondField.Type)