From 145abe1f49e5e976eaed12e7524521f333e12de1 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Sun, 31 Mar 2024 14:27:45 -0700 Subject: [PATCH 1/4] Update dependecines and Go version Signed-off-by: Maksym Pavlenko --- go.mod | 20 +++++++++++++++++++- go.sum | 20 -------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 5690f18e..8215de2e 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/mxpv/podsync +go 1.21 + require ( github.com/BrianHicks/finch v0.0.0-20140409222414-419bd73c29ec github.com/aws/aws-sdk-go v1.44.144 @@ -22,4 +24,20 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) -go 1.13 +require ( + github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect + github.com/cespare/xxhash v1.1.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgraph-io/ristretto v0.0.2 // indirect + github.com/dustin/go-humanize v1.0.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/grafov/m3u8 v0.11.1 // indirect + github.com/hashicorp/errwrap v1.0.0 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/net v0.11.0 // indirect + golang.org/x/sys v0.9.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/protobuf v1.28.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum index ffe8f2bf..c4592fc9 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,3 @@ -cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BrianHicks/finch v0.0.0-20140409222414-419bd73c29ec h1:1VPruZMM1WQC7POhjxbZOWK564cuFz1hlpwYW6ocM4E= @@ -87,15 +86,9 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= @@ -108,10 +101,8 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -119,8 +110,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/oauth2 v0.9.0 h1:BPpt2kU7oMRq3kCHAA1tbSEshXRw1LpG2ztgDwrzuAs= @@ -128,7 +117,6 @@ golang.org/x/oauth2 v0.9.0/go.mod h1:qYgFZaFiu6Wg24azG8bdV52QJXJGbZzIIsRCdVKzbLw golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -144,30 +132,22 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 391489a35f2ba1099dfba796145a043ed1f8b5f5 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Sun, 31 Mar 2024 14:35:17 -0700 Subject: [PATCH 2/4] Fix tests and lints Signed-off-by: Maksym Pavlenko --- .golangci.yml | 2 +- pkg/builder/youtube_test.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 45a48588..fde0600a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,7 +15,7 @@ linters: - interfacer - unconvert - maligned - - depguard + # - depguard - nakedret - prealloc - whitespace diff --git a/pkg/builder/youtube_test.go b/pkg/builder/youtube_test.go index 39259b54..03f66ddb 100644 --- a/pkg/builder/youtube_test.go +++ b/pkg/builder/youtube_test.go @@ -43,7 +43,6 @@ func TestYT_BuildFeed(t *testing.T) { require.NoError(t, err) urls := []string{ - "https://youtube.com/user/fxigr1", "https://www.youtube.com/channel/UCupvZG-5ko_eiXAupbDfxWw", "https://www.youtube.com/playlist?list=PLF7tUDhGkiCk_Ne30zu7SJ9gZF9R9ZruE", "https://www.youtube.com/channel/UCK9lZ2lHRBgx2LOcqPifukA", From d8e042a4972fcc8e5f9af11fe94c14dfd9726ba2 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Sun, 31 Mar 2024 16:48:17 -0700 Subject: [PATCH 3/4] Update golangci-lint Signed-off-by: Maksym Pavlenko --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3770ab98..4619d62d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: - uses: actions/checkout@v4 - uses: golangci/golangci-lint-action@v4 with: - version: v1.50.1 + version: v1.57.2 - name: Go mod env: From 7a81903ae8c5cb19c15c84080e1a75b0c47a3799 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Sun, 31 Mar 2024 17:23:42 -0700 Subject: [PATCH 4/4] Replace deprecated function calls Signed-off-by: Maksym Pavlenko --- cmd/podsync/config.go | 4 ++-- cmd/podsync/config_test.go | 3 +-- pkg/db/badger_test.go | 36 ++++++++---------------------------- pkg/fs/local_test.go | 25 ++++++++----------------- pkg/fs/s3_test.go | 4 ++-- pkg/ytdl/ytdl.go | 3 +-- 6 files changed, 22 insertions(+), 53 deletions(-) diff --git a/cmd/podsync/config.go b/cmd/podsync/config.go index 2334a920..43156432 100644 --- a/cmd/podsync/config.go +++ b/cmd/podsync/config.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "io/ioutil" + "os" "path/filepath" "regexp" @@ -54,7 +54,7 @@ type Log struct { // LoadConfig loads TOML configuration from a file path func LoadConfig(path string) (*Config, error) { - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) if err != nil { return nil, errors.Wrapf(err, "failed to read config file: %s", path) } diff --git a/cmd/podsync/config_test.go b/cmd/podsync/config_test.go index c4b13a62..b5de84ac 100644 --- a/cmd/podsync/config_test.go +++ b/cmd/podsync/config_test.go @@ -1,7 +1,6 @@ package main import ( - "io/ioutil" "os" "testing" "time" @@ -235,7 +234,7 @@ data_dir = "/data" func setup(t *testing.T, file string) string { t.Helper() - f, err := ioutil.TempFile("", "") + f, err := os.CreateTemp("", "") require.NoError(t, err) defer f.Close() diff --git a/pkg/db/badger_test.go b/pkg/db/badger_test.go index a188493f..5760bde2 100644 --- a/pkg/db/badger_test.go +++ b/pkg/db/badger_test.go @@ -2,8 +2,6 @@ package db import ( "context" - "io/ioutil" - "os" "testing" "time" @@ -16,23 +14,17 @@ import ( var testCtx = context.TODO() func TestNewBadger(t *testing.T) { - dir, err := ioutil.TempDir("", "podsync-badger-") - require.NoError(t, err) + dir := t.TempDir() db, err := NewBadger(&Config{Dir: dir}) require.NoError(t, err) err = db.Close() assert.NoError(t, err) - - err = os.RemoveAll(dir) - assert.NoError(t, err) } func TestBadger_Version(t *testing.T) { - dir, err := ioutil.TempDir("", "podsync-badger-") - assert.NoError(t, err) - defer os.RemoveAll(dir) + dir := t.TempDir() db, err := NewBadger(&Config{Dir: dir}) require.NoError(t, err) @@ -44,9 +36,7 @@ func TestBadger_Version(t *testing.T) { } func TestBadger_AddFeed(t *testing.T) { - dir, err := ioutil.TempDir("", "podsync-badger-") - assert.NoError(t, err) - defer os.RemoveAll(dir) + dir := t.TempDir() db, err := NewBadger(&Config{Dir: dir}) require.NoError(t, err) @@ -58,9 +48,7 @@ func TestBadger_AddFeed(t *testing.T) { } func TestBadger_GetFeed(t *testing.T) { - dir, err := ioutil.TempDir("", "podsync-badger-") - assert.NoError(t, err) - defer os.RemoveAll(dir) + dir := t.TempDir() db, err := NewBadger(&Config{Dir: dir}) require.NoError(t, err) @@ -78,9 +66,7 @@ func TestBadger_GetFeed(t *testing.T) { } func TestBadger_WalkFeeds(t *testing.T) { - dir, err := ioutil.TempDir("", "podsync-badger-") - assert.NoError(t, err) - defer os.RemoveAll(dir) + dir := t.TempDir() db, err := NewBadger(&Config{Dir: dir}) require.NoError(t, err) @@ -104,9 +90,7 @@ func TestBadger_WalkFeeds(t *testing.T) { } func TestBadger_DeleteFeed(t *testing.T) { - dir, err := ioutil.TempDir("", "podsync-badger-") - assert.NoError(t, err) - defer os.RemoveAll(dir) + dir := t.TempDir() db, err := NewBadger(&Config{Dir: dir}) require.NoError(t, err) @@ -129,9 +113,7 @@ func TestBadger_DeleteFeed(t *testing.T) { } func TestBadger_UpdateEpisode(t *testing.T) { - dir, err := ioutil.TempDir("", "podsync-badger-") - assert.NoError(t, err) - defer os.RemoveAll(dir) + dir := t.TempDir() db, err := NewBadger(&Config{Dir: dir}) require.NoError(t, err) @@ -159,9 +141,7 @@ func TestBadger_UpdateEpisode(t *testing.T) { } func TestBadger_WalkEpisodes(t *testing.T) { - dir, err := ioutil.TempDir("", "podsync-badger-") - assert.NoError(t, err) - defer os.RemoveAll(dir) + dir := t.TempDir() db, err := NewBadger(&Config{Dir: dir}) require.NoError(t, err) diff --git a/pkg/fs/local_test.go b/pkg/fs/local_test.go index b20ca01b..4329886e 100644 --- a/pkg/fs/local_test.go +++ b/pkg/fs/local_test.go @@ -3,13 +3,11 @@ package fs import ( "bytes" "context" - "io/ioutil" "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) var ( @@ -23,10 +21,8 @@ func TestNewLocal(t *testing.T) { } func TestLocal_Create(t *testing.T) { - tmpDir, err := ioutil.TempDir("", "podsync-local-stor-") - require.NoError(t, err) - - defer os.RemoveAll(tmpDir) + tmpDir, err := os.MkdirTemp("", "") + assert.NoError(t, err) stor, err := NewLocal(tmpDir) assert.NoError(t, err) @@ -41,8 +37,8 @@ func TestLocal_Create(t *testing.T) { } func TestLocal_Size(t *testing.T) { - tmpDir, err := ioutil.TempDir("", "podsync-local-stor-") - require.NoError(t, err) + tmpDir, err := os.MkdirTemp("", "") + assert.NoError(t, err) defer os.RemoveAll(tmpDir) @@ -66,10 +62,8 @@ func TestLocal_NoSize(t *testing.T) { } func TestLocal_Delete(t *testing.T) { - tmpDir, err := ioutil.TempDir("", "podsync-local-stor-") - require.NoError(t, err) - - defer os.RemoveAll(tmpDir) + tmpDir, err := os.MkdirTemp("", "") + assert.NoError(t, err) stor, err := NewLocal(tmpDir) assert.NoError(t, err) @@ -89,11 +83,8 @@ func TestLocal_Delete(t *testing.T) { func TestLocal_copyFile(t *testing.T) { reader := bytes.NewReader([]byte{1, 2, 4}) - - tmpDir, err := ioutil.TempDir("", "podsync-test-") - require.NoError(t, err) - - defer os.RemoveAll(tmpDir) + tmpDir, err := os.MkdirTemp("", "") + assert.NoError(t, err) file := filepath.Join(tmpDir, "1") diff --git a/pkg/fs/s3_test.go b/pkg/fs/s3_test.go index ea403366..d5e56dcf 100644 --- a/pkg/fs/s3_test.go +++ b/pkg/fs/s3_test.go @@ -2,7 +2,7 @@ package fs import ( "bytes" - "io/ioutil" + "io" "os" "testing" @@ -98,7 +98,7 @@ func newMockS3(files map[string][]byte, prefix string) (*S3, error) { } func (m *mockS3API) PutObjectRequest(input *s3.PutObjectInput) (*request.Request, *s3.PutObjectOutput) { - content, _ := ioutil.ReadAll(input.Body) + content, _ := io.ReadAll(input.Body) req := request.New(aws.Config{}, metadata.ClientInfo{}, request.Handlers{}, nil, &request.Operation{}, nil, nil) m.files[*input.Key] = content return req, &s3.PutObjectOutput{} diff --git a/pkg/ytdl/ytdl.go b/pkg/ytdl/ytdl.go index 1d33a928..d641a657 100644 --- a/pkg/ytdl/ytdl.go +++ b/pkg/ytdl/ytdl.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "net/http" "os" "os/exec" @@ -158,7 +157,7 @@ func (dl *YoutubeDl) Update(ctx context.Context) error { } func (dl *YoutubeDl) Download(ctx context.Context, feedConfig *feed.Config, episode *model.Episode) (r io.ReadCloser, err error) { - tmpDir, err := ioutil.TempDir("", "podsync-") + tmpDir, err := os.MkdirTemp("", "podsync-") if err != nil { return nil, errors.Wrap(err, "failed to get temp dir for download") }