Source File
pointer.go
Belonging Package
github.com/goccy/go-json/internal/errors
package errorsimport ()// ErrInvalidUTF8 reports invalid UTF-8 in a JSON string: jsontext and the v2 json package report it by this error.var ErrInvalidUTF8 = errors.New("invalid UTF-8")// maxShownPointer is the length over which the pointer of an error is shown shortened: its start and its end,// of about half of it each, cut before a token if they can be.const maxShownPointer = 100// ShortPointer shortens a long pointer. The part which is left out is shown by an ellipsis for the end of the// token which the start cuts, one for the whole tokens, and one for the start of the token which the end cuts.func ( string) string {if len() <= maxShownPointer {return}:= maxShownPointer / 2:= strings.LastIndexByte([1:], '/') + 1if <= 0 {for = ; !utf8.RuneStart([]); -- {}}:= max(len()-, +1):= strings.IndexByte([:], '/'):= < 0 // the end starts within a tokenif {for = len() - ; !utf8.RuneStart([]); ++ {}} else {+=}:= [:]:= [:], := strings.IndexByte(, '/'), strings.LastIndexByte(, '/')if != 0 {+= "…" // the end of a token}if >= 0 && ( > || !) {+= "/…" // whole tokens}if && >= 0 {+= "/"if < len()-1 {+= "…" // the start of a token}}return + [:]}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |