util.go 371 B

123456789101112131415161718
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package astutil
  5. import "go/ast"
  6. // Unparen returns e with any enclosing parentheses stripped.
  7. func Unparen(e ast.Expr) ast.Expr {
  8. for {
  9. p, ok := e.(*ast.ParenExpr)
  10. if !ok {
  11. return e
  12. }
  13. e = p.X
  14. }
  15. }