Go version
go1.27
Output of go env in your module/workspace:
What did you do?
Do this:
v := jsontext.Value(`["foo", "bar", "baz", ]`)
fmt.Println(v.Compact())
What did you see happen?
It correctly reports an error like:
jsontext: invalid character ']' at start of value within "/3" after offset 22
What did you expect to see?
However, it would be more helpful to report:
jsontext: invalid trailing ',' before ']' after offset 20
An accidental trailing comma is a common mistake in hand-modified JSON.
While the current syntactic error is correct (and actually the easiest to produce given the parsing context), it is not particularly easy for a human to diagnose the problem.
Go version
go1.27
Output of
go envin your module/workspace:What did you do?
Do this:
What did you see happen?
It correctly reports an error like:
What did you expect to see?
However, it would be more helpful to report:
An accidental trailing comma is a common mistake in hand-modified JSON.
While the current syntactic error is correct (and actually the easiest to produce given the parsing context), it is not particularly easy for a human to diagnose the problem.