Skip to content
Browse files

Update so it compiles

Fixed issue 4
Fixed issue 8
Fixed issue 9
Fixed issue 10
Fixed issue 11
  • Loading branch information...
1 parent 63d75cb commit f602e48a7b0f6bfcfc7fcad6b1aaca25cf5291c9 @stephenmw stephenmw committed Jun 27, 2011
Showing with 11 additions and 11 deletions.
  1. +1 −1 Makefile
  2. +5 −5 conf.go
  3. +3 −3 get.go
  4. +1 −1 read.go
  5. +1 −1 write.go
View
2 Makefile
@@ -1,4 +1,4 @@
-include $(GOROOT)/src/Make.$(GOARCH)
+include $(GOROOT)/src/Make.inc
TARG=conf
GOFILES=\
View
10 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"
View
6 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}
}
}
View
2 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
}
View
2 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 {

0 comments on commit f602e48

Please sign in to comment.
Something went wrong with that request. Please try again.