# Dump Go Abstract Syntax Tree

DevFeed: [Dump Go Abstract Syntax Tree](<https://devfeed.tech/articles/dump-go-abstract-syntax-tree-35391.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/dump-go-abstract-syntax-tree/>)

Author: Graham King

Published: 2014-06-28T19:09:44Z

Content type: tutorial

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [code analysis](<https://devfeed.tech/topics/code-analysis.md>), [Parsing](<https://devfeed.tech/topics/parsing.md>), [syntax](<https://devfeed.tech/topics/syntax.md>)

Tags: [analysis](<https://devfeed.tech/tags/analysis.md>), [ast](<https://devfeed.tech/tags/ast.md>), [code](<https://devfeed.tech/tags/code.md>), [code-analysis](<https://devfeed.tech/tags/code-analysis.md>), [go](<https://devfeed.tech/tags/go.md>), [software](<https://devfeed.tech/tags/software.md>), [syntax](<https://devfeed.tech/tags/syntax.md>)

## AI overview

A tutorial on parsing Go source code into an abstract syntax tree and displaying the AST for a given Go file. It frames this as a starting point for refactoring and code analysis tools.

## Source excerpt

Go has good support for examining and modifying Go source code. This is a huge help in writing refactoring and code analysis tools. The first step is usually to parse a source file into it's Abstract Syntax Tree representation. Here's a complete program to display the AST for a given Go file: Use: - Save that as - Build it: - Run it: