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:
+6
-5
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user