diff --git a/ast/node.go b/ast/node.go index 5cc91b1db..ae386c929 100644 --- a/ast/node.go +++ b/ast/node.go @@ -695,14 +695,14 @@ func (self *Node) GetByPath(path ...interface{}) *Node { } var s = self for _, p := range path { - switch p.(type) { + switch p := p.(type) { case int: - s = s.Index(p.(int)) + s = s.Index(p) if !s.Valid() { return s } case string: - s = s.Get(p.(string)) + s = s.Get(p) if !s.Valid() { return s } diff --git a/ast/search.go b/ast/search.go index 9e809bb8d..b6357094a 100644 --- a/ast/search.go +++ b/ast/search.go @@ -40,13 +40,13 @@ func (self *Searcher) GetByPath(path ...interface{}) (Node, error) { var err types.ParsingError for _, p := range path { - switch p.(type) { + switch p := p.(type) { case int: - if err = self.parser.searchIndex(p.(int)); err != 0 { + if err = self.parser.searchIndex(p); err != 0 { return Node{}, self.parser.ExportError(err) } case string: - if err = self.parser.searchKey(p.(string)); err != 0 { + if err = self.parser.searchKey(p); err != 0 { return Node{}, self.parser.ExportError(err) } default: