Skip to content
Permalink
Browse files

update: account for layout templates (string slices, not just slices …

…of string slices).
  • Loading branch information...
Gabriel Aszalos
Gabriel Aszalos committed Aug 28, 2015
1 parent bbb748b commit 17cde5e36859a47336e707acd943627178ab4349
Showing with 13 additions and 1 deletion.
  1. +13 −1 lint.go
14 lint.go
@@ -154,10 +154,13 @@ func parseTmplSet(filename string) ([][]string, error) {
ast.Walk(visitFn(func(n ast.Node) bool {
switch n := n.(type) {
case *ast.CompositeLit:
if isTmplSet(n.Type) {
switch {
case isTmplSet(n.Type):
for _, e := range n.Elts {
tmplSets = append(tmplSets, astStringSlice(e.(*ast.CompositeLit)))
}
case isLayoutSet(n.Type):
tmplSets = append(tmplSets, astStringSlice(n))
}
}
return true
@@ -176,6 +179,15 @@ func isTmplSet(x ast.Expr) bool {
return false
}

func isLayoutSet(x ast.Expr) bool {
if sx, ok := x.(*ast.ArrayType); ok && sx.Len == nil {
if t, ok := sx.Elt.(*ast.Ident); ok && t.Name == "string" {
return true
}
}
return false
}

func astStringSlice(cl *ast.CompositeLit) []string {
var ss []string
for _, e := range cl.Elts {

0 comments on commit 17cde5e

Please sign in to comment.
You can’t perform that action at this time.