diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 169e1252..e1a2d5ec 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 - name: Check out code into the Go module directory uses: actions/checkout@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f9a3f5a..588481de 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 - name: Check out code into the Go module directory uses: actions/checkout@v2 diff --git a/.golangci.yml b/.golangci.yml index f90891cf..5fd1ecd0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,6 +14,10 @@ linters-settings: ignorePackageGlobs: - github.com/satisfactorymodding/smr-api/* +issues: + exclude: + - should pass the context parameter + linters: disable-all: true enable: diff --git a/cmd/validate-zip/main.go b/cmd/validate-zip/main.go index 6b5cf904..ea1707d3 100644 --- a/cmd/validate-zip/main.go +++ b/cmd/validate-zip/main.go @@ -2,7 +2,6 @@ package main import ( "context" - "io/ioutil" "os" "github.com/satisfactorymodding/smr-api/validation" @@ -13,7 +12,7 @@ func main() { return } - f, _ := ioutil.ReadFile(os.Args[1]) + f, _ := os.ReadFile(os.Args[1]) validation.InitializeValidator() _, err := validation.ExtractModInfo(context.Background(), f, true, true, "N/A") diff --git a/go.mod b/go.mod index 2fd1a19c..a6b1b8ec 100755 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/satisfactorymodding/smr-api -go 1.18 +go 1.19 require ( github.com/99designs/gqlgen v0.17.5 @@ -31,6 +31,7 @@ require ( github.com/spf13/viper v1.11.0 github.com/swaggo/echo-swagger v1.3.2 github.com/swaggo/swag v1.8.1 + github.com/vektah/gqlparser/v2 v2.4.2 github.com/vmihailenco/taskq/extra/taskqotel/v3 v3.2.8 github.com/vmihailenco/taskq/v3 v3.2.8 github.com/xeipuuv/gojsonschema v1.2.0 @@ -42,6 +43,7 @@ require ( go.opentelemetry.io/otel/sdk v1.7.0 go.opentelemetry.io/otel/trace v1.7.0 golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 gopkg.in/go-playground/validator.v9 v9.31.0 gorm.io/driver/postgres v1.3.5 @@ -126,7 +128,6 @@ require ( github.com/urfave/cli/v2 v2.4.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.1 // indirect - github.com/vektah/gqlparser/v2 v2.4.2 // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/x448/float16 v0.8.4 // indirect @@ -137,7 +138,6 @@ require ( go.uber.org/atomic v1.7.0 // indirect golang.org/x/exp v0.0.0-20210220032938-85be41e4509f // indirect golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect diff --git a/go.sum b/go.sum index 65ae0431..c7d53805 100755 --- a/go.sum +++ b/go.sum @@ -25,7 +25,6 @@ cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.88.0/go.mod h1:dnKwfYbP9hQhefiUvpbcAyoGSHUrOxR20JVElLiUvEY= cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= @@ -160,7 +159,6 @@ github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdK github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/avast/retry-go/v3 v3.1.1 h1:49Scxf4v8PmiQ/nY0aY3p0hDueqSmc7++cBbtiDGu2g= @@ -699,10 +697,8 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210715191844-86eeefc3e471/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -751,7 +747,6 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= @@ -1114,7 +1109,6 @@ github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6 github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -1361,9 +1355,7 @@ go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= -go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= -go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= go.etcd.io/etcd/pkg/v3 v3.5.0/go.mod h1:UzJGatBQ1lXChBkQF0AuAtkRQMYnHubxAEYIrC3MSsE= @@ -1456,7 +1448,6 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -1580,13 +1571,13 @@ golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -1996,8 +1987,6 @@ google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+n google.golang.org/genproto v0.0.0-20210630183607-d20f26d13c79/go.mod h1:yiaVoXHpRzHGyxV3o4DktVWY4mSUErTKaeEOq6C3t3U= google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210721163202-f1cecdd8b78a/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210726143408-b02e89920bf0/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= diff --git a/gql/resolver_mods.go b/gql/resolver_mods.go index 8d63c89e..f9ececb7 100644 --- a/gql/resolver_mods.go +++ b/gql/resolver_mods.go @@ -3,7 +3,7 @@ package gql import ( "bytes" "context" - "io/ioutil" + "io" "time" "github.com/satisfactorymodding/smr-api/dataloader" @@ -54,7 +54,7 @@ func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) var logoData []byte if mod.Logo != nil { - file, err := ioutil.ReadAll(mod.Logo.File) + file, err := io.ReadAll(mod.Logo.File) if err != nil { return nil, errors.Wrap(err, "failed to read logo file") @@ -127,7 +127,7 @@ func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod gene SetCompatibilityINN(mod.Compatibility, &dbMod.Compatibility) if mod.Logo != nil { - file, err := ioutil.ReadAll(mod.Logo.File) + file, err := io.ReadAll(mod.Logo.File) if err != nil { return nil, errors.Wrap(err, "failed to read logo file") diff --git a/gql/resolver_users.go b/gql/resolver_users.go index d42a106c..a69f1627 100644 --- a/gql/resolver_users.go +++ b/gql/resolver_users.go @@ -7,7 +7,7 @@ import ( "crypto/sha256" "encoding/base64" "encoding/hex" - "io/ioutil" + "io" "net/http" "net/url" @@ -35,7 +35,7 @@ func (r *mutationResolver) UpdateUser(ctx context.Context, userID string, input } if input.Avatar != nil { - file, err := ioutil.ReadAll(input.Avatar.File) + file, err := io.ReadAll(input.Avatar.File) if err != nil { return nil, errors.Wrap(err, "failed to read avatar file") diff --git a/gql/resolver_versions.go b/gql/resolver_versions.go index c6430626..2d939597 100644 --- a/gql/resolver_versions.go +++ b/gql/resolver_versions.go @@ -3,7 +3,7 @@ package gql import ( "bytes" "context" - "io/ioutil" + "io" "runtime/debug" "time" @@ -71,7 +71,7 @@ func (r *mutationResolver) UploadVersionPart(ctx context.Context, modID string, } // TODO Optimize - fileData, err := ioutil.ReadAll(file.File) + fileData, err := io.ReadAll(file.File) if err != nil { return false, errors.Wrap(err, "failed to read file") diff --git a/gql/versions.go b/gql/versions.go index 2f728378..a4f1dc18 100644 --- a/gql/versions.go +++ b/gql/versions.go @@ -3,7 +3,7 @@ package gql import ( "context" "encoding/json" - "io/ioutil" + "io" "time" "github.com/satisfactorymodding/smr-api/db/postgres" @@ -38,7 +38,7 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI } // TODO Optimize - fileData, err := ioutil.ReadAll(modFile) + fileData, err := io.ReadAll(modFile) if err != nil { storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) diff --git a/integrations/discord.go b/integrations/discord.go index c9234ce8..f2ea0aa0 100644 --- a/integrations/discord.go +++ b/integrations/discord.go @@ -6,7 +6,6 @@ import ( "encoding/json" "html" "io" - "io/ioutil" "net/http" "runtime/debug" "strings" @@ -76,7 +75,7 @@ func NewMod(ctx context.Context, mod *postgres.Mod) { _ = Body.Close() }(res.Body) - _, _ = ioutil.ReadAll(res.Body) + _, _ = io.ReadAll(res.Body) } func NewVersion(ctx context.Context, version *postgres.Version) { @@ -161,5 +160,5 @@ func NewVersion(ctx context.Context, version *postgres.Version) { _ = Body.Close() }(res.Body) - _, _ = ioutil.ReadAll(res.Body) + _, _ = io.ReadAll(res.Body) } diff --git a/oauth/facebook.go b/oauth/facebook.go index c361d9e1..db3cf33d 100644 --- a/oauth/facebook.go +++ b/oauth/facebook.go @@ -2,7 +2,7 @@ package oauth import ( "encoding/json" - "io/ioutil" + "io" "github.com/satisfactorymodding/smr-api/redis" @@ -34,7 +34,7 @@ func FacebookCallback(code string, state string) (*UserData, error) { return nil, errors.Wrap(err, "failed to get user data") } - bytes, err := ioutil.ReadAll(resp.Body) + bytes, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrap(err, "failed to read response body") diff --git a/oauth/github.go b/oauth/github.go index f0518d18..581f410f 100644 --- a/oauth/github.go +++ b/oauth/github.go @@ -2,7 +2,7 @@ package oauth import ( "encoding/json" - "io/ioutil" + "io" "strconv" "github.com/satisfactorymodding/smr-api/redis" @@ -31,7 +31,7 @@ func GithubCallback(code string, state string) (*UserData, error) { return nil, errors.Wrap(err, "failed to get user data") } - bytes, err := ioutil.ReadAll(resp.Body) + bytes, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrap(err, "failed to read user data") @@ -50,7 +50,7 @@ func GithubCallback(code string, state string) (*UserData, error) { return nil, errors.Wrap(err, "failed to get user emails") } - bytes, err = ioutil.ReadAll(resp.Body) + bytes, err = io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrap(err, "failed to read user emails") diff --git a/oauth/google.go b/oauth/google.go index d2092f4f..c23494b3 100644 --- a/oauth/google.go +++ b/oauth/google.go @@ -2,7 +2,7 @@ package oauth import ( "encoding/json" - "io/ioutil" + "io" "github.com/satisfactorymodding/smr-api/redis" @@ -33,7 +33,7 @@ func GoogleCallback(code string, state string) (*UserData, error) { return nil, errors.Wrap(err, "failed to get user info") } - bytes, err := ioutil.ReadAll(resp.Body) + bytes, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrap(err, "failed to read user info") diff --git a/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go b/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go index 0f499b22..46d4d7df 100644 --- a/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go +++ b/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go @@ -6,7 +6,6 @@ import ( "context" "encoding/json" "io" - "io/ioutil" "net/http" "path" "time" @@ -44,7 +43,7 @@ func ScanModOnVirusTotalConsumer(ctx context.Context, payload []byte) error { response, _ := http.Get(link) - fileData, err := ioutil.ReadAll(response.Body) + fileData, err := io.ReadAll(response.Body) if err != nil { return errors.Wrap(err, "failed to read mod file") diff --git a/redis/jobs/consumers/utils.go b/redis/jobs/consumers/utils.go index 31ae1323..042c87ff 100644 --- a/redis/jobs/consumers/utils.go +++ b/redis/jobs/consumers/utils.go @@ -3,7 +3,7 @@ package consumers import ( "context" "encoding/json" - "io/ioutil" + "io" "net/http" "github.com/satisfactorymodding/smr-api/db/postgres" @@ -24,7 +24,7 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin response, _ := http.Get(link) - fileData, err := ioutil.ReadAll(response.Body) + fileData, err := io.ReadAll(response.Body) if err != nil { return errors.Wrap(err, "failed to read response body") diff --git a/storage/b2.go b/storage/b2.go index ceb1f746..98d574c9 100644 --- a/storage/b2.go +++ b/storage/b2.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go/service/s3/s3manager" "github.com/pkg/errors" "github.com/rs/zerolog/log" + "github.com/satisfactorymodding/smr-api/redis" "github.com/aws/aws-sdk-go/aws" @@ -69,7 +70,7 @@ func (b2o *B2) Put(ctx context.Context, key string, body io.ReadSeeker) (string, cleanedKey := strings.TrimPrefix(key, "/") uploader := s3manager.NewUploader(b2o.S3Session) - _, err := uploader.Upload(&s3manager.UploadInput{ + _, err := uploader.UploadWithContext(ctx, &s3manager.UploadInput{ Body: body, Bucket: aws.String(b2o.Config.Bucket), Key: aws.String(cleanedKey), diff --git a/storage/s3.go b/storage/s3.go index 41aa84e9..4a2b6d30 100644 --- a/storage/s3.go +++ b/storage/s3.go @@ -72,7 +72,7 @@ func (s3o *S3) Put(ctx context.Context, key string, body io.ReadSeeker) (string, uploader := s3manager.NewUploader(s3o.S3Session) - _, err := uploader.Upload(&s3manager.UploadInput{ + _, err := uploader.UploadWithContext(ctx, &s3manager.UploadInput{ Body: body, Bucket: aws.String(viper.GetString("storage.bucket")), Key: aws.String(cleanedKey), diff --git a/util/image.go b/util/image.go index 9825ea14..dc355eae 100644 --- a/util/image.go +++ b/util/image.go @@ -2,17 +2,13 @@ package util import ( "context" - // GIF Support _ "image/gif" - // JPEG Support _ "image/jpeg" - // PNG Support _ "image/png" - - "io/ioutil" + "io" "net/http" "github.com/satisfactorymodding/smr-api/util/converter" @@ -31,7 +27,7 @@ func LinkToWebp(ctx context.Context, url string) ([]byte, error) { return nil, errors.New("invalid url") } - imageAsBytes, err := ioutil.ReadAll(resp.Body) + imageAsBytes, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.New("invalid url") diff --git a/validation/paks_test.go b/validation/paks_test.go index 6d31c40b..d4167cbf 100644 --- a/validation/paks_test.go +++ b/validation/paks_test.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -32,7 +31,7 @@ func TestExtractDataFromPak(t *testing.T) { for _, f := range paks { fmt.Println("Parsing file:", f) - data, err := ioutil.ReadFile(f) + data, err := os.ReadFile(f) if err != nil { panic(err) @@ -50,7 +49,7 @@ func TestExtractDataFromPak(t *testing.T) { } else { marshal, _ := json.MarshalIndent(pakData, "", " ") - if err := ioutil.WriteFile(f+".json", marshal, 0644); err != nil { + if err := os.WriteFile(f+".json", marshal, 0644); err != nil { t.Error(err) } } diff --git a/validation/validation.go b/validation/validation.go index 19e72938..ab40c111 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -9,7 +9,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "path/filepath" "strconv" "strings" @@ -119,7 +118,7 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal break } - pakData, err := ioutil.ReadAll(data) + pakData, err := io.ReadAll(data) if err != nil { log.Err(err).Msg("failed reading archive file") @@ -178,7 +177,7 @@ func validateDataJSON(archive *zip.Reader, dataFile *zip.File, withValidation bo return nil, errors.New("invalid zip archive") } - dataJSON, err := ioutil.ReadAll(rc) + dataJSON, err := io.ReadAll(rc) if err != nil { return nil, errors.New("invalid zip archive") @@ -277,7 +276,7 @@ func validateUPluginJSON(archive *zip.Reader, uPluginFile *zip.File, withValidat return nil, errors.New("invalid zip archive") } - uPluginJSON, err := ioutil.ReadAll(rc) + uPluginJSON, err := io.ReadAll(rc) if err != nil { return nil, errors.New("invalid zip archive")