MCPcopy
hub / github.com/pelletier/go-toml / ExampleDecodeError

Function ExampleDecodeError

errors_test.go:534–553  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

532}
533
534func ExampleDecodeError() {
535 doc := `name = 123__456`
536
537 s := map[string]interface{}{}
538 err := Unmarshal([]byte(doc), &s)
539
540 fmt.Println(err)
541
542 var derr *DecodeError
543 if errors.As(err, &derr) {
544 fmt.Println(derr.String())
545 row, col := derr.Position()
546 fmt.Println("error occurred at row", row, "column", col)
547 }
548 // Output:
549 // toml: number must have at least one digit between underscores
550 // 1| name = 123__456
551 // | ~~ number must have at least one digit between underscores
552 // error occurred at row 1 column 11
553}
554
555func TestWrapDecodeErrorNil(t *testing.T) {
556 assert.True(t, wrapDecodeError([]byte("a = 1"), nil) == nil)

Callers

nothing calls this directly

Calls 3

StringMethod · 0.95
PositionMethod · 0.95
UnmarshalFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…