#incremental #parsing #go

tree-sitter-go

Go grammar for the tree-sitter parsing library

2 unstable releases

0.19.1 Oct 4, 2021
0.16.0 Oct 27, 2020

#4 in #golang

Download history 658/week @ 2022-11-27 735/week @ 2022-12-04 781/week @ 2022-12-11 696/week @ 2022-12-18 695/week @ 2022-12-25 1343/week @ 2023-01-01 1838/week @ 2023-01-08 1845/week @ 2023-01-15 1964/week @ 2023-01-22 1668/week @ 2023-01-29 1466/week @ 2023-02-05 1989/week @ 2023-02-12 2534/week @ 2023-02-19 2482/week @ 2023-02-26 2641/week @ 2023-03-05 2468/week @ 2023-03-12

10,411 downloads per month
Used in 14 crates (3 directly)

MIT license

1.5MB
53K SLoC

C 52K SLoC JavaScript 750 SLoC // 0.0% comments Scheme 120 SLoC // 0.0% comments Rust 31 SLoC // 0.1% comments

tree-sitter-go

This crate provides a Go grammar for the tree-sitter parsing library. To use this crate, add it to the [dependencies] section of your Cargo.toml file. (Note that you will probably also need to depend on the tree-sitter crate to use the parsed result in any useful way.)

[dependencies]
tree-sitter = "0.20"
tree-sitter-go = "0.19"

Typically, you will use the language function to add this grammar to a tree-sitter Parser, and then use the parser to parse some code:

let code = r#"
    func double(x int) int {
    	return x * 2
    }
"#;
let mut parser = Parser::new();
parser.set_language(tree_sitter_go::language()).expect("Error loading Go grammar");
let parsed = parser.parse(code, None);

If you have any questions, please reach out to us in the tree-sitter discussions page.

Dependencies

~1.3–1.9MB
~51K SLoC