Skip to content

Commit 4af1d7e

Browse files
lollipopmansmoeding
authored andcommitted
Fix go importing
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
1 parent e436795 commit 4af1d7e

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

bindings/go/binding_test.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/go/go.mod

Lines changed: 0 additions & 5 deletions
This file was deleted.

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ module github.com/smoeding/tree-sitter-puppet
33
go 1.22
44

55
require github.com/tree-sitter/go-tree-sitter v0.24.0
6+
7+
require github.com/mattn/go-pointer v0.0.1 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=
2+
github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc=
3+
github.com/tree-sitter/go-tree-sitter v0.24.0 h1:kRZb6aBNfcI/u0Qh8XEt3zjNVnmxTisDBN+kXK0xRYQ=
4+
github.com/tree-sitter/go-tree-sitter v0.24.0/go.mod h1:x681iFVoLMEwOSIHA1chaLkXlroXEN7WY+VHGFaoDbk=

0 commit comments

Comments
 (0)