Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions config/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const tmp = "/tmp/__config_test.go__garbage"
func testGet(t *testing.T, c *Config, section string, option string,
expected interface{}) {
ok := false
switch _ := expected.(type) {
switch expected.(type) {
case string:
v, _ := c.String(section, option)
if v == expected.(string) {
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestInMemory(t *testing.T) {

// Creates a 'tough' configuration file and test (read) parsing.
func TestReadFile(t *testing.T) {
file, err := os.Open(tmp, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0644)
file, err := os.Create(tmp)
if err != nil {
t.Fatalf("Test cannot run because cannot write temporary file: " + tmp)
}
Expand Down Expand Up @@ -266,4 +266,3 @@ func TestWriteReadFile(t *testing.T) {

defer os.Remove(tmp)
}

8 changes: 3 additions & 5 deletions config/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// Base to read a file and get the configuration representation.
// That representation can be queried with GetString, etc.
func _read(fname string, c *Config) (*Config, os.Error) {
file, err := os.Open(fname, os.O_RDONLY, 0)
file, err := os.Open(fname)
if err != nil {
return nil, err
}
Expand All @@ -37,8 +37,7 @@ func _read(fname string, c *Config) (*Config, os.Error) {

// ReadDefault reads a configuration file and returns its representation.
// All arguments, except `fname`, are related to `New()`
func Read(fname string, comment, separator string, preSpace, postSpace bool) (
*Config, os.Error) {
func Read(fname string, comment, separator string, preSpace, postSpace bool) (*Config, os.Error) {
return _read(fname, New(comment, separator, preSpace, postSpace))
}

Expand Down Expand Up @@ -81,7 +80,7 @@ func (self *Config) read(buf *bufio.Reader) (err os.Error) {

// No new section and no section defined so
//case section == "":
//return os.NewError("no section defined")
//return os.NewError("no section defined")

// Other alternatives
default:
Expand All @@ -107,4 +106,3 @@ func (self *Config) read(buf *bufio.Reader) (err os.Error) {
}
return nil
}

3 changes: 1 addition & 2 deletions config/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// The desired file permissions must be passed as in os.Open. The header is a
// string that is saved as a comment in the first line of the file.
func (self *Config) WriteFile(fname string, perm uint32, header string) os.Error {
file, err := os.Open(fname, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, perm)
file, err := os.Create(fname)
if err != nil {
return err
}
Expand Down Expand Up @@ -84,4 +84,3 @@ func (self *Config) write(buf *bufio.Writer, header string) (err os.Error) {

return nil
}