diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b637f00..b3cdb48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: # if: steps.vendor-cache.outputs.cache-hit != 'true' - name: Restore modules from cache id: vendor-cache - uses: actions/cache@v3.0.2 + uses: actions/cache@v3 env: cache-name: vendor with: @@ -71,7 +71,7 @@ jobs: - name: Static analysis uses: golangci/golangci-lint-action@v3.2.0 with: - version: latest + version: v1.48.0 # Run unit tests - name: Test diff --git a/.gitignore b/.gitignore index 63ac2f2..963f922 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Generals .DS_Store .idea +.vscode # Deps vendor/** diff --git a/.golangci.yml b/.golangci.yml index a65ff49..46441cc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -49,7 +49,6 @@ linters: - exhaustive - forcetypeassert - godot - - ifshort - noctx - predeclared - exportloopref @@ -58,6 +57,7 @@ linters: #- wrapcheck #- nestif #- funlen + #- ifshort disable: - deadcode - unused diff --git a/Makefile b/Makefile index 9b0ee5a..31e6d48 100644 --- a/Makefile +++ b/Makefile @@ -44,11 +44,8 @@ ca-roots: ## deps: Download and compile all dependencies and intermediary products deps: - @-rm -rf vendor go mod tidy - go mod verify - go mod download - go mod vendor + go clean ## docker: Build docker image # https://github.com/opencontainers/image-spec/blob/master/annotations.md diff --git a/config_test.go b/config_test.go index 9ed1c38..0c25ed3 100644 --- a/config_test.go +++ b/config_test.go @@ -3,7 +3,7 @@ package main import ( "encoding/json" - "io/ioutil" + "io" "net/http" "testing" @@ -113,7 +113,7 @@ func TestServer(t *testing.T) { if res.StatusCode != http.StatusOK { t.Error("invalid status code") } - response, err := ioutil.ReadAll(res.Body) + response, err := io.ReadAll(res.Body) if err != nil { t.Error(err) } @@ -148,7 +148,7 @@ func TestServer(t *testing.T) { if res.StatusCode != http.StatusNotFound { t.Error("invalid status code") } - response, err := ioutil.ReadAll(res.Body) + response, err := io.ReadAll(res.Body) if err != nil { t.Error(err) } diff --git a/go.mod b/go.mod index 45089e0..7928cad 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/bryk-io/go-vanity -go 1.13 +go 1.16 require gopkg.in/yaml.v2 v2.4.0 diff --git a/main.go b/main.go index 9e7585e..baca204 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" "log" "net/http" "os" @@ -26,7 +25,7 @@ func main() { } // Read configuration file - contents, err := ioutil.ReadFile(filepath.Clean(file)) + contents, err := os.ReadFile(filepath.Clean(file)) if err != nil { fmt.Println("failed to read configuration file: ", err) os.Exit(-1) diff --git a/version.go b/version.go index 378b039..fa93dd9 100644 --- a/version.go +++ b/version.go @@ -18,6 +18,7 @@ func versionInfo() map[string]string { "build_code": buildCode, "os": fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), "go": runtime.Version(), + "release": releaseCode(), } if buildTimestamp != "" { rd, err := time.Parse(time.RFC3339, buildTimestamp) @@ -27,3 +28,14 @@ func versionInfo() map[string]string { } return components } + +func releaseCode() string { + release := "govanity" + if coreVersion != "" { + release += "@" + coreVersion + } + if buildCode != "" { + release += "+" + buildCode + } + return release +}