summaryrefslogtreecommitdiffhomepage
path: root/caddyfile
diff options
context:
space:
mode:
authorMateusz Gajewski <[email protected]>2016-10-25 18:45:30 +0200
committerMateusz Gajewski <[email protected]>2016-10-25 19:19:54 +0200
commit8cc3416bbcb0900d451bf95cbb1363870b39a7ea (patch)
tree1cbfb086caa245a5d808e43f2cabde0af94aec26 /caddyfile
parentc4d64a418ba122058cc08a6893c0c489960f91d9 (diff)
downloadcaddy-8cc3416bbcb0900d451bf95cbb1363870b39a7ea.tar.gz
caddy-8cc3416bbcb0900d451bf95cbb1363870b39a7ea.zip
Remove dead code, do struct alignment, simplify code
Diffstat (limited to 'caddyfile')
-rw-r--r--caddyfile/dispenser_test.go4
-rw-r--r--caddyfile/parse.go18
2 files changed, 6 insertions, 16 deletions
diff --git a/caddyfile/dispenser_test.go b/caddyfile/dispenser_test.go
index 313e273b0..300cd1a51 100644
--- a/caddyfile/dispenser_test.go
+++ b/caddyfile/dispenser_test.go
@@ -64,7 +64,7 @@ func TestDispenser_NextArg(t *testing.T) {
}
assertNextArg := func(expectedVal string, loadAnother bool, expectedCursor int) {
- if d.NextArg() != true {
+ if !d.NextArg() {
t.Error("NextArg(): Should load next argument but got false instead")
}
if d.cursor != expectedCursor {
@@ -74,7 +74,7 @@ func TestDispenser_NextArg(t *testing.T) {
t.Errorf("Val(): Expected '%s' but got '%s'", expectedVal, val)
}
if !loadAnother {
- if d.NextArg() != false {
+ if d.NextArg() {
t.Fatalf("NextArg(): Should NOT load another argument, but got true instead (val: '%s')", d.Val())
}
if d.cursor != expectedCursor {
diff --git a/caddyfile/parse.go b/caddyfile/parse.go
index fab3a8e84..13b23db05 100644
--- a/caddyfile/parse.go
+++ b/caddyfile/parse.go
@@ -16,8 +16,7 @@ import (
// pass in nil instead.
func Parse(filename string, input io.Reader, validDirectives []string) ([]ServerBlock, error) {
p := parser{Dispenser: NewDispenser(filename, input), validDirectives: validDirectives}
- blocks, err := p.parseAll()
- return blocks, err
+ return p.parseAll()
}
// allTokens lexes the entire input, but does not parse it.
@@ -62,12 +61,7 @@ func (p *parser) parseAll() ([]ServerBlock, error) {
func (p *parser) parseOne() error {
p.block = ServerBlock{Tokens: make(map[string][]Token)}
- err := p.begin()
- if err != nil {
- return err
- }
-
- return nil
+ return p.begin()
}
func (p *parser) begin() error {
@@ -76,6 +70,7 @@ func (p *parser) begin() error {
}
err := p.addresses()
+
if err != nil {
return err
}
@@ -86,12 +81,7 @@ func (p *parser) begin() error {
return nil
}
- err = p.blockContents()
- if err != nil {
- return err
- }
-
- return nil
+ return p.blockContents()
}
func (p *parser) addresses() error {