go-get 运行 是否从具有不同环境变量的当前 shell 进程派生?
Does go-get run builds forked from current shell process with different environment variables?
我有一个简单的 Makefile
像这样:
unexport GOPATH
help :
@echo "libedkafka"
@echo "libedkafka-clean"
opt/librdkafka:
(mkdir -p ./opt && cd ./opt && git clone https://github.com/edenhill/librdkafka.git --depth=1)
opt/librdkafka/config.cache: opt/librdkafka
(cd ./opt/librdkafka && ./configure --prefix build)
opt/librdkafka/build/lib/pkgconfig/rdkafka.pc: opt/librdkafka/config.cache
(cd ./opt/librdkafka && make && make install)
make -t opt/librdkafka/build/lib/pkgconfig/rdkafka.pc
opt/librdkafka-goget-done: opt/librdkafka/build/lib/pkgconfig/rdkafka.pc
( export PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:opt/librdkafka/build/lib/pkgconfig"; \
go env; \
echo $$PKG_CONFIG_PATH; \
pkg-config --cflags -- rdkafka-static; \
echo "So it should work "; \
go get -u -tags static gopkg.in/confluentinc/confluent-kafka-go.v1/kafka && \
touch opt/librdkafka-goget-done; )
librdkafka: opt/librdkafka-goget-done
librdkafka-clean:
rm -rf ./opt/librdkafka
rm -rf ./opt/librdkafka-goget-done
当我 运行 它时,它失败并出现错误,它找不到 pkg-config
的相关配置,而当我在目标中打印它时,它向我显示了值!
$ make librdkafka
( export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:opt/librdkafka/build/lib/pkgconfig"; \
go env; \
echo $PKG_CONFIG_PATH; \
pkg-config --cflags -- rdkafka-static; \
echo "So it should work "; \
go get -u -tags static gopkg.in/confluentinc/confluent-kafka-go.v1/kafka && \
touch opt/librdkafka-goget-done; )
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/me/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/me/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.5/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/me/Workspace/TBNew/test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/s_/tygqt0_56pzg6jk2xycqr7_w0000gq/T/go-build935984301=/tmp/go-build -gno-record-gcc-switches -fno-common"
:opt/librdkafka/build/lib/pkgconfig
-I/Users/me/Workspace/TBNew/test/opt/librdkafka/build/include
So it should work
# pkg-config --cflags -- rdkafka-static
Package rdkafka-static was not found in the pkg-config search path.
Perhaps you should add the directory containing `rdkafka-static.pc'
to the PKG_CONFIG_PATH environment variable
No package 'rdkafka-static' found
pkg-config: exit status 1
make: *** [opt/librdkafka-goget-done] Error 2
所以我的问题是 go-get 在构建时是否使用不同的环境?
我正在使用 mac-os(达尔文内核版本 18.5.0)作为我的操作系统。
我找到问题了!我的意思是我修复了它:PKG_CONFIG_PATH
中的值包含我的配置文件的相对路径。当我将其更改为绝对路径脚本时有效。
# Assuming PRJ_DIR is defined before!
export PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:$${PRJ_DIR}opt/librdkafka/build/lib/pkgconfig";
不确定,但我认为 go-get 在使用环境中的值之前会对它们进行评估,如果检测到不合适的值,请静静地删除它们!
我有一个简单的 Makefile
像这样:
unexport GOPATH
help :
@echo "libedkafka"
@echo "libedkafka-clean"
opt/librdkafka:
(mkdir -p ./opt && cd ./opt && git clone https://github.com/edenhill/librdkafka.git --depth=1)
opt/librdkafka/config.cache: opt/librdkafka
(cd ./opt/librdkafka && ./configure --prefix build)
opt/librdkafka/build/lib/pkgconfig/rdkafka.pc: opt/librdkafka/config.cache
(cd ./opt/librdkafka && make && make install)
make -t opt/librdkafka/build/lib/pkgconfig/rdkafka.pc
opt/librdkafka-goget-done: opt/librdkafka/build/lib/pkgconfig/rdkafka.pc
( export PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:opt/librdkafka/build/lib/pkgconfig"; \
go env; \
echo $$PKG_CONFIG_PATH; \
pkg-config --cflags -- rdkafka-static; \
echo "So it should work "; \
go get -u -tags static gopkg.in/confluentinc/confluent-kafka-go.v1/kafka && \
touch opt/librdkafka-goget-done; )
librdkafka: opt/librdkafka-goget-done
librdkafka-clean:
rm -rf ./opt/librdkafka
rm -rf ./opt/librdkafka-goget-done
当我 运行 它时,它失败并出现错误,它找不到 pkg-config
的相关配置,而当我在目标中打印它时,它向我显示了值!
$ make librdkafka
( export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:opt/librdkafka/build/lib/pkgconfig"; \
go env; \
echo $PKG_CONFIG_PATH; \
pkg-config --cflags -- rdkafka-static; \
echo "So it should work "; \
go get -u -tags static gopkg.in/confluentinc/confluent-kafka-go.v1/kafka && \
touch opt/librdkafka-goget-done; )
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/me/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/me/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.5/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/me/Workspace/TBNew/test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/s_/tygqt0_56pzg6jk2xycqr7_w0000gq/T/go-build935984301=/tmp/go-build -gno-record-gcc-switches -fno-common"
:opt/librdkafka/build/lib/pkgconfig
-I/Users/me/Workspace/TBNew/test/opt/librdkafka/build/include
So it should work
# pkg-config --cflags -- rdkafka-static
Package rdkafka-static was not found in the pkg-config search path.
Perhaps you should add the directory containing `rdkafka-static.pc'
to the PKG_CONFIG_PATH environment variable
No package 'rdkafka-static' found
pkg-config: exit status 1
make: *** [opt/librdkafka-goget-done] Error 2
所以我的问题是 go-get 在构建时是否使用不同的环境?
我正在使用 mac-os(达尔文内核版本 18.5.0)作为我的操作系统。
我找到问题了!我的意思是我修复了它:PKG_CONFIG_PATH
中的值包含我的配置文件的相对路径。当我将其更改为绝对路径脚本时有效。
# Assuming PRJ_DIR is defined before!
export PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:$${PRJ_DIR}opt/librdkafka/build/lib/pkgconfig";
不确定,但我认为 go-get 在使用环境中的值之前会对它们进行评估,如果检测到不合适的值,请静静地删除它们!