我正在尝试编写一个 super 简单的 Makefile
来在 Go 项目中运行测试。该项目的依赖项已出售,但我想跳过这些测试。当从命令行运行它时,我只是做
$ go test $(go list ./... | grep -v /vendor/)
然而,当我像这样将其放入 Makefile
时:
test:
go test $(go list ./... | grep -v /vendor/)
.PHONY: test
表达式不会被计算:
$ make
go test
? github.com/m90/some-repo [no test files]
我如何让 make 以类似 shell 的方式插入表达式?
最佳答案
在 Makefile 配方部分中,您需要使用第二个 $
转义 $
:
test:
go test $$(go list ./... | grep -v /vendor/)
.PHONY: test
关于go - 为什么我的 Makefile 不在命令中插入表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44167230/