我试图在influx/telegraf
本地构建并使用go mod vendor
命令供应所有包。然而,有趣的是,构建失败后出现以下错误:
# github.com/shirou/gopsutil/host
vendor/github.com/shirou/gopsutil/host/host_darwin_cgo.go:9:11: fatal error: 'include/smc.c' file not found
#include "include/smc.c"
^~~~~~~~~~~~~~~
重现步骤(设置 GOPATH 变量后):
# Fetch the project, e.g. influx/telegraf
go get -d github.com/influxdata/telegraf
# CD into the project
cd $GOPATH/src/influxdata/telegraf
# Checkout v1.14.5 (the current latest version)
git checkout v1.14.5
# Fetch the modules under vendor/ directory
go mod vendor
# Then modify the Makefile as follows:
# 1. Remove the `deps` target and its reference in the `all` target; it is not needed anymore, as we fetched all modules.
# 2. Add the `-mod vendor` flag everywhere `go build`, `go install`, or `go test` is called. This is necessary since Telegraf v1.14.5 is still on version 1.12 of Go, which requires this flag to use the modules under `vendor/` directory.
# Finally, build the project and you should get the error above
make