Strongly-typed AST types for Go, auto-generated from
tree-sitter-go's node-types.json.
This crate is generated by treesitter-types and is
automatically kept up to date when a new version of the grammar crate is released.
These types have been tested by parsing the Go compiler source code.
See the Tree-sitter project for more information about the underlying parser framework.
Example
use *;
// A minimal Go hello-world program.
let src = b"\
package main
import \"fmt\"
func main() {
fmt.Println(\"Hello, World!\")
}
";
// Parse the source with tree-sitter and convert into typed AST.
let mut parser = new;
parser.set_language.unwrap;
let tree = parser.parse.unwrap;
let source_file = from_node.unwrap;
// The source file has three top-level children.
assert_eq!;
// 1) The package clause — `package main`.
let PackageClause = &source_file.children else ;
assert_eq!;
// 2) The import declaration — `import "fmt"`.
let ImportDeclaration = &source_file.children else ;
let ImportSpec = &import.children else ;
assert!; // no alias
// 3) The function declaration — `func main() { ... }`.
let FunctionDeclaration = &source_file.children else ;
assert_eq!;
assert!; // no parameters
assert!; // no return type
assert!; // has a body