rbtr-lang-go 2026.9.0.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rbtr_lang_go-2026.9.0.dev1/LICENSE +21 -0
- rbtr_lang_go-2026.9.0.dev1/PKG-INFO +64 -0
- rbtr_lang_go-2026.9.0.dev1/README.md +37 -0
- rbtr_lang_go-2026.9.0.dev1/pyproject.toml +59 -0
- rbtr_lang_go-2026.9.0.dev1/pyproject.toml.orig +63 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/__init__.py +1 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/go.scm +53 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/plugin.py +57 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/py.typed +0 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/__init__.py +0 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/__snapshots__/test_samples/test_edges_match_snapshot.json +3 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/__snapshots__/test_samples/test_extraction_matches_snapshot.json +325 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/cases_docstrings.py +140 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/cases_extraction.py +294 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/samples/go/go.go +43 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/samples/go/go.mod +3 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/samples/go/greeter/text.go +13 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/test_docstrings.py +45 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/test_extraction.py +57 -0
- rbtr_lang_go-2026.9.0.dev1/src/rbtr_lang_go/tests/test_samples.py +87 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alejandro Giacometti
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rbtr-lang-go
|
|
3
|
+
Version: 2026.9.0.dev1
|
|
4
|
+
Summary: rbtr — Go language plugin
|
|
5
|
+
Keywords: code-search,code-index,tree-sitter,static-analysis,semantic-search,developer-tools,go,golang
|
|
6
|
+
Author: Alejandro Giacometti
|
|
7
|
+
Author-email: Alejandro Giacometti <alejandro.giacometti@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Go
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Dist: rbtr==2026.9.0.dev1
|
|
19
|
+
Requires-Dist: tree-sitter-go
|
|
20
|
+
Requires-Python: >=3.13
|
|
21
|
+
Project-URL: Homepage, https://github.com/janrito/rbtr
|
|
22
|
+
Project-URL: Repository, https://github.com/janrito/rbtr
|
|
23
|
+
Project-URL: Documentation, https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-go#readme
|
|
24
|
+
Project-URL: Issues, https://github.com/janrito/rbtr/issues
|
|
25
|
+
Project-URL: Changelog, https://github.com/janrito/rbtr/releases
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# rbtr-lang-go
|
|
29
|
+
|
|
30
|
+
Go support for [rbtr]. Optional plugin — install with
|
|
31
|
+
`pip install rbtr[go]`.
|
|
32
|
+
|
|
33
|
+
[rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
|
|
34
|
+
|
|
35
|
+
## What it ingests
|
|
36
|
+
|
|
37
|
+
- **Functions & methods** — `func`; a method with a receiver is scoped to its
|
|
38
|
+
receiver type.
|
|
39
|
+
- **Classes** — `struct`, `interface`, and named types.
|
|
40
|
+
- **Variables** — package-level `var` / `const` (and grouped blocks).
|
|
41
|
+
- **Imports** — `import` declarations (single and grouped), for cross-file
|
|
42
|
+
edges. An import path carries the module prefix `go.mod` declares, which is
|
|
43
|
+
read from the repository and stripped, and it names a package — a directory
|
|
44
|
+
— so the edge reaches every `.go` file in it.
|
|
45
|
+
|
|
46
|
+
Leading `//` doc comments fold into the symbol's content.
|
|
47
|
+
|
|
48
|
+
## Chunks produced
|
|
49
|
+
|
|
50
|
+
```go
|
|
51
|
+
func Greet(name string) string { … } // function "Greet"
|
|
52
|
+
type Server struct { … } // class "Server"
|
|
53
|
+
func (s *Server) Start() { … } // method "Start", scope "Server"
|
|
54
|
+
const MaxConns = 100 // variable "MaxConns"
|
|
55
|
+
import "fmt" // import, metadata {module: fmt}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Embedded / injected chunks
|
|
59
|
+
|
|
60
|
+
None. Go does not embed other languages.
|
|
61
|
+
|
|
62
|
+
## Grammar & dependencies
|
|
63
|
+
|
|
64
|
+
Uses the `tree-sitter-go` grammar. No dependency on other language plugins.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# rbtr-lang-go
|
|
2
|
+
|
|
3
|
+
Go support for [rbtr]. Optional plugin — install with
|
|
4
|
+
`pip install rbtr[go]`.
|
|
5
|
+
|
|
6
|
+
[rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
|
|
7
|
+
|
|
8
|
+
## What it ingests
|
|
9
|
+
|
|
10
|
+
- **Functions & methods** — `func`; a method with a receiver is scoped to its
|
|
11
|
+
receiver type.
|
|
12
|
+
- **Classes** — `struct`, `interface`, and named types.
|
|
13
|
+
- **Variables** — package-level `var` / `const` (and grouped blocks).
|
|
14
|
+
- **Imports** — `import` declarations (single and grouped), for cross-file
|
|
15
|
+
edges. An import path carries the module prefix `go.mod` declares, which is
|
|
16
|
+
read from the repository and stripped, and it names a package — a directory
|
|
17
|
+
— so the edge reaches every `.go` file in it.
|
|
18
|
+
|
|
19
|
+
Leading `//` doc comments fold into the symbol's content.
|
|
20
|
+
|
|
21
|
+
## Chunks produced
|
|
22
|
+
|
|
23
|
+
```go
|
|
24
|
+
func Greet(name string) string { … } // function "Greet"
|
|
25
|
+
type Server struct { … } // class "Server"
|
|
26
|
+
func (s *Server) Start() { … } // method "Start", scope "Server"
|
|
27
|
+
const MaxConns = 100 // variable "MaxConns"
|
|
28
|
+
import "fmt" // import, metadata {module: fmt}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Embedded / injected chunks
|
|
32
|
+
|
|
33
|
+
None. Go does not embed other languages.
|
|
34
|
+
|
|
35
|
+
## Grammar & dependencies
|
|
36
|
+
|
|
37
|
+
Uses the `tree-sitter-go` grammar. No dependency on other language plugins.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.11.26,<1"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[tool.uv.build-backend]
|
|
6
|
+
module-name = "rbtr_lang_go"
|
|
7
|
+
|
|
8
|
+
[tool.uv.sources.rbtr]
|
|
9
|
+
workspace = true
|
|
10
|
+
|
|
11
|
+
[project]
|
|
12
|
+
name = "rbtr-lang-go"
|
|
13
|
+
version = "2026.9.0-dev1"
|
|
14
|
+
description = "rbtr — Go language plugin"
|
|
15
|
+
readme = "README.md"
|
|
16
|
+
license = "MIT"
|
|
17
|
+
license-files = ["LICENSE"]
|
|
18
|
+
keywords = [
|
|
19
|
+
"code-search",
|
|
20
|
+
"code-index",
|
|
21
|
+
"tree-sitter",
|
|
22
|
+
"static-analysis",
|
|
23
|
+
"semantic-search",
|
|
24
|
+
"developer-tools",
|
|
25
|
+
"go",
|
|
26
|
+
"golang",
|
|
27
|
+
]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 4 - Beta",
|
|
30
|
+
"Intended Audience :: Developers",
|
|
31
|
+
"Programming Language :: Go",
|
|
32
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
33
|
+
"Programming Language :: Python :: 3.13",
|
|
34
|
+
"Topic :: Software Development :: Libraries",
|
|
35
|
+
"Topic :: Text Processing :: Indexing",
|
|
36
|
+
"Typing :: Typed",
|
|
37
|
+
]
|
|
38
|
+
requires-python = ">=3.13"
|
|
39
|
+
dependencies = [
|
|
40
|
+
"rbtr==2026.9.0-dev1",
|
|
41
|
+
"tree-sitter-go",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[[project.authors]]
|
|
45
|
+
name = "Alejandro Giacometti"
|
|
46
|
+
email = "alejandro.giacometti@gmail.com"
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://github.com/janrito/rbtr"
|
|
50
|
+
Repository = "https://github.com/janrito/rbtr"
|
|
51
|
+
Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-go#readme"
|
|
52
|
+
Issues = "https://github.com/janrito/rbtr/issues"
|
|
53
|
+
Changelog = "https://github.com/janrito/rbtr/releases"
|
|
54
|
+
|
|
55
|
+
[project.entry-points."rbtr.languages"]
|
|
56
|
+
go = "rbtr_lang_go.plugin:go"
|
|
57
|
+
|
|
58
|
+
[dependency-groups]
|
|
59
|
+
dev = ["rbtr[test]"]
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.11.26,<1"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[tool.uv.build-backend]
|
|
6
|
+
module-name = "rbtr_lang_go"
|
|
7
|
+
# No source-exclude: the plugin's tests, samples, and snapshots ship with
|
|
8
|
+
# the wheel (they are the language's golden record), and go.scm ships as
|
|
9
|
+
# package data.
|
|
10
|
+
|
|
11
|
+
[project]
|
|
12
|
+
name = "rbtr-lang-go"
|
|
13
|
+
version = "2026.9.0-dev1"
|
|
14
|
+
description = "rbtr — Go language plugin"
|
|
15
|
+
readme = "README.md"
|
|
16
|
+
license = "MIT"
|
|
17
|
+
license-files = ["LICENSE"]
|
|
18
|
+
authors = [
|
|
19
|
+
{ name = "Alejandro Giacometti", email = "alejandro.giacometti@gmail.com" },
|
|
20
|
+
]
|
|
21
|
+
keywords = [
|
|
22
|
+
"code-search",
|
|
23
|
+
"code-index",
|
|
24
|
+
"tree-sitter",
|
|
25
|
+
"static-analysis",
|
|
26
|
+
"semantic-search",
|
|
27
|
+
"developer-tools",
|
|
28
|
+
"go",
|
|
29
|
+
"golang",
|
|
30
|
+
]
|
|
31
|
+
classifiers = [
|
|
32
|
+
"Development Status :: 4 - Beta",
|
|
33
|
+
"Intended Audience :: Developers",
|
|
34
|
+
"Programming Language :: Go",
|
|
35
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
36
|
+
"Programming Language :: Python :: 3.13",
|
|
37
|
+
"Topic :: Software Development :: Libraries",
|
|
38
|
+
"Topic :: Text Processing :: Indexing",
|
|
39
|
+
"Typing :: Typed",
|
|
40
|
+
]
|
|
41
|
+
requires-python = ">=3.13"
|
|
42
|
+
dependencies = [
|
|
43
|
+
"rbtr==2026.9.0-dev1",
|
|
44
|
+
"tree-sitter-go",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.urls]
|
|
48
|
+
Homepage = "https://github.com/janrito/rbtr"
|
|
49
|
+
Repository = "https://github.com/janrito/rbtr"
|
|
50
|
+
Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-go#readme"
|
|
51
|
+
Issues = "https://github.com/janrito/rbtr/issues"
|
|
52
|
+
Changelog = "https://github.com/janrito/rbtr/releases"
|
|
53
|
+
|
|
54
|
+
[project.entry-points."rbtr.languages"]
|
|
55
|
+
# The value resolves to the language's `LanguageRegistration` (named by its
|
|
56
|
+
# id) — see the rbtr ARCHITECTURE "External plugins" note.
|
|
57
|
+
go = "rbtr_lang_go.plugin:go"
|
|
58
|
+
|
|
59
|
+
[tool.uv.sources]
|
|
60
|
+
rbtr = { workspace = true }
|
|
61
|
+
|
|
62
|
+
[dependency-groups]
|
|
63
|
+
dev = ["rbtr[test]"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Go language plugin package."""
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
; Top-level comments (Go uses one `comment` type for `//` and `/* */`).
|
|
2
|
+
; The engine groups these and folds a block flush before a symbol into it.
|
|
3
|
+
(comment) @comment
|
|
4
|
+
|
|
5
|
+
(function_declaration
|
|
6
|
+
name: (identifier) @_fn_name) @function
|
|
7
|
+
|
|
8
|
+
(method_declaration
|
|
9
|
+
receiver: (parameter_list
|
|
10
|
+
(parameter_declaration
|
|
11
|
+
type: [
|
|
12
|
+
(type_identifier) @_scope
|
|
13
|
+
(pointer_type (type_identifier) @_scope)
|
|
14
|
+
]))
|
|
15
|
+
name: (field_identifier) @_method_name) @method
|
|
16
|
+
|
|
17
|
+
(type_declaration
|
|
18
|
+
(type_spec
|
|
19
|
+
name: (type_identifier) @_cls_name)) @class
|
|
20
|
+
|
|
21
|
+
(type_spec
|
|
22
|
+
(interface_type
|
|
23
|
+
(method_elem
|
|
24
|
+
name: (field_identifier) @_method_name) @method))
|
|
25
|
+
|
|
26
|
+
(type_declaration
|
|
27
|
+
(type_alias
|
|
28
|
+
name: (type_identifier) @_cls_name)) @class
|
|
29
|
+
|
|
30
|
+
(import_declaration
|
|
31
|
+
(import_spec
|
|
32
|
+
path: (interpreted_string_literal) @_import_module) @import)
|
|
33
|
+
|
|
34
|
+
(import_declaration
|
|
35
|
+
(import_spec_list
|
|
36
|
+
(import_spec
|
|
37
|
+
path: (interpreted_string_literal) @_import_module) @import))
|
|
38
|
+
|
|
39
|
+
(source_file
|
|
40
|
+
(var_declaration
|
|
41
|
+
(var_spec
|
|
42
|
+
name: (identifier) @_var_name) @variable))
|
|
43
|
+
|
|
44
|
+
(source_file
|
|
45
|
+
(const_declaration
|
|
46
|
+
(const_spec
|
|
47
|
+
name: (identifier) @_var_name) @variable))
|
|
48
|
+
|
|
49
|
+
(source_file
|
|
50
|
+
(var_declaration
|
|
51
|
+
(var_spec_list
|
|
52
|
+
(var_spec
|
|
53
|
+
name: (identifier) @_var_name) @variable)))
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Go language plugin.
|
|
2
|
+
|
|
3
|
+
Provides full support: functions, methods, type declarations,
|
|
4
|
+
and import extraction.
|
|
5
|
+
|
|
6
|
+
Extracted chunks::
|
|
7
|
+
|
|
8
|
+
func hello() {} → function "hello", scope ""
|
|
9
|
+
func (u User) Name() string {} → method "Name", scope ""
|
|
10
|
+
type User struct { ... } → class "User", scope ""
|
|
11
|
+
type Reader interface { ... } → class "Reader", scope ""
|
|
12
|
+
|
|
13
|
+
import "fmt"
|
|
14
|
+
→ import, metadata {module: "fmt"}
|
|
15
|
+
import ("fmt" "os/exec")
|
|
16
|
+
→ 2 import chunks: {module: "fmt"}, {module: "os/exec"}
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import re
|
|
22
|
+
|
|
23
|
+
from rbtr.languages.registration import LanguageRegistration, QueryExtraction, load_query
|
|
24
|
+
|
|
25
|
+
# ── Manifest ─────────────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
_MODULE_LINE = re.compile(r"^\s*module\s+(\S+)", re.MULTILINE)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# ── Plugin ───────────────────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
go = LanguageRegistration(
|
|
34
|
+
id="go",
|
|
35
|
+
extensions=frozenset({".go"}),
|
|
36
|
+
grammar_module="tree_sitter_go",
|
|
37
|
+
extraction=QueryExtraction(
|
|
38
|
+
query=load_query(__package__, "go"),
|
|
39
|
+
scope_types=frozenset({"type_spec"}),
|
|
40
|
+
),
|
|
41
|
+
package_directory=True,
|
|
42
|
+
extraction_serial=4,
|
|
43
|
+
manifest="go.mod",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@go.manifest_reader
|
|
48
|
+
def go_module_prefix(text: str) -> tuple[tuple[str, str], ...]:
|
|
49
|
+
"""Strip the module path `go.mod` declares from every import.
|
|
50
|
+
|
|
51
|
+
Imports inside a module are written from the module root, so `module
|
|
52
|
+
example.com/m` makes `example.com/m/b` the directory `b`.
|
|
53
|
+
"""
|
|
54
|
+
match = _MODULE_LINE.search(text)
|
|
55
|
+
if match is None:
|
|
56
|
+
return ()
|
|
57
|
+
return ((f"{match.group(1)}/", ""),)
|
|
File without changes
|
|
File without changes
|