Removed firstIndex and replaced with strings.IndexAny
This commit is contained in:
parent
8f74ead862
commit
bd314801c3
11
conf.go
11
conf.go
|
@ -160,17 +160,6 @@ func NewConfigFile() *ConfigFile {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func firstIndex(s string, delim []byte) int {
|
|
||||||
for i := 0; i < len(s); i++ {
|
|
||||||
for j := 0; j < len(delim); j++ {
|
|
||||||
if s[i] == delim[j] {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetError struct {
|
type GetError struct {
|
||||||
Reason int
|
Reason int
|
||||||
ValueType string
|
ValueType string
|
||||||
|
|
4
read.go
4
read.go
|
@ -84,10 +84,10 @@ func (c *ConfigFile) Read(reader io.Reader) (err os.Error) {
|
||||||
return ReadError{BlankSection, l}
|
return ReadError{BlankSection, l}
|
||||||
|
|
||||||
default: // other alternatives
|
default: // other alternatives
|
||||||
i := firstIndex(l, []byte{'=', ':'})
|
i := strings.IndexAny(l, "=:")
|
||||||
switch {
|
switch {
|
||||||
case i > 0: // option and value
|
case i > 0: // option and value
|
||||||
i := firstIndex(l, []byte{'=', ':'})
|
i := strings.IndexAny(l, "=:")
|
||||||
option = strings.TrimSpace(l[0:i])
|
option = strings.TrimSpace(l[0:i])
|
||||||
value := strings.TrimSpace(stripComments(l[i+1:]))
|
value := strings.TrimSpace(stripComments(l[i+1:]))
|
||||||
c.AddOption(section, option, value)
|
c.AddOption(section, option, value)
|
||||||
|
|
Loading…
Reference in New Issue