How to import non-go directories (e.g: C src/) with go modules?

167 Views Asked by At

I use https://github.com/cloudflare/golz4 which is a go interface to C code. So the src/ directory is mandatory in the dep tree.

Most dependency management ignore those directories (without .go files) but leave an option to force it.

e.g: go dep has

# [prune]
#   unused-packages = true

Vgo/Go1.11 mod ignore those directories but is there an option to force import them ?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

The go tool only tracks C sources that are in the same directory as an imported Go package — that's a deeply-engrained assumption of the cache-invalidation algorithm.

Ideally, you should send a PR to cloudflare/golz4 to put the C sources in the same directory as the Go wrapper.