diff --git a/Makefile b/Makefile index 9d296a3..4bf00da 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -include $(GOROOT)/src/Make.$(GOARCH) +include $(GOROOT)/src/Make.inc TARG=conf GOFILES=\ diff --git a/conf.go b/conf.go index eb8c1dd..59d5f0a 100644 --- a/conf.go +++ b/conf.go @@ -171,13 +171,13 @@ type GetError struct { func (err GetError) String() string { switch err.Reason { case SectionNotFound: - return fmt.Sprintf("section '%s' not found", err.Section) + return fmt.Sprintf("section '%s' not found", string(err.Section)) case OptionNotFound: - return fmt.Sprintf("option '%s' not found in section '%s'", err.Option, err.Section) + return fmt.Sprintf("option '%s' not found in section '%s'", string(err.Option), string(err.Section)) case CouldNotParse: - return fmt.Sprintf("could not parse %s value '%s'", err.ValueType, err.Value) + return fmt.Sprintf("could not parse %s value '%s'", string(err.ValueType), string(err.Value)) case MaxDepthReached: - return fmt.Sprintf("possible cycle while unfolding variables: max depth of %d reached", DepthValues) + return fmt.Sprintf("possible cycle while unfolding variables: max depth of %d reached", int(DepthValues)) } return "invalid get error" @@ -193,7 +193,7 @@ func (err ReadError) String() string { case BlankSection: return "empty section name not allowed" case CouldNotParse: - return fmt.Sprintf("could not parse line: %s", err.Line) + return fmt.Sprintf("could not parse line: %s", string(err.Line)) } return "invalid read error" diff --git a/get.go b/get.go index 3879a5d..2fb10c6 100644 --- a/get.go +++ b/get.go @@ -159,12 +159,12 @@ func (c *ConfigFile) GetInt(section string, option string) (value int, err os.Er // GetFloat has the same behaviour as GetString but converts the response to float. -func (c *ConfigFile) GetFloat(section string, option string) (value float, err os.Error) { +func (c *ConfigFile) GetFloat64(section string, option string) (value float64, err os.Error) { sv, err := c.GetString(section, option) if err == nil { - value, err = strconv.Atof(sv) + value, err = strconv.Atof64(sv) if err != nil { - err = GetError{CouldNotParse, "float", sv, section, option} + err = GetError{CouldNotParse, "float64", sv, section, option} } } diff --git a/read.go b/read.go index ee7658e..82af45b 100644 --- a/read.go +++ b/read.go @@ -13,7 +13,7 @@ import ( func ReadConfigFile(fname string) (c *ConfigFile, err os.Error) { var file *os.File - if file, err = os.Open(fname, os.O_RDONLY, 0); err != nil { + if file, err = os.Open(fname); err != nil { return nil, err } diff --git a/write.go b/write.go index c41563b..be3cc64 100644 --- a/write.go +++ b/write.go @@ -12,7 +12,7 @@ import ( func (c *ConfigFile) WriteConfigFile(fname string, perm uint32, header string) (err os.Error) { var file *os.File - if file, err = os.Open(fname, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, perm); err != nil { + if file, err = os.Create(fname); err != nil { return err } if err = c.Write(file, header); err != nil {