Skip to content

Fix go importing#9

Merged
smoeding merged 1 commit into
smoeding:mainfrom
lollipopman:fix-go-mod-try-two
May 7, 2026
Merged

Fix go importing#9
smoeding merged 1 commit into
smoeding:mainfrom
lollipopman:fix-go-mod-try-two

Conversation

@lollipopman
Copy link
Copy Markdown
Contributor

This is attempt two, as the first attempt,
bf66a6a, only worked locally when using a go.mod require directive.

When grabbing a module remotely, Go assumes that all dependent code is in the last directory, e.g.

go get github.com/smoeding/tree-sitter-puppet/bindings/go

Grabs everything in /go and below, so compilation fails, since the C code in the parent directory cannot be found.

This problem does not occur in local development however, since the parent directory does exist, which is why adding a require directive masks the problem.

Instead we want to use the go.mod file /tree-sitter-puppet/go.mod and delete tree-sitter-puppet/bindings/go.mod. Then a go get will grab the C code as well.

This is also how other tree-sitter bindings are setup:

https://github.com/tree-sitter-grammars/tree-sitter-yaml

Two other changes are made:

  1. Switch the Go tree-sitter bindings from github.com/smacker/go-tree-sitter to github.com/tree-sitter/tree-sitter-puppet, as the latter are unmaintained.
  2. Add an indirect dep on github.com/mattn/go-pointer

This is attempt two, as the first attempt,
bf66a6a, only worked locally when using
a go.mod require directive.

When grabbing a module remotely, Go assumes that all dependent code is
in the last directory, e.g.

  go get github.com/smoeding/tree-sitter-puppet/bindings/go

Grabs everything in /go and below, so compilation fails, since the C
code in the parent directory cannot be found.

This problem does not occur in local development however, since the
parent directory does exist, which is why adding a require directive
masks the problem.

Instead we want to use the go.mod file /tree-sitter-puppet/go.mod and
delete tree-sitter-puppet/bindings/go.mod. Then a go get will grab the C
code as well.

This is also how other tree-sitter bindings are setup:

  https://github.com/tree-sitter-grammars/tree-sitter-yaml

Two other changes are made:

1. Switch the Go tree-sitter bindings from
   github.com/smacker/go-tree-sitter to
   github.com/tree-sitter/tree-sitter-puppet, as the latter are
   unmaintained.
2. Add an indirect dep on github.com/mattn/go-pointer
@smoeding
Copy link
Copy Markdown
Owner

smoeding commented May 7, 2026

I don't use the Go bindings, so I won't be able to help here ;-)

@smoeding smoeding merged commit 4af1d7e into smoeding:main May 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants