Skip to content

Commit

Permalink
Merge pull request #8 from to-lz1/update_go_to_1_19_1
Browse files Browse the repository at this point in the history
update go 1.19.1
  • Loading branch information
hirosassa authored Sep 7, 2022
2 parents e92f605 + 1ca1d1a commit ef901e4
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 58 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/client-js-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: client/js/node_modules
key: ${{ runner.os }}-clinet-js-modules-${{ hashFiles('client/js/yarn.lock') }}
Expand All @@ -27,16 +27,16 @@ jobs:

runs-on: ubuntu-latest
env:
go-version: 1.18.3
go-version: 1.19.1

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: ${{ env.go-version }}

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: client/js/node_modules
key: ${{ runner.os }}-clinet-js-modules-${{ hashFiles('client/js/yarn.lock') }}
Expand All @@ -56,7 +56,7 @@ jobs:
pushd client/js
DSPS_BASE_URL="http://localhost:3000/" yarn test:ci
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: coverage
path: client/js/coverage
6 changes: 3 additions & 3 deletions .github/workflows/release-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.18.3
go-version: 1.19.1
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v3
with:
version: latest
workdir: server
Expand All @@ -32,7 +32,7 @@ jobs:
# version=$(echo "${{github.ref}}" | sed 's/^refs\/tags\/v//')
# echo "::set-output name=version::$version"
# - name: Checkout
# uses: actions/checkout@v2
# uses: actions/checkout@v3
# - uses: actions/setup-node@v1
# with:
# node-version: '12.x'
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/server-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:

runs-on: ubuntu-latest
env:
go-version: 1.18.3
go-version: 1.19.1

steps:
- uses: actions/checkout@v2
# Note: golangci/golangci-lint-action caches. Should not use actions/cache@v2 otherwise result in so many "File exists"
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
# Note: golangci/golangci-lint-action caches. Should not use actions/cache@v3 otherwise result in so many "File exists"
- uses: actions/setup-go@v3
with:
go-version: ${{ env.go-version }}
- name: generate
Expand All @@ -24,7 +24,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.46.2
version: v1.49.0
working-directory: server
skip-pkg-cache: true
- name: Other Lint
Expand All @@ -42,7 +42,7 @@ jobs:
name: Server test

runs-on: ubuntu-latest
container: golang:1.18.3-bullseye
container: golang:1.19.1-bullseye
services:
redis:
image: redis:6.0.9
Expand All @@ -55,14 +55,14 @@ jobs:
--health-retries 10
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: /go/pkg/mod # Not ~/go/pkg/mod because "container" is active.
key: ${{ runner.os }}-server-gomod-${{ hashFiles('server/go.sum') }}
restore-keys: |
${{ runner.os }}-server-gomod-
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Test
Expand All @@ -78,7 +78,7 @@ jobs:
run: |
curl -s https://codecov.io/bash > codecov.sh
bash codecov.sh
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: coverage.html
path: server/coverage.html
Expand All @@ -88,16 +88,16 @@ jobs:

runs-on: ubuntu-latest
env:
go-version: 1.18.3
go-version: 1.19.1

steps:
- uses: actions/checkout@v2
# Note: golangci/golangci-lint-action caches. Should not use actions/cache@v2 otherwise result in so many "File exists"
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
# Note: golangci/golangci-lint-action caches. Should not use actions/cache@v3 otherwise result in so many "File exists"
- uses: actions/setup-go@v3
with:
go-version: ${{ env.go-version }}
- name: build
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v3
with:
version: latest
workdir: server
Expand Down
3 changes: 3 additions & 0 deletions server/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ run:

issues:
exclude-use-default: false
exclude:
# https://golangci-lint.run/usage/false-positives/#exc0015
- "should have a package comment"

linters:
enable:
Expand Down
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18.3
FROM golang:1.19.1
ARG DSPS_VERSION_ID=""
WORKDIR /go/src/github.com/dsps/server
COPY . .
Expand Down
5 changes: 2 additions & 3 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -57,9 +56,9 @@ func LoadConfigFile(ctx context.Context, configFile string, configOverrides Over
case "":
yamlBytes = []byte("")
case "-":
yamlBytes, err = ioutil.ReadAll(os.Stdin)
yamlBytes, err = io.ReadAll(os.Stdin)
default:
yamlBytes, err = ioutil.ReadFile(configFile) //nolint:gosec // Disables G304: Potential file inclusion via variable
yamlBytes, err = os.ReadFile(configFile) //nolint:gosec // Disables G304: Potential file inclusion via variable
}
if err != nil {
return ServerConfig{}, err
Expand Down
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/m3dev/dsps/server

go 1.18
go 1.19

require (
cloud.google.com/go v0.74.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions server/http/middleware/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestPanicHandling(t *testing.T) {
logger.WithTestLogger(t, nil, func(lc *logger.LogCapture) {
res := DoHTTPRequest(t, "GET", server.URL+"/panic-after-200", ``)
assert.Equal(t, 200, res.StatusCode) // After response sent.
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
assert.NoError(t, err)
assert.Equal(t, `{"hi":"hello"}`+"\n", string(body))
assert.NoError(t, res.Body.Close())
Expand Down
4 changes: 2 additions & 2 deletions server/http/router/request.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package router

import (
"io/ioutil"
"io"
"net/http"
)

Expand All @@ -14,7 +14,7 @@ type Request struct {
func (req Request) ReadBody() ([]byte, error) {
// > The Server will close the request body. The ServeHTTP Handler does not need to.
// https://golang.org/pkg/net/http/#ResponseWriter
return ioutil.ReadAll(req.Body)
return io.ReadAll(req.Body)
}

// GetQueryParam returns URL query parameter or ""
Expand Down
4 changes: 2 additions & 2 deletions server/http/testing/http_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package testing

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

Expand Down Expand Up @@ -52,7 +52,7 @@ func BodyJSONMapOfRes(t *testing.T, res *http.Response) map[string]interface{} {
func BodyJSONOfRes(t *testing.T, res *http.Response, body interface{}) {
assert.Regexp(t, "application/json(;|$)", res.Header.Get("Content-Type"))

raw, err := ioutil.ReadAll(res.Body)
raw, err := io.ReadAll(res.Body)
assert.NoError(t, err)
assert.NoError(t, res.Body.Close())
assert.NoError(t, json.Unmarshal(raw, body), "failed to parse response JSON: %s", string(raw))
Expand Down
4 changes: 2 additions & 2 deletions server/jwt/signing_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package jwt

import (
"fmt"
"io/ioutil"
"os"

jwtgo "github.com/dgrijalva/jwt-go/v4"

Expand All @@ -27,7 +27,7 @@ func LoadKey(alg domain.JwtAlg, keyFilePath string, privateKey bool) (interface{
}

parserWrapper := func(f func(bytes []byte) (interface{}, error)) (interface{}, error) {
bytes, err := ioutil.ReadFile(keyFilePath) //nolint:gosec // Only loads file specified by server configuration file
bytes, err := os.ReadFile(keyFilePath) //nolint:gosec // Only loads file specified by server configuration file
if err != nil {
return nil, fmt.Errorf(`failed to read JWT key file "%s": %w`, keyFilePath, err)
}
Expand Down
7 changes: 4 additions & 3 deletions server/jwt/validator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package validator_test

import (
"context"
"io/ioutil"
"os"

"testing"
"time"

Expand Down Expand Up @@ -38,12 +39,12 @@ func TestPregeneratedJwt(t *testing.T) {
v := createDefaultValidator(t)

// Valid JWT
jwt, err := ioutil.ReadFile("../testdata/RS256-2048bit.jwt")
jwt, err := os.ReadFile("../testdata/RS256-2048bit.jwt")
assert.NoError(t, err)
assert.NoError(t, v.Validate(ctx, string(jwt)))

// Expired JWT
jwt, err = ioutil.ReadFile("../testdata/RS256-2048bit-expired.jwt")
jwt, err = os.ReadFile("../testdata/RS256-2048bit-expired.jwt")
assert.NoError(t, err)
err = v.Validate(ctx, string(jwt))
assert.Error(t, err)
Expand Down
5 changes: 2 additions & 3 deletions server/testing/file_utils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package testing

import (
"io/ioutil"
"os"
"testing"

Expand All @@ -10,10 +9,10 @@ import (

// WithTextFile creates temporary text file
func WithTextFile(t *testing.T, content string, f func(filename string)) {
file, err := ioutil.TempFile(os.TempDir(), "dsps-test-*.txt")
file, err := os.CreateTemp(os.TempDir(), "dsps-test-*.txt")
assert.NoError(t, err)
defer assert.NoError(t, os.Remove(file.Name()))

assert.NoError(t, ioutil.WriteFile(file.Name(), []byte(content), os.ModePerm))
assert.NoError(t, os.WriteFile(file.Name(), []byte(content), os.ModePerm))
f(file.Name())
}
4 changes: 2 additions & 2 deletions server/webhook/outgoing/client_multiplexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"sync"
Expand All @@ -21,7 +21,7 @@ func TestNewMultiplexClient(t *testing.T) {
received := []domain.Message{}
responseCodes := []int{}
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
bytes, err := ioutil.ReadAll(r.Body)
bytes, err := io.ReadAll(r.Body)
assert.NoError(t, err)
var msg domain.Message
assert.NoError(t, json.Unmarshal(bytes, &msg))
Expand Down
Loading

0 comments on commit ef901e4

Please sign in to comment.