From bb630a0c2d877614e05873e6225653de3945008e Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Sun, 24 Sep 2023 15:38:20 +0200 Subject: [PATCH] fix --- jsn.go | 4 ++-- jsn_test.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/jsn.go b/jsn.go index b7f3fa1..e15eac7 100644 --- a/jsn.go +++ b/jsn.go @@ -39,9 +39,9 @@ func UnmarshalFrom(r io.Reader, v any) error { return err } if d.More() { - return errX + return errMore } return nil } -var errX = errors.New("body must contain only one JSON object") +var errMore = errors.New("body must contain only one JSON entity") diff --git a/jsn_test.go b/jsn_test.go index fef6bb9..1720c8c 100644 --- a/jsn_test.go +++ b/jsn_test.go @@ -33,7 +33,11 @@ func TestUnmarshal(t *testing.T) { }, { input: `{"abc": 123}a`, - errStr: "body must contain only one JSON object", + errStr: "body must contain only one JSON entity", + }, + { + input: `[123]{"a":"b"}`, + errStr: "body must contain only one JSON entity", }, { input: `{"abc`,