Browse Source

add comments to forge.go

pull/16/head
Brett Langdon 11 years ago
parent
commit
37b67150b5
1 changed files with 12 additions and 0 deletions
  1. +12
    -0
      forge.go

+ 12
- 0
forge.go View File

@ -105,10 +105,16 @@ import (
"strings" "strings"
) )
// ParseBytes takes a []byte representation of the config file, parses it
// and responds with `*Section` and potentially an `error` if it cannot
// properly parse the config
func ParseBytes(data []byte) (*Section, error) { func ParseBytes(data []byte) (*Section, error) {
return ParseReader(bytes.NewReader(data)) return ParseReader(bytes.NewReader(data))
} }
// ParseFile takes a string filename for the config file, parses it
// and responds with `*Section` and potentially an `error` if it cannot
// properly parse the configf
func ParseFile(filename string) (*Section, error) { func ParseFile(filename string) (*Section, error) {
reader, err := os.Open(filename) reader, err := os.Open(filename)
if err != nil { if err != nil {
@ -117,6 +123,9 @@ func ParseFile(filename string) (*Section, error) {
return ParseReader(reader) return ParseReader(reader)
} }
// ParseReader takes an `io.Reader` representation of the config file, parses it
// and responds with `*Section` and potentially an `error` if it cannot
// properly parse the config
func ParseReader(reader io.Reader) (*Section, error) { func ParseReader(reader io.Reader) (*Section, error) {
parser := NewParser(reader) parser := NewParser(reader)
err := parser.Parse() err := parser.Parse()
@ -127,6 +136,9 @@ func ParseReader(reader io.Reader) (*Section, error) {
return parser.GetSettings(), nil return parser.GetSettings(), nil
} }
// ParseString takes a string representation of the config file, parses it
// and responds with `*Section` and potentially an `error` if it cannot
// properly parse the config
func ParseString(data string) (*Section, error) { func ParseString(data string) (*Section, error) {
return ParseReader(strings.NewReader(data)) return ParseReader(strings.NewReader(data))
} }

Loading…
Cancel
Save