Skip to content

Commit

Permalink
Remove deprecated 'ioutil' package
Browse files Browse the repository at this point in the history
  • Loading branch information
bcessa committed Aug 13, 2022
1 parent 7b5771a commit a4dac51
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -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:
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
@@ -1,6 +1,7 @@
# Generals
.DS_Store
.idea
.vscode

# Deps
vendor/**
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Expand Up @@ -49,7 +49,6 @@ linters:
- exhaustive
- forcetypeassert
- godot
- ifshort
- noctx
- predeclared
- exportloopref
Expand All @@ -58,6 +57,7 @@ linters:
#- wrapcheck
#- nestif
#- funlen
#- ifshort
disable:
- deadcode
- unused
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions config_test.go
Expand Up @@ -3,7 +3,7 @@ package main

import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"testing"

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion 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
3 changes: 1 addition & 2 deletions main.go
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
Expand All @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions version.go
Expand Up @@ -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)
Expand All @@ -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
}

0 comments on commit a4dac51

Please sign in to comment.