go - 为什么我的 Makefile 不在命令中插入表达式

标签 go makefile

我正在尝试编写一个 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/

相关文章:

encoding - Go、DER 和处理大整数

makefile - 静态和共享库的 Autotools 设置

c - 为什么我用gdb调试的时候是 "No symbol file now"?

linux - Makefile 变量是该进程的环境变量吗?

go - 相当于 golang 中的 gpg --sign 吗?

go - go中 'defer'是什么意思?

去吧,如果我用仅类型接收器声明一个函数,如何调用它?

c - 将 m5ops.h 链接到 C 项目

bash - Makefile 中的条件语句是否有效语法

go - 在函数内设置空接口(interface){}类型的变量的值