Rename Parse and Load to {Parse,Load}Config
This commit is contained in:
parent
0dd852183a
commit
6608aaf865
|
@ -47,17 +47,17 @@ func (d *Directive) ChildByName(name string) *Directive {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Load(path string) (*Directive, error) {
|
func LoadConfig(path string) (*Directive, error) {
|
||||||
f, err := os.Open(path)
|
f, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
return Parse(f)
|
return ParseConfig(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Parse(r io.Reader) (*Directive, error) {
|
func ParseConfig(r io.Reader) (*Directive, error) {
|
||||||
scanner := bufio.NewScanner(r)
|
scanner := bufio.NewScanner(r)
|
||||||
|
|
||||||
var directives []*Directive
|
var directives []*Directive
|
||||||
|
|
2
main.go
2
main.go
|
@ -15,7 +15,7 @@ func main() {
|
||||||
flag.StringVar(&configPath, "config", configPath, "path to configuration file")
|
flag.StringVar(&configPath, "config", configPath, "path to configuration file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
cfg, err := Load(configPath)
|
cfg, err := LoadConfig(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to load config file: %v", err)
|
log.Fatalf("failed to load config file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue