This commit is contained in:
Thomas Pelletier
2021-05-08 17:03:51 -04:00
committed by GitHub
parent ea225df3ed
commit 45ea20024b
8 changed files with 476 additions and 58 deletions
+21
View File
@@ -3,6 +3,7 @@ package toml
import (
"bytes"
"errors"
"fmt"
"strings"
"testing"
@@ -179,3 +180,23 @@ line 5`,
})
}
}
func ExampleDecodeError() {
doc := `name = 123__456`
s := map[string]interface{}{}
err := Unmarshal([]byte(doc), &s)
fmt.Println(err)
de := err.(*DecodeError)
fmt.Println(de.String())
row, col := de.Position()
fmt.Println("error occured at row", row, "column", col)
// Output:
// toml: number must have at least one digit between underscores
// 1| name = 123__456
// | ~~ number must have at least one digit between underscores
// error occured at row 1 column 11
}