From a918dd6e1bb43e4cafe4a456e14c9f107d9c70f7 Mon Sep 17 00:00:00 2001 From: kruskall <99559985+kruskall@users.noreply.github.com> Date: Fri, 9 Sep 2022 16:56:25 +0200 Subject: [PATCH] refactor: use go 1.17 run syntax in makefile tasks (#132) replace old workaround and go install with go run syntax. Formatting also took care of an issue introduced in go 1.19 with the style changes around documentation/comments. --- Makefile | 27 ++++++--------------------- providers/linux/capabilities_linux.go | 5 +++-- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 9d3ea5c7..9d4e6b17 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,14 @@ -GOPATH?=~/go - .phony: update update: fmt lic imports .PHONY: lic -lic: $(GOPATH)/bin/go-licenser - go-licenser +lic: + go run github.com/elastic/go-licenser@latest .PHONY: fmt -fmt: $(GOPATH)/bin/gofumpt - gofumpt -w -l ./ +fmt: + go run mvdan.cc/gofumpt@latest -w -l ./ .PHONY: imports -imports: $(GOPATH)/bin/goimports - goimports -l -local github.com/elastic/go-sysinfo ./ - -$(GOPATH)/bin/go-licenser: - @echo "go-licenser missing, installing" - go install github.com/elastic/go-licenser@latest - -$(GOPATH)/bin/gofumpt: - @echo "gofumpt missing, installing" - #Ugly boilerplate for go mod installs - cd $(mktemp -d); go mod init tmp; go get mvdan.cc/gofumpt - -$(GOPATH)/bin/goimports: - @echo "goimports missing, installing" - go install golang.org/x/tools/cmd/goimports@latest +imports: + go run golang.org/x/tools/cmd/goimports@latest -l -local github.com/elastic/go-sysinfo ./ diff --git a/providers/linux/capabilities_linux.go b/providers/linux/capabilities_linux.go index c13e0402..0b53d75d 100644 --- a/providers/linux/capabilities_linux.go +++ b/providers/linux/capabilities_linux.go @@ -26,8 +26,9 @@ import ( // capabilityNames is mapping of capability constant values to names. // // Generated with: -// curl -s https://raw.githubusercontent.com/torvalds/linux/master/include/uapi/linux/capability.h | \ -// grep -P '^#define CAP_\w+\s+\d+' | perl -pe 's/#define (\w+)\s+(\d+)/\2: "\1",/g' +// +// curl -s https://raw.githubusercontent.com/torvalds/linux/master/include/uapi/linux/capability.h | \ +// grep -P '^#define CAP_\w+\s+\d+' | perl -pe 's/#define (\w+)\s+(\d+)/\2: "\1",/g' var capabilityNames = map[int]string{ 0: "chown", 1: "dac_override",