Standard library / go/ast

go/ast.Unparen()

Removes enclosing parenthesized expressions, leaving the original inner expression. Expected stdout: '*ast.BasicLit\n'.

Formal Syntax & Structure

go syntaxgo
func Unparen(e Expr) Expr

Parameters & Attributes

NameTypeDescription
eExprExpression whose outer parentheses are removed.

Return Value

Expr

Removes enclosing parenthesized expressions, leaving the original inner expression.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/ast"  "go/parser")
func check(e error) {  if e != nil {    panic(e)  }}
func main() { x, e := parser.ParseExpr("((42))"); check(e); fmt.Printf("%T\n", ast.Unparen(x)) }
Go Reference