From 37b67150b5fc71d1343d7bfdea29e78f3d063276 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Sat, 20 Jun 2015 16:31:09 -0400 Subject: [PATCH] add comments to forge.go --- forge.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/forge.go b/forge.go index e4d0119..2db9b0c 100644 --- a/forge.go +++ b/forge.go @@ -105,10 +105,16 @@ import ( "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) { 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) { reader, err := os.Open(filename) if err != nil { @@ -117,6 +123,9 @@ func ParseFile(filename string) (*Section, error) { 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) { parser := NewParser(reader) err := parser.Parse() @@ -127,6 +136,9 @@ func ParseReader(reader io.Reader) (*Section, error) { 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) { return ParseReader(strings.NewReader(data)) }