all: gotool
@go build -v .
clean:
rm -f apiserver
find . -name "[._]*.s[a-w][a-z]" | xargs -i rm -f {}
gotool:
gofmt -w .
go tool vet . |& grep -v vendor;true
help:
@echo "make - compile the source code"
@echo "make clean - remove binary file and vim swp files"
@echo "make gotool - run go tool 'fmt' and 'vet'"
@echo "make ca - generate ca files"
.PHONY: clean gotool help与这个推荐的go tool vet . |& grep -v vendor;true混淆,并在执行此操作时出错...
$ make
gofmt -w .
go tool vet . |& grep -v vendor;true
/bin/sh: 1: Syntax error: "&" unexpected
Makefile:7: recipe for target 'gotool' failed
make: *** [gotool] Error 2发布于 2019-02-08 12:49:02
该命令尝试将标准输出和标准错误都重定向到grep。可移植的(主观上更好的)方法是
go tool vet . 2>&1 | grep -v vendor || true尾随的true将导致make命令成功,即使grep找不到任何匹配项(即没有不包含vendor的输出行)。回想一下,make在缺省情况下会在出现第一个错误时中断编译;这避免了显然只为监视或娱乐而运行的命令出现错误。
https://stackoverflow.com/questions/54585229
复制相似问题