DIRS := \ . \ nl uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1))) testdirs = $(call uniq,$(foreach d,$(1),$(dir $(wildcard $(d)/*_test.go)))) all: test .PHONY: $(call testdirs,$(DIRS)) $(call testdirs,$(DIRS)): ! gofmt -l $@*.go | grep '' go test -v github.com/vishvananda/netlink/$@ test: $(call testdirs,$(DIRS))