Skip to content

Commit 0f0e8f3

Browse files
committed
fix: add error checking in types_test.go and use 'any' type
- Add error checking for json.Unmarshal calls to fix errcheck lint errors - Replace interface{} with any for Go 1.18+ compatibility Signed-off-by: penfree <pengfei.qiu@gmail.com> Change-Id: Ic742890ad4675fdd1a920d36aacb748e356d1735
1 parent 05a5c4f commit 0f0e8f3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pkg/utils/tokenizer/types_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,17 @@ func TestChatMessageContentPreservation(t *testing.T) {
8888
}
8989

9090
// Unmarshal to generic interface to verify structure
91-
var inputMap, outputMap map[string]interface{}
92-
json.Unmarshal([]byte(input), &inputMap)
93-
json.Unmarshal(output, &outputMap)
91+
var inputMap, outputMap map[string]any
92+
if err := json.Unmarshal([]byte(input), &inputMap); err != nil {
93+
t.Fatalf("Failed to unmarshal input: %v", err)
94+
}
95+
if err := json.Unmarshal(output, &outputMap); err != nil {
96+
t.Fatalf("Failed to unmarshal output: %v", err)
97+
}
9498

9599
// Check that content is an array in both
96-
inputContent, inputOk := inputMap["content"].([]interface{})
97-
outputContent, outputOk := outputMap["content"].([]interface{})
100+
inputContent, inputOk := inputMap["content"].([]any)
101+
outputContent, outputOk := outputMap["content"].([]any)
98102

99103
if !inputOk || !outputOk {
100104
t.Fatal("Content should be an array")

0 commit comments

Comments
 (0)