I get this error when running go vet in my project, with vendored dependencies.
$ go vet ./...
# <project path...>/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1
vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/curve.go:42:10: fatal error: libsecp256k1/include/secp256k1.h: No such file or directory
#include "libsecp256k1/include/secp256k1.h"
I thought that this was a dependency missing in the development environment, but when looking at the original project source, the include path is relative to the source file.
Why can the file not be found?
Some dependency management tools for go do not vendor all code that is referenced by the project. This means that in some circumstances C code, that can be used in go files with cgo, are not included in the vendor directory.
I have encountered this issue twice with two separate vendoring tools, but there is work to support these use cases.
The simplest method I have found so far is to use govendor and then import the complete directory to ensure that all the required files are there. This is a very simple solution that ignores a lot of the complexity around including c dependencies in go projects, but fixes the issue whilst there is no permanent fix for the issue.
go get github.com/kardianos/govendor
govendor init
govendor add +e
# Remove the directory that is missing the c dependencies
rm -rf ./vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/
# Add the file and include all files
# https://github.com/kardianos/govendor/issues/247
govendor add github.com/ethereum/go-ethereum/crypto/secp256k1/^