From 3d6f45f81c5905ca51e6c2af5d9ed10155a4f2c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 1 Jun 2021 09:00:27 +0300 Subject: [PATCH] lint --- .build.yml | 5 +++++ Makefile | 7 ++++++- go.mod | 2 ++ main.go | 2 +- rootfs/rootfs.go | 5 ----- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.build.yml b/.build.yml index 7b9fc7f..0e177d2 100644 --- a/.build.yml +++ b/.build.yml @@ -1,11 +1,16 @@ image: alpine/edge packages: - go + - git - make sources: - https://git.sr.ht/~motiejus/undocker tasks: + - setup: | + GOPATH=/usr/local go install honnef.co/go/tools/cmd/staticcheck - test: | make -C undocker coverage.html + - lint: | + make -C undocker lint artifacts: - undocker/coverage.html diff --git a/Makefile b/Makefile index 9b27981..bc556f4 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,12 @@ undocker: $(GODEPS) .PHONY: test test: - go test -cover ./... + go test -race -cover ./... + +.PHONY: lint +lint: + staticcheck -f stylish ./... + go vet ./... .INTERMEDIATE: coverage.out coverage.out: $(GODEPS) diff --git a/go.mod b/go.mod index 4067504..db9d752 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module git.sr.ht/~motiejus/undocker go 1.16 + +require honnef.co/go/tools v0.2.0 // indirect diff --git a/main.go b/main.go index ac5eec8..ee99746 100644 --- a/main.go +++ b/main.go @@ -31,7 +31,7 @@ func main() { c := &command{flattener: rootfs.Flatten, Stdout: os.Stdout} if err := c.execute(os.Args[1], os.Args[2]); err != nil { - fmt.Errorf("Error: %v", err) + fmt.Printf("Error: %v", err) os.Exit(1) } os.Exit(0) diff --git a/rootfs/rootfs.go b/rootfs/rootfs.go index 7ea0ae6..1ff9b26 100644 --- a/rootfs/rootfs.go +++ b/rootfs/rootfs.go @@ -5,7 +5,6 @@ import ( "bytes" "compress/gzip" "encoding/json" - "errors" "fmt" "io" "io/ioutil" @@ -20,10 +19,6 @@ const ( _whPrefix = ".wh." ) -var ( - errBadManifest = errors.New("bad manifest.json") -) - type ( dockerManifestJSON []struct { Layers []string `json:"Layers"`