Rename group to table (#115)

* Rename Group to Table Fixes #45 
* Change fmt.Errorf to errors.new for simple strings
This commit is contained in:
Thomas Pelletier
2016-12-03 12:32:16 +01:00
committed by GitHub
parent d464759235
commit ce7be745f0
7 changed files with 67 additions and 66 deletions
+6 -5
View File
@@ -4,6 +4,7 @@ package toml
import (
"bytes"
"errors"
"fmt"
"unicode"
)
@@ -47,7 +48,7 @@ func parseKey(key string) ([]string, error) {
} else {
if !wasInQuotes {
if buffer.Len() == 0 {
return nil, fmt.Errorf("empty key group")
return nil, errors.New("empty table key")
}
groups = append(groups, buffer.String())
buffer.Reset()
@@ -67,23 +68,23 @@ func parseKey(key string) ([]string, error) {
return nil, fmt.Errorf("invalid bare character: %c", char)
}
if !inQuotes && expectDot {
return nil, fmt.Errorf("what?")
return nil, errors.New("what?")
}
buffer.WriteRune(char)
expectDot = false
}
}
if inQuotes {
return nil, fmt.Errorf("mismatched quotes")
return nil, errors.New("mismatched quotes")
}
if escapeNext {
return nil, fmt.Errorf("unfinished escape sequence")
return nil, errors.New("unfinished escape sequence")
}
if buffer.Len() > 0 {
groups = append(groups, buffer.String())
}
if len(groups) == 0 {
return nil, fmt.Errorf("empty key")
return nil, errors.New("empty key")
}
return groups, nil
}