Make golint shut the f.ck up

This commit is contained in:
Miek Gieben 2015-02-19 10:59:15 +00:00
parent b02ae55fbe
commit bf8a652f64
1 changed files with 68 additions and 68 deletions

136
zscan.go
View File

@ -46,24 +46,24 @@ const (
zValue zValue
zKey zKey
_EXPECT_OWNER_DIR // Ownername zExpectOwnerDir // Ownername
_EXPECT_OWNER_BL // Whitespace after the ownername zExpectOwnerBl // Whitespace after the ownername
_EXPECT_ANY // Expect rrtype, ttl or class zExpectAny // Expect rrtype, ttl or class
_EXPECT_ANY_NOCLASS // Expect rrtype or ttl zExpectAnyNoClass // Expect rrtype or ttl
_EXPECT_ANY_NOCLASS_BL // The whitespace after _EXPECT_ANY_NOCLASS zExpectAnyNoClassBl // The whitespace after _EXPECT_ANY_NOCLASS
_EXPECT_ANY_NOTTL // Expect rrtype or class zExpectAnyNoTtl // Expect rrtype or class
_EXPECT_ANY_NOTTL_BL // Whitespace after _EXPECT_ANY_NOTTL zExpectAnyNoTtlBl // Whitespace after _EXPECT_ANY_NOTTL
_EXPECT_RRTYPE // Expect rrtype zExpectRrtype // Expect rrtype
_EXPECT_RRTYPE_BL // Whitespace BEFORE rrtype zExpectRrtypeBl // Whitespace BEFORE rrtype
_EXPECT_RDATA // The first element of the rdata zExpectRdata // The first element of the rdata
_EXPECT_DIRTTL_BL // Space after directive $TTL zExpectDirTtlBl // Space after directive $TTL
_EXPECT_DIRTTL // Directive $TTL zExpectDirTtl // Directive $TTL
_EXPECT_DIRORIGIN_BL // Space after directive $ORIGIN zExpectDirOriginBl // Space after directive $ORIGIN
_EXPECT_DIRORIGIN // Directive $ORIGIN zExpectDirOrigin // Directive $ORIGIN
_EXPECT_DIRINCLUDE_BL // Space after directive $INCLUDE zExpectDirIncludeBl // Space after directive $INCLUDE
_EXPECT_DIRINCLUDE // Directive $INCLUDE zExpectDirInclude // Directive $INCLUDE
_EXPECT_DIRGENERATE // Directive $GENERATE zExpectDirGenerate // Directive $GENERATE
_EXPECT_DIRGENERATE_BL // Space after directive $GENERATE zExpectDirGenerateBl // Space after directive $GENERATE
) )
// ParseError is a parsing error. It contains the parse error and the location in the io.Reader // ParseError is a parsing error. It contains the parse error and the location in the io.Reader
@ -193,7 +193,7 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
return return
} }
st := _EXPECT_OWNER_DIR // initial state st := zExpectOwnerDir // initial state
var h RR_Header var h RR_Header
var defttl uint32 = defaultTtl var defttl uint32 = defaultTtl
var prevName string var prevName string
@ -205,19 +205,19 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
} }
switch st { switch st {
case _EXPECT_OWNER_DIR: case zExpectOwnerDir:
// We can also expect a directive, like $TTL or $ORIGIN // We can also expect a directive, like $TTL or $ORIGIN
h.Ttl = defttl h.Ttl = defttl
h.Class = ClassINET h.Class = ClassINET
switch l.value { switch l.value {
case zNewline: case zNewline:
st = _EXPECT_OWNER_DIR st = zExpectOwnerDir
case zOwner: case zOwner:
h.Name = l.token h.Name = l.token
if l.token[0] == '@' { if l.token[0] == '@' {
h.Name = origin h.Name = origin
prevName = h.Name prevName = h.Name
st = _EXPECT_OWNER_BL st = zExpectOwnerBl
break break
} }
if h.Name[l.length-1] != '.' { if h.Name[l.length-1] != '.' {
@ -229,23 +229,23 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
return return
} }
prevName = h.Name prevName = h.Name
st = _EXPECT_OWNER_BL st = zExpectOwnerBl
case zDirTtl: case zDirTtl:
st = _EXPECT_DIRTTL_BL st = zExpectDirTtlBl
case zDirOrigin: case zDirOrigin:
st = _EXPECT_DIRORIGIN_BL st = zExpectDirOriginBl
case zDirInclude: case zDirInclude:
st = _EXPECT_DIRINCLUDE_BL st = zExpectDirIncludeBl
case zDirGenerate: case zDirGenerate:
st = _EXPECT_DIRGENERATE_BL st = zExpectDirGenerateBl
case zRrtpe: case zRrtpe:
h.Name = prevName h.Name = prevName
h.Rrtype = l.torc h.Rrtype = l.torc
st = _EXPECT_RDATA st = zExpectRdata
case zClass: case zClass:
h.Name = prevName h.Name = prevName
h.Class = l.torc h.Class = l.torc
st = _EXPECT_ANY_NOCLASS_BL st = zExpectAnyNoClassBl
case zBlank: case zBlank:
// Discard, can happen when there is nothing on the // Discard, can happen when there is nothing on the
// line except the RR type // line except the RR type
@ -258,19 +258,19 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
// Don't about the defttl, we should take the $TTL value // Don't about the defttl, we should take the $TTL value
// defttl = ttl // defttl = ttl
} }
st = _EXPECT_ANY_NOTTL_BL st = zExpectAnyNoTtlBl
default: default:
t <- &Token{Error: &ParseError{f, "syntax error at beginning", l}} t <- &Token{Error: &ParseError{f, "syntax error at beginning", l}}
return return
} }
case _EXPECT_DIRINCLUDE_BL: case zExpectDirIncludeBl:
if l.value != zBlank { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank after $INCLUDE-directive", l}} t <- &Token{Error: &ParseError{f, "no blank after $INCLUDE-directive", l}}
return return
} }
st = _EXPECT_DIRINCLUDE st = zExpectDirInclude
case _EXPECT_DIRINCLUDE: case zExpectDirInclude:
if l.value != zString { if l.value != zString {
t <- &Token{Error: &ParseError{f, "expecting $INCLUDE value, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting $INCLUDE value, not this...", l}}
return return
@ -313,14 +313,14 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
return return
} }
parseZone(r1, l.token, neworigin, t, include+1) parseZone(r1, l.token, neworigin, t, include+1)
st = _EXPECT_OWNER_DIR st = zExpectOwnerDir
case _EXPECT_DIRTTL_BL: case zExpectDirTtlBl:
if l.value != zBlank { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank after $TTL-directive", l}} t <- &Token{Error: &ParseError{f, "no blank after $TTL-directive", l}}
return return
} }
st = _EXPECT_DIRTTL st = zExpectDirTtl
case _EXPECT_DIRTTL: case zExpectDirTtl:
if l.value != zString { if l.value != zString {
t <- &Token{Error: &ParseError{f, "expecting $TTL value, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting $TTL value, not this...", l}}
return return
@ -335,14 +335,14 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
} else { } else {
defttl = ttl defttl = ttl
} }
st = _EXPECT_OWNER_DIR st = zExpectOwnerDir
case _EXPECT_DIRORIGIN_BL: case zExpectDirOriginBl:
if l.value != zBlank { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank after $ORIGIN-directive", l}} t <- &Token{Error: &ParseError{f, "no blank after $ORIGIN-directive", l}}
return return
} }
st = _EXPECT_DIRORIGIN st = zExpectDirOrigin
case _EXPECT_DIRORIGIN: case zExpectDirOrigin:
if l.value != zString { if l.value != zString {
t <- &Token{Error: &ParseError{f, "expecting $ORIGIN value, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting $ORIGIN value, not this...", l}}
return return
@ -363,14 +363,14 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
} else { } else {
origin = l.token origin = l.token
} }
st = _EXPECT_OWNER_DIR st = zExpectOwnerDir
case _EXPECT_DIRGENERATE_BL: case zExpectDirGenerateBl:
if l.value != zBlank { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank after $GENERATE-directive", l}} t <- &Token{Error: &ParseError{f, "no blank after $GENERATE-directive", l}}
return return
} }
st = _EXPECT_DIRGENERATE st = zExpectDirGenerate
case _EXPECT_DIRGENERATE: case zExpectDirGenerate:
if l.value != zString { if l.value != zString {
t <- &Token{Error: &ParseError{f, "expecting $GENERATE value, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting $GENERATE value, not this...", l}}
return return
@ -379,21 +379,21 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
t <- &Token{Error: &ParseError{f, e, l}} t <- &Token{Error: &ParseError{f, e, l}}
return return
} }
st = _EXPECT_OWNER_DIR st = zExpectOwnerDir
case _EXPECT_OWNER_BL: case zExpectOwnerBl:
if l.value != zBlank { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank after owner", l}} t <- &Token{Error: &ParseError{f, "no blank after owner", l}}
return return
} }
st = _EXPECT_ANY st = zExpectAny
case _EXPECT_ANY: case zExpectAny:
switch l.value { switch l.value {
case zRrtpe: case zRrtpe:
h.Rrtype = l.torc h.Rrtype = l.torc
st = _EXPECT_RDATA st = zExpectRdata
case zClass: case zClass:
h.Class = l.torc h.Class = l.torc
st = _EXPECT_ANY_NOCLASS_BL st = zExpectAnyNoClassBl
case zString: case zString:
if ttl, ok := stringToTtl(l.token); !ok { if ttl, ok := stringToTtl(l.token); !ok {
t <- &Token{Error: &ParseError{f, "not a TTL", l}} t <- &Token{Error: &ParseError{f, "not a TTL", l}}
@ -402,36 +402,36 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
h.Ttl = ttl h.Ttl = ttl
// defttl = ttl // don't set the defttl here // defttl = ttl // don't set the defttl here
} }
st = _EXPECT_ANY_NOTTL_BL st = zExpectAnyNoTtlBl
default: default:
t <- &Token{Error: &ParseError{f, "expecting RR type, TTL or class, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting RR type, TTL or class, not this...", l}}
return return
} }
case _EXPECT_ANY_NOCLASS_BL: case zExpectAnyNoClassBl:
if l.value != zBlank { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank before class", l}} t <- &Token{Error: &ParseError{f, "no blank before class", l}}
return return
} }
st = _EXPECT_ANY_NOCLASS st = zExpectAnyNoClass
case _EXPECT_ANY_NOTTL_BL: case zExpectAnyNoTtlBl:
if l.value != zBlank { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank before TTL", l}} t <- &Token{Error: &ParseError{f, "no blank before TTL", l}}
return return
} }
st = _EXPECT_ANY_NOTTL st = zExpectAnyNoTtl
case _EXPECT_ANY_NOTTL: case zExpectAnyNoTtl:
switch l.value { switch l.value {
case zClass: case zClass:
h.Class = l.torc h.Class = l.torc
st = _EXPECT_RRTYPE_BL st = zExpectRrtypeBl
case zRrtpe: case zRrtpe:
h.Rrtype = l.torc h.Rrtype = l.torc
st = _EXPECT_RDATA st = zExpectRdata
default: default:
t <- &Token{Error: &ParseError{f, "expecting RR type or class, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting RR type or class, not this...", l}}
return return
} }
case _EXPECT_ANY_NOCLASS: case zExpectAnyNoClass:
switch l.value { switch l.value {
case zString: case zString:
if ttl, ok := stringToTtl(l.token); !ok { if ttl, ok := stringToTtl(l.token); !ok {
@ -441,28 +441,28 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
h.Ttl = ttl h.Ttl = ttl
// defttl = ttl // don't set the def ttl anymore // defttl = ttl // don't set the def ttl anymore
} }
st = _EXPECT_RRTYPE_BL st = zExpectRrtypeBl
case zRrtpe: case zRrtpe:
h.Rrtype = l.torc h.Rrtype = l.torc
st = _EXPECT_RDATA st = zExpectRdata
default: default:
t <- &Token{Error: &ParseError{f, "expecting RR type or TTL, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting RR type or TTL, not this...", l}}
return return
} }
case _EXPECT_RRTYPE_BL: case zExpectRrtypeBl:
if l.value != zBlank { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank before RR type", l}} t <- &Token{Error: &ParseError{f, "no blank before RR type", l}}
return return
} }
st = _EXPECT_RRTYPE st = zExpectRrtype
case _EXPECT_RRTYPE: case zExpectRrtype:
if l.value != zRrtpe { if l.value != zRrtpe {
t <- &Token{Error: &ParseError{f, "unknown RR type", l}} t <- &Token{Error: &ParseError{f, "unknown RR type", l}}
return return
} }
h.Rrtype = l.torc h.Rrtype = l.torc
st = _EXPECT_RDATA st = zExpectRdata
case _EXPECT_RDATA: case zExpectRdata:
r, e, c1 := setRR(h, c, origin, f) r, e, c1 := setRR(h, c, origin, f)
if e != nil { if e != nil {
// If e.lex is nil than we have encounter a unknown RR type // If e.lex is nil than we have encounter a unknown RR type
@ -474,7 +474,7 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
return return
} }
t <- &Token{RR: r, Comment: c1} t <- &Token{RR: r, Comment: c1}
st = _EXPECT_OWNER_DIR st = zExpectOwnerDir
} }
} }
// If we get here, we and the h.Rrtype is still zero, we haven't parsed anything, this // If we get here, we and the h.Rrtype is still zero, we haven't parsed anything, this