代码之家  ›  专栏  ›  技术社区  ›  danielcooperxyz

在使用dep运行go vet时找不到头文件

  •  1
  • danielcooperxyz  · 技术社区  · 8 年前

    我在我的项目中运行go-vet时遇到此错误,并具有自动提供的依赖项。

    $ 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"
    

    为什么找不到文件?

    2 回复  |  直到 8 年前
        1
  •  2
  •   danielcooperxyz    7 年前

    一些go依赖关系管理工具并没有提供项目引用的所有代码。这意味着在某些情况下,可以在带有C go的go文件中使用的C代码不包括在vendor目录中。

    我已经用两个独立的自动售货工具遇到过两次这个问题,但是有一些工作可以支持这些 use cases .

    到目前为止我找到的最简单的方法是 govendor 然后导入完整的目录以确保所有必需的文件都在那里。这是一个非常简单的解决方案,它忽略了在go项目中包含c依赖项的许多复杂性,但是在没有永久性解决方案的情况下修复了这个问题。

    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/^
    
        2
  •  1
  •   truongnm    7 年前

    Gopkg.toml 您可以添加

    [prune]
      go-tests = true
      unused-packages = true
      non-go = true
    
      [[prune.project]]
        name = "github.com/ethereum/go-ethereum"
        non-go = false
        unused-packages = false
    
    推荐文章