From 19a5e73c192dadc3bab02b7c674c52e6fbd065ef Mon Sep 17 00:00:00 2001 From: l3uddz Date: Fri, 1 Apr 2022 20:42:05 +0100 Subject: [PATCH] refactor: imports --- cache/cache.go | 3 ++- cache/delete.go | 1 + cache/delete_test.go | 3 ++- cache/get.go | 1 + cache/get_test.go | 3 ++- cache/put.go | 3 ++- cache/put_test.go | 3 ++- cache/test.go | 3 ++- cmd/nabarr/config.go | 5 +++-- cmd/nabarr/config_windows.go | 3 ++- cmd/nabarr/main.go | 11 ++++++----- cmd/nabarr/pvr/pvr.go | 3 ++- cmd/nabarr/shutdown.go | 3 ++- cmd/nabarr/update.go | 3 ++- cmd/nabarr/version.go | 1 + go.sum | 1 - media/client.go | 1 + media/movie.go | 3 ++- media/omdb/media.go | 5 +++-- media/omdb/omdb.go | 5 +++-- media/show.go | 3 ++- media/struct.go | 5 +++-- media/trakt/media.go | 3 ++- media/trakt/trakt.go | 5 +++-- media/tvdb/media.go | 1 + media/tvdb/tvdb.go | 5 +++-- nabarr.go | 3 ++- radarr/api.go | 7 ++++--- radarr/expression.go | 1 + radarr/queue.go | 1 + radarr/radarr.go | 7 ++++--- rss/job.go | 3 ++- rss/process.go | 5 +++-- rss/rss.go | 3 ++- rss/struct.go | 5 +++-- sonarr/api.go | 7 ++++--- sonarr/expression.go | 1 + sonarr/queue.go | 3 ++- sonarr/sonarr.go | 7 ++++--- util/http.go | 5 +++-- 40 files changed, 91 insertions(+), 53 deletions(-) diff --git a/cache/cache.go b/cache/cache.go index 9d5b23a..95bafae 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -3,11 +3,12 @@ package cache import ( "context" "fmt" + "time" + "github.com/dgraph-io/badger/v3" "github.com/l3uddz/nabarr/logger" "github.com/lefelys/state" "github.com/rs/zerolog" - "time" ) type Client struct { diff --git a/cache/delete.go b/cache/delete.go index 232534a..bab2121 100644 --- a/cache/delete.go +++ b/cache/delete.go @@ -2,6 +2,7 @@ package cache import ( "fmt" + "github.com/dgraph-io/badger/v3" ) diff --git a/cache/delete_test.go b/cache/delete_test.go index ade8025..7b86499 100644 --- a/cache/delete_test.go +++ b/cache/delete_test.go @@ -1,8 +1,9 @@ package cache import ( - "github.com/rs/zerolog" "testing" + + "github.com/rs/zerolog" ) func TestClient_Delete(t *testing.T) { diff --git a/cache/get.go b/cache/get.go index 0c21ca8..9639bdc 100644 --- a/cache/get.go +++ b/cache/get.go @@ -2,6 +2,7 @@ package cache import ( "fmt" + "github.com/dgraph-io/badger/v3" ) diff --git a/cache/get_test.go b/cache/get_test.go index c46ba4e..f93dbda 100644 --- a/cache/get_test.go +++ b/cache/get_test.go @@ -1,10 +1,11 @@ package cache import ( - "github.com/rs/zerolog" "reflect" "testing" "time" + + "github.com/rs/zerolog" ) func TestClient_Get(t *testing.T) { diff --git a/cache/put.go b/cache/put.go index e26742d..d9e0cf3 100644 --- a/cache/put.go +++ b/cache/put.go @@ -2,8 +2,9 @@ package cache import ( "fmt" - "github.com/dgraph-io/badger/v3" "time" + + "github.com/dgraph-io/badger/v3" ) func (c *Client) Put(bucket string, key string, val []byte, ttl time.Duration) error { diff --git a/cache/put_test.go b/cache/put_test.go index b7d91b5..865ef86 100644 --- a/cache/put_test.go +++ b/cache/put_test.go @@ -1,10 +1,11 @@ package cache import ( - "github.com/rs/zerolog" "reflect" "testing" "time" + + "github.com/rs/zerolog" ) func TestClient_Put(t *testing.T) { diff --git a/cache/test.go b/cache/test.go index 2dda910..0365c5e 100644 --- a/cache/test.go +++ b/cache/test.go @@ -1,8 +1,9 @@ package cache import ( - "github.com/dgraph-io/badger/v3" "testing" + + "github.com/dgraph-io/badger/v3" ) func newDb(t *testing.T) *badger.DB { diff --git a/cmd/nabarr/config.go b/cmd/nabarr/config.go index 0b7eb99..78feec6 100644 --- a/cmd/nabarr/config.go +++ b/cmd/nabarr/config.go @@ -3,10 +3,11 @@ package main import ( - "github.com/kirsle/configdir" - "golang.org/x/sys/unix" "os" "path/filepath" + + "github.com/kirsle/configdir" + "golang.org/x/sys/unix" ) func defaultConfigPath() string { diff --git a/cmd/nabarr/config_windows.go b/cmd/nabarr/config_windows.go index 575375d..147e027 100644 --- a/cmd/nabarr/config_windows.go +++ b/cmd/nabarr/config_windows.go @@ -3,9 +3,10 @@ package main import ( "errors" "fmt" - "github.com/kirsle/configdir" "os" "path/filepath" + + "github.com/kirsle/configdir" ) func defaultConfigPath() string { diff --git a/cmd/nabarr/main.go b/cmd/nabarr/main.go index df836f9..320ab4e 100644 --- a/cmd/nabarr/main.go +++ b/cmd/nabarr/main.go @@ -3,6 +3,12 @@ package main import ( "context" "fmt" + "io" + "os" + "path/filepath" + "strings" + "time" + "github.com/alecthomas/kong" "github.com/goccy/go-yaml" "github.com/l3uddz/nabarr" @@ -15,11 +21,6 @@ import ( "github.com/natefinch/lumberjack" "github.com/rs/zerolog" "github.com/rs/zerolog/log" - "io" - "os" - "path/filepath" - "strings" - "time" ) type config struct { diff --git a/cmd/nabarr/pvr/pvr.go b/cmd/nabarr/pvr/pvr.go index 675ff1a..29e852e 100644 --- a/cmd/nabarr/pvr/pvr.go +++ b/cmd/nabarr/pvr/pvr.go @@ -2,13 +2,14 @@ package pvr import ( "errors" + "strings" + "github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr/cache" "github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/radarr" "github.com/l3uddz/nabarr/sonarr" "github.com/lefelys/state" - "strings" ) type PVR interface { diff --git a/cmd/nabarr/shutdown.go b/cmd/nabarr/shutdown.go index e073e6b..aaeddf5 100644 --- a/cmd/nabarr/shutdown.go +++ b/cmd/nabarr/shutdown.go @@ -1,10 +1,11 @@ package main import ( - "github.com/rs/zerolog/log" "os" "os/signal" "syscall" + + "github.com/rs/zerolog/log" ) func waitShutdown() { diff --git a/cmd/nabarr/update.go b/cmd/nabarr/update.go index 8435fd3..a3f26bc 100644 --- a/cmd/nabarr/update.go +++ b/cmd/nabarr/update.go @@ -3,11 +3,12 @@ package main import ( "bufio" "fmt" + "os" + "github.com/alecthomas/kong" "github.com/blang/semver" "github.com/l3uddz/nabarr/build" "github.com/rhysd/go-github-selfupdate/selfupdate" - "os" ) type updateFlag string diff --git a/cmd/nabarr/version.go b/cmd/nabarr/version.go index a897f84..af389e2 100644 --- a/cmd/nabarr/version.go +++ b/cmd/nabarr/version.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "github.com/alecthomas/kong" ) diff --git a/go.sum b/go.sum index 681d84c..7726cc0 100644 --- a/go.sum +++ b/go.sum @@ -356,7 +356,6 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220401154927-543a649e0bdd h1:zYlwaUHTmxuf6H7hwO2dgwqozQmH7zf4x+/qql4oVWc= golang.org/x/net v0.0.0-20220401154927-543a649e0bdd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= diff --git a/media/client.go b/media/client.go index 1749568..0130412 100644 --- a/media/client.go +++ b/media/client.go @@ -2,6 +2,7 @@ package media import ( "fmt" + "github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/media/omdb" "github.com/l3uddz/nabarr/media/trakt" diff --git a/media/movie.go b/media/movie.go index b001246..a94f2d8 100644 --- a/media/movie.go +++ b/media/movie.go @@ -3,9 +3,10 @@ package media import ( "errors" "fmt" - "github.com/l3uddz/nabarr/media/trakt" "strconv" "time" + + "github.com/l3uddz/nabarr/media/trakt" ) func (c *Client) GetMovieInfo(item *FeedItem) (*Item, error) { diff --git a/media/omdb/media.go b/media/omdb/media.go index be328ac..4e745ba 100644 --- a/media/omdb/media.go +++ b/media/omdb/media.go @@ -4,10 +4,11 @@ import ( "encoding/json" "errors" "fmt" - "github.com/l3uddz/nabarr/util" - "github.com/lucperkins/rek" "net/url" "strings" + + "github.com/l3uddz/nabarr/util" + "github.com/lucperkins/rek" ) var ( diff --git a/media/omdb/omdb.go b/media/omdb/omdb.go index d979e5a..f84a014 100644 --- a/media/omdb/omdb.go +++ b/media/omdb/omdb.go @@ -1,12 +1,13 @@ package omdb import ( + "net/http" + "time" + "github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/util" "github.com/rs/zerolog" "go.uber.org/ratelimit" - "net/http" - "time" ) type Client struct { diff --git a/media/show.go b/media/show.go index 4ea31cb..8630ace 100644 --- a/media/show.go +++ b/media/show.go @@ -3,8 +3,9 @@ package media import ( "errors" "fmt" - "github.com/l3uddz/nabarr/media/trakt" "strconv" + + "github.com/l3uddz/nabarr/media/trakt" ) func (c *Client) GetShowInfo(item *FeedItem) (*Item, error) { diff --git a/media/struct.go b/media/struct.go index 4b9580b..0af314f 100644 --- a/media/struct.go +++ b/media/struct.go @@ -2,12 +2,13 @@ package media import ( "encoding/xml" + "strings" + "time" + "github.com/l3uddz/nabarr/media/omdb" "github.com/l3uddz/nabarr/media/tvdb" "github.com/l3uddz/nabarr/util" "github.com/pkg/errors" - "strings" - "time" ) /* Media Item(s) */ diff --git a/media/trakt/media.go b/media/trakt/media.go index e5034be..084624a 100644 --- a/media/trakt/media.go +++ b/media/trakt/media.go @@ -4,9 +4,10 @@ import ( "encoding/json" "errors" "fmt" + "net/url" + "github.com/l3uddz/nabarr/util" "github.com/lucperkins/rek" - "net/url" ) var ( diff --git a/media/trakt/trakt.go b/media/trakt/trakt.go index 666f8ee..d3814b0 100644 --- a/media/trakt/trakt.go +++ b/media/trakt/trakt.go @@ -1,12 +1,13 @@ package trakt import ( + "net/http" + "time" + "github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/util" "github.com/rs/zerolog" "go.uber.org/ratelimit" - "net/http" - "time" ) type Client struct { diff --git a/media/tvdb/media.go b/media/tvdb/media.go index 94eefb9..0bc20a0 100644 --- a/media/tvdb/media.go +++ b/media/tvdb/media.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/l3uddz/nabarr/util" "github.com/lucperkins/rek" ) diff --git a/media/tvdb/tvdb.go b/media/tvdb/tvdb.go index a5f889e..614006a 100644 --- a/media/tvdb/tvdb.go +++ b/media/tvdb/tvdb.go @@ -2,12 +2,13 @@ package tvdb import ( "fmt" + "net/http" + "time" + "github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/util" "github.com/rs/zerolog" "go.uber.org/ratelimit" - "net/http" - "time" ) type Client struct { diff --git a/nabarr.go b/nabarr.go index b00818d..178c2cc 100644 --- a/nabarr.go +++ b/nabarr.go @@ -1,9 +1,10 @@ package nabarr import ( + "time" + "github.com/antonmedv/expr/vm" "github.com/l3uddz/nabarr/media" - "time" ) type ExprProgram struct { diff --git a/radarr/api.go b/radarr/api.go index f2762aa..828a0d8 100644 --- a/radarr/api.go +++ b/radarr/api.go @@ -4,13 +4,14 @@ import ( "encoding/json" "errors" "fmt" + "net/url" + "strconv" + "strings" + "github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/util" "github.com/lucperkins/rek" - "net/url" - "strconv" - "strings" ) var ( diff --git a/radarr/expression.go b/radarr/expression.go index 490629b..ab000a1 100644 --- a/radarr/expression.go +++ b/radarr/expression.go @@ -2,6 +2,7 @@ package radarr import ( "fmt" + "github.com/antonmedv/expr" "github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr/media" diff --git a/radarr/queue.go b/radarr/queue.go index 138c124..cd14706 100644 --- a/radarr/queue.go +++ b/radarr/queue.go @@ -3,6 +3,7 @@ package radarr import ( "errors" "fmt" + "github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr/media" "github.com/lefelys/state" diff --git a/radarr/radarr.go b/radarr/radarr.go index 8a48a9d..ff6ee16 100644 --- a/radarr/radarr.go +++ b/radarr/radarr.go @@ -2,15 +2,16 @@ package radarr import ( "fmt" + "net/http" + "strings" + "time" + "github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr/cache" "github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/util" "github.com/rs/zerolog" - "net/http" - "strings" - "time" ) type Client struct { diff --git a/rss/job.go b/rss/job.go index 4c4596a..c2713ba 100644 --- a/rss/job.go +++ b/rss/job.go @@ -2,10 +2,11 @@ package rss import ( "fmt" + "time" + "github.com/l3uddz/nabarr/cmd/nabarr/pvr" "github.com/l3uddz/nabarr/util" "github.com/robfig/cron/v3" - "time" ) func (c *Client) AddJob(feed feedItem) error { diff --git a/rss/process.go b/rss/process.go index a12045a..945150f 100644 --- a/rss/process.go +++ b/rss/process.go @@ -3,11 +3,12 @@ package rss import ( "encoding/xml" "fmt" + "sort" + "strings" + "github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/util" "github.com/lucperkins/rek" - "sort" - "strings" ) func (j *rssJob) process() error { diff --git a/rss/rss.go b/rss/rss.go index e199bc1..5145eb4 100644 --- a/rss/rss.go +++ b/rss/rss.go @@ -1,13 +1,14 @@ package rss import ( + "time" + "github.com/l3uddz/nabarr/cache" "github.com/l3uddz/nabarr/cmd/nabarr/pvr" "github.com/l3uddz/nabarr/logger" "github.com/lefelys/state" "github.com/robfig/cron/v3" "github.com/rs/zerolog" - "time" ) type Client struct { diff --git a/rss/struct.go b/rss/struct.go index f33048f..ae7d312 100644 --- a/rss/struct.go +++ b/rss/struct.go @@ -1,12 +1,13 @@ package rss import ( + "net/http" + "time" + "github.com/l3uddz/nabarr/cache" "github.com/l3uddz/nabarr/cmd/nabarr/pvr" "github.com/robfig/cron/v3" "github.com/rs/zerolog" - "net/http" - "time" ) type feedItem struct { diff --git a/sonarr/api.go b/sonarr/api.go index 0bfc91f..ee9aabc 100644 --- a/sonarr/api.go +++ b/sonarr/api.go @@ -4,13 +4,14 @@ import ( "encoding/json" "errors" "fmt" + "net/url" + "strconv" + "strings" + "github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/util" "github.com/lucperkins/rek" - "net/url" - "strconv" - "strings" ) var ( diff --git a/sonarr/expression.go b/sonarr/expression.go index e04116d..9567209 100644 --- a/sonarr/expression.go +++ b/sonarr/expression.go @@ -2,6 +2,7 @@ package sonarr import ( "fmt" + "github.com/antonmedv/expr" "github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr/media" diff --git a/sonarr/queue.go b/sonarr/queue.go index dcd4369..66cc0da 100644 --- a/sonarr/queue.go +++ b/sonarr/queue.go @@ -3,11 +3,12 @@ package sonarr import ( "errors" "fmt" + "strings" + "github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/util" "github.com/lefelys/state" - "strings" ) func (c *Client) QueueFeedItem(item *media.FeedItem) { diff --git a/sonarr/sonarr.go b/sonarr/sonarr.go index 3df381e..6dd22b7 100644 --- a/sonarr/sonarr.go +++ b/sonarr/sonarr.go @@ -2,15 +2,16 @@ package sonarr import ( "fmt" + "net/http" + "strings" + "time" + "github.com/l3uddz/nabarr" "github.com/l3uddz/nabarr/cache" "github.com/l3uddz/nabarr/logger" "github.com/l3uddz/nabarr/media" "github.com/l3uddz/nabarr/util" "github.com/rs/zerolog" - "net/http" - "strings" - "time" ) type Client struct { diff --git a/util/http.go b/util/http.go index 4cd2c93..d686a14 100644 --- a/util/http.go +++ b/util/http.go @@ -1,12 +1,13 @@ package util import ( + "net/http" + "time" + "github.com/hashicorp/go-retryablehttp" "github.com/l3uddz/nabarr/build" "github.com/rs/zerolog" "go.uber.org/ratelimit" - "net/http" - "time" ) func NewRetryableHttpClient(timeout time.Duration, rl ratelimit.Limiter, log *zerolog.Logger) *http.Client {