From d3c02afe24b408f58cdcc58d12b1a8db82d02e65 Mon Sep 17 00:00:00 2001 From: iyear Date: Sun, 20 Aug 2023 21:00:06 +0800 Subject: [PATCH] chore(prj): optimize imports --- app/archive/backup.go | 8 +++++--- app/archive/recover.go | 8 +++++--- app/chat/export.go | 12 +++++++----- app/chat/ls.go | 14 ++++++++------ app/chat/message.go | 1 + app/chat/message_test.go | 3 ++- app/dl/dl.go | 8 +++++--- app/dl/files.go | 12 +++++++----- app/dl/urls.go | 4 +++- app/internal/dliter/iter.go | 8 +++++--- app/internal/dliter/types.go | 10 ++++++---- app/internal/dliter/util.go | 3 ++- app/internal/tgc/run.go | 4 +++- app/internal/tgc/tgc.go | 12 +++++++----- app/login/auth.go | 3 ++- app/login/code.go | 6 ++++-- app/login/desktop.go | 10 ++++++---- app/up/iter.go | 8 +++++--- app/up/up.go | 4 +++- app/up/walk.go | 5 +++-- cmd/archive.go | 6 ++++-- cmd/chat.go | 6 ++++-- cmd/dl.go | 8 +++++--- cmd/login.go | 3 ++- cmd/root.go | 16 +++++++++------- cmd/up.go | 3 ++- cmd/version.go | 8 +++++--- main.go | 6 ++++-- pkg/clock/clock.go | 3 ++- pkg/dcpool/dcpool.go | 8 +++++--- pkg/downloader/downloader.go | 22 ++++++++++++---------- pkg/downloader/iter.go | 1 + pkg/downloader/ps.go | 6 ++++-- pkg/downloader/write_at.go | 3 ++- pkg/key/key.go | 3 ++- pkg/kv/kv.go | 8 +++++--- pkg/logger/logger.go | 1 + pkg/prog/prog.go | 3 ++- pkg/ps/ps.go | 6 ++++-- pkg/storage/peers.go | 4 +++- pkg/storage/session.go | 2 ++ pkg/storage/state.go | 2 ++ pkg/takeout/middleware.go | 1 + pkg/takeout/takeout.go | 2 ++ pkg/tdesktop/tdesktop.go | 3 ++- pkg/texpr/expr.go | 3 ++- pkg/texpr/fields.go | 3 ++- pkg/texpr/fields_test.go | 3 ++- pkg/tmedia/document.go | 4 +++- pkg/tmedia/media.go | 1 + pkg/tmedia/photo.go | 6 ++++-- pkg/tpath/tpath_linux.go | 3 ++- pkg/tplfunc/string.go | 3 ++- pkg/uploader/progress.go | 1 + pkg/uploader/ps.go | 6 ++++-- pkg/uploader/uploader.go | 10 ++++++---- pkg/utils/cmd.go | 3 ++- pkg/utils/media.go | 3 ++- pkg/utils/proxy.go | 3 ++- pkg/utils/telegram.go | 7 ++++--- test/archive_test.go | 5 +++-- test/chat_ls_test.go | 6 ++++-- test/suite_test.go | 12 +++++++----- test/upload_test.go | 9 +++++---- 64 files changed, 234 insertions(+), 134 deletions(-) diff --git a/app/archive/backup.go b/app/archive/backup.go index dee43c5..88e2d1b 100644 --- a/app/archive/backup.go +++ b/app/archive/backup.go @@ -2,10 +2,12 @@ package archive import ( "context" - "github.com/fatih/color" - "github.com/iyear/tdl/pkg/consts" - "github.com/mholt/archiver/v4" "os" + + "github.com/fatih/color" + "github.com/mholt/archiver/v4" + + "github.com/iyear/tdl/pkg/consts" ) func Backup(ctx context.Context, dst string) error { diff --git a/app/archive/recover.go b/app/archive/recover.go index 0f1bc04..adee16f 100644 --- a/app/archive/recover.go +++ b/app/archive/recover.go @@ -2,12 +2,14 @@ package archive import ( "context" - "github.com/fatih/color" - "github.com/iyear/tdl/pkg/consts" - "github.com/mholt/archiver/v4" "io" "os" "path/filepath" + + "github.com/fatih/color" + "github.com/mholt/archiver/v4" + + "github.com/iyear/tdl/pkg/consts" ) func Recover(ctx context.Context, file string) error { diff --git a/app/chat/export.go b/app/chat/export.go index a4b6c15..2031016 100644 --- a/app/chat/export.go +++ b/app/chat/export.go @@ -4,6 +4,9 @@ import ( "context" "encoding/json" "fmt" + "os" + "time" + "github.com/fatih/color" "github.com/go-faster/jx" "github.com/gotd/contrib/middleware/ratelimit" @@ -11,17 +14,16 @@ import ( "github.com/gotd/td/telegram/query" "github.com/gotd/td/telegram/query/messages" "github.com/gotd/td/tg" + "github.com/jedib0t/go-pretty/v6/progress" + "go.uber.org/multierr" + "golang.org/x/time/rate" + "github.com/iyear/tdl/app/internal/tgc" "github.com/iyear/tdl/pkg/prog" "github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/texpr" "github.com/iyear/tdl/pkg/tmedia" "github.com/iyear/tdl/pkg/utils" - "github.com/jedib0t/go-pretty/v6/progress" - "go.uber.org/multierr" - "golang.org/x/time/rate" - "os" - "time" ) const ( diff --git a/app/chat/ls.go b/app/chat/ls.go index dad8a6f..0b310bd 100644 --- a/app/chat/ls.go +++ b/app/chat/ls.go @@ -4,22 +4,24 @@ import ( "context" "encoding/json" "fmt" + "strconv" + "strings" + "time" + "github.com/gotd/contrib/middleware/ratelimit" "github.com/gotd/td/telegram/message/peer" "github.com/gotd/td/telegram/peers" "github.com/gotd/td/telegram/query" "github.com/gotd/td/tg" + "github.com/mattn/go-runewidth" + "go.uber.org/zap" + "golang.org/x/time/rate" + "github.com/iyear/tdl/app/internal/tgc" "github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/texpr" "github.com/iyear/tdl/pkg/utils" - "github.com/mattn/go-runewidth" - "go.uber.org/zap" - "golang.org/x/time/rate" - "strconv" - "strings" - "time" ) type Dialog struct { diff --git a/app/chat/message.go b/app/chat/message.go index bd020f9..3a08e35 100644 --- a/app/chat/message.go +++ b/app/chat/message.go @@ -2,6 +2,7 @@ package chat import ( "github.com/gotd/td/tg" + "github.com/iyear/tdl/pkg/tmedia" "github.com/iyear/tdl/pkg/utils" ) diff --git a/app/chat/message_test.go b/app/chat/message_test.go index 068ae17..a91bfd4 100644 --- a/app/chat/message_test.go +++ b/app/chat/message_test.go @@ -1,8 +1,9 @@ package chat import ( - "github.com/iyear/tdl/pkg/texpr" "testing" + + "github.com/iyear/tdl/pkg/texpr" ) func TestMessageExpr(t *testing.T) { diff --git a/app/dl/dl.go b/app/dl/dl.go index 5a8afc1..2c15ce4 100644 --- a/app/dl/dl.go +++ b/app/dl/dl.go @@ -5,9 +5,14 @@ import ( "encoding/json" "errors" "fmt" + "github.com/AlecAivazis/survey/v2" "github.com/fatih/color" "github.com/gotd/contrib/middleware/floodwait" + "github.com/spf13/viper" + "go.uber.org/multierr" + "go.uber.org/zap" + "github.com/iyear/tdl/app/internal/dliter" "github.com/iyear/tdl/app/internal/tgc" "github.com/iyear/tdl/pkg/consts" @@ -16,9 +21,6 @@ import ( "github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/logger" - "github.com/spf13/viper" - "go.uber.org/multierr" - "go.uber.org/zap" ) type Options struct { diff --git a/app/dl/files.go b/app/dl/files.go index 0847935..c792a75 100644 --- a/app/dl/files.go +++ b/app/dl/files.go @@ -3,20 +3,22 @@ package dl import ( "context" "errors" + "io" + "os" + "strconv" + "github.com/bcicen/jstream" "github.com/gotd/td/telegram/peers" "github.com/gotd/td/tg" + "github.com/mitchellh/mapstructure" + "go.uber.org/zap" + "github.com/iyear/tdl/app/internal/dliter" "github.com/iyear/tdl/pkg/dcpool" "github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/utils" - "github.com/mitchellh/mapstructure" - "go.uber.org/zap" - "io" - "os" - "strconv" ) const ( diff --git a/app/dl/urls.go b/app/dl/urls.go index 0cc5f81..c77cbba 100644 --- a/app/dl/urls.go +++ b/app/dl/urls.go @@ -2,14 +2,16 @@ package dl import ( "context" + "github.com/gotd/td/telegram/peers" + "go.uber.org/zap" + "github.com/iyear/tdl/app/internal/dliter" "github.com/iyear/tdl/pkg/dcpool" "github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/utils" - "go.uber.org/zap" ) func parseURLs(ctx context.Context, pool dcpool.Pool, kvd kv.KV, urls []string) ([]*dliter.Dialog, error) { diff --git a/app/internal/dliter/iter.go b/app/internal/dliter/iter.go index 4eda11d..83f78ff 100644 --- a/app/internal/dliter/iter.go +++ b/app/internal/dliter/iter.go @@ -5,17 +5,19 @@ import ( "context" "errors" "fmt" + "path/filepath" + "text/template" + "time" + "github.com/gotd/td/telegram/peers" "github.com/gotd/td/telegram/query" "github.com/gotd/td/tg" + "github.com/iyear/tdl/pkg/downloader" "github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/tmedia" "github.com/iyear/tdl/pkg/tplfunc" "github.com/iyear/tdl/pkg/utils" - "path/filepath" - "text/template" - "time" ) func New(ctx context.Context, opts *Options) (*Iter, error) { diff --git a/app/internal/dliter/types.go b/app/internal/dliter/types.go index d5b0b87..4a6eefe 100644 --- a/app/internal/dliter/types.go +++ b/app/internal/dliter/types.go @@ -1,12 +1,14 @@ package dliter import ( - "github.com/gotd/td/telegram/peers" - "github.com/gotd/td/tg" - "github.com/iyear/tdl/pkg/dcpool" - "github.com/iyear/tdl/pkg/kv" "sync" "text/template" + + "github.com/gotd/td/telegram/peers" + "github.com/gotd/td/tg" + + "github.com/iyear/tdl/pkg/dcpool" + "github.com/iyear/tdl/pkg/kv" ) type Options struct { diff --git a/app/internal/dliter/util.go b/app/internal/dliter/util.go index b33a2c4..582e04b 100644 --- a/app/internal/dliter/util.go +++ b/app/internal/dliter/util.go @@ -5,8 +5,9 @@ import ( "crypto/sha256" "encoding/binary" "fmt" - "github.com/iyear/tdl/pkg/utils" "sort" + + "github.com/iyear/tdl/pkg/utils" ) func sortDialogs(dialogs []*Dialog, desc bool) { diff --git a/app/internal/tgc/run.go b/app/internal/tgc/run.go index 1142f5e..48a2757 100644 --- a/app/internal/tgc/run.go +++ b/app/internal/tgc/run.go @@ -3,9 +3,11 @@ package tgc import ( "context" "fmt" + "github.com/gotd/td/telegram" - "github.com/iyear/tdl/pkg/logger" "go.uber.org/zap" + + "github.com/iyear/tdl/pkg/logger" ) func RunWithAuth(ctx context.Context, client *telegram.Client, f func(ctx context.Context) error) error { diff --git a/app/internal/tgc/tgc.go b/app/internal/tgc/tgc.go index a499776..0888b8b 100644 --- a/app/internal/tgc/tgc.go +++ b/app/internal/tgc/tgc.go @@ -3,11 +3,18 @@ package tgc import ( "context" "fmt" + "os" + "path/filepath" + "time" + "github.com/cenkalti/backoff/v4" "github.com/gotd/contrib/middleware/floodwait" tdclock "github.com/gotd/td/clock" "github.com/gotd/td/telegram" "github.com/gotd/td/telegram/dcs" + "github.com/spf13/viper" + "go.uber.org/zap" + "github.com/iyear/tdl/pkg/clock" "github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/key" @@ -15,11 +22,6 @@ import ( "github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/utils" - "github.com/spf13/viper" - "go.uber.org/zap" - "os" - "path/filepath" - "time" ) func New(ctx context.Context, login bool, middlewares ...telegram.Middleware) (*telegram.Client, kv.KV, error) { diff --git a/app/login/auth.go b/app/login/auth.go index 4caf61a..2764ff9 100644 --- a/app/login/auth.go +++ b/app/login/auth.go @@ -3,11 +3,12 @@ package login import ( "context" "errors" + "strings" + "github.com/AlecAivazis/survey/v2" "github.com/fatih/color" "github.com/gotd/td/telegram/auth" "github.com/gotd/td/tg" - "strings" ) // noSignUp can be embedded to prevent signing up. diff --git a/app/login/code.go b/app/login/code.go index 2f03d23..9176bc0 100644 --- a/app/login/code.go +++ b/app/login/code.go @@ -3,15 +3,17 @@ package login import ( "context" "crypto/rand" + "time" + "github.com/cenkalti/backoff/v4" "github.com/fatih/color" "github.com/gotd/td/telegram" "github.com/gotd/td/telegram/auth" + "github.com/spf13/viper" + "github.com/iyear/tdl/app/internal/tgc" "github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/key" - "github.com/spf13/viper" - "time" ) func Code(ctx context.Context) error { diff --git a/app/login/desktop.go b/app/login/desktop.go index 7dfcce3..589067f 100644 --- a/app/login/desktop.go +++ b/app/login/desktop.go @@ -3,10 +3,16 @@ package login import ( "context" "fmt" + "os" + "path/filepath" + "strconv" + "github.com/AlecAivazis/survey/v2" "github.com/fatih/color" "github.com/gotd/td/session" tdtdesktop "github.com/gotd/td/session/tdesktop" + "github.com/spf13/viper" + "github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/kv" @@ -14,10 +20,6 @@ import ( "github.com/iyear/tdl/pkg/tdesktop" "github.com/iyear/tdl/pkg/tpath" "github.com/iyear/tdl/pkg/utils" - "github.com/spf13/viper" - "os" - "path/filepath" - "strconv" ) const tdata = "tdata" diff --git a/app/up/iter.go b/app/up/iter.go index 800aec5..be55a34 100644 --- a/app/up/iter.go +++ b/app/up/iter.go @@ -3,13 +3,15 @@ package up import ( "context" "fmt" + "os" + "path/filepath" + "github.com/gabriel-vasile/mimetype" + "go.uber.org/zap" + "github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/uploader" "github.com/iyear/tdl/pkg/utils" - "go.uber.org/zap" - "os" - "path/filepath" ) type file struct { diff --git a/app/up/up.go b/app/up/up.go index 890fbf5..24d8715 100644 --- a/app/up/up.go +++ b/app/up/up.go @@ -2,11 +2,13 @@ package up import ( "context" + "github.com/fatih/color" + "github.com/spf13/viper" + "github.com/iyear/tdl/app/internal/tgc" "github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/uploader" - "github.com/spf13/viper" ) type Options struct { diff --git a/app/up/walk.go b/app/up/walk.go index 369f52e..e493b2d 100644 --- a/app/up/walk.go +++ b/app/up/walk.go @@ -1,11 +1,12 @@ package up import ( - "github.com/iyear/tdl/pkg/consts" - "github.com/iyear/tdl/pkg/utils" "io/fs" "path/filepath" "strings" + + "github.com/iyear/tdl/pkg/consts" + "github.com/iyear/tdl/pkg/utils" ) func walk(paths, excludes []string) ([]*file, error) { diff --git a/cmd/archive.go b/cmd/archive.go index 5c065e5..f385cb4 100644 --- a/cmd/archive.go +++ b/cmd/archive.go @@ -2,9 +2,11 @@ package cmd import ( "fmt" - "github.com/iyear/tdl/app/archive" - "github.com/spf13/cobra" "time" + + "github.com/spf13/cobra" + + "github.com/iyear/tdl/app/archive" ) func NewBackup() *cobra.Command { diff --git a/cmd/chat.go b/cmd/chat.go index bc4ccde..06f3ad4 100644 --- a/cmd/chat.go +++ b/cmd/chat.go @@ -2,11 +2,13 @@ package cmd import ( "fmt" + "math" + + "github.com/spf13/cobra" + "github.com/iyear/tdl/app/chat" "github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/utils" - "github.com/spf13/cobra" - "math" ) func NewChat() *cobra.Command { diff --git a/cmd/dl.go b/cmd/dl.go index 16d631e..d5b89b0 100644 --- a/cmd/dl.go +++ b/cmd/dl.go @@ -2,12 +2,14 @@ package cmd import ( "fmt" + "strings" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + "github.com/iyear/tdl/app/dl" "github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/logger" - "github.com/spf13/cobra" - "github.com/spf13/viper" - "strings" ) func NewDownload() *cobra.Command { diff --git a/cmd/login.go b/cmd/login.go index b2b326d..aa341bd 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -2,9 +2,10 @@ package cmd import ( "github.com/fatih/color" + "github.com/spf13/cobra" + "github.com/iyear/tdl/app/login" "github.com/iyear/tdl/pkg/logger" - "github.com/spf13/cobra" ) func NewLogin() *cobra.Command { diff --git a/cmd/root.go b/cmd/root.go index c6926a9..4824fdf 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,18 +1,20 @@ package cmd import ( + "path/filepath" + "strings" + "time" + "github.com/fatih/color" - "github.com/iyear/tdl/pkg/consts" - "github.com/iyear/tdl/pkg/kv" - "github.com/iyear/tdl/pkg/logger" - "github.com/iyear/tdl/pkg/utils" "github.com/spf13/cobra" "github.com/spf13/cobra/doc" "github.com/spf13/viper" "go.uber.org/zap" - "path/filepath" - "strings" - "time" + + "github.com/iyear/tdl/pkg/consts" + "github.com/iyear/tdl/pkg/kv" + "github.com/iyear/tdl/pkg/logger" + "github.com/iyear/tdl/pkg/utils" ) func New() *cobra.Command { diff --git a/cmd/up.go b/cmd/up.go index b40ac31..2136a50 100644 --- a/cmd/up.go +++ b/cmd/up.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/iyear/tdl/app/up" "github.com/iyear/tdl/pkg/logger" - "github.com/spf13/cobra" ) func NewUpload() *cobra.Command { diff --git a/cmd/version.go b/cmd/version.go index 3208322..9b8967d 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -3,11 +3,13 @@ package cmd import ( "bytes" _ "embed" - "github.com/fatih/color" - "github.com/iyear/tdl/pkg/consts" - "github.com/spf13/cobra" "runtime" "text/template" + + "github.com/fatih/color" + "github.com/spf13/cobra" + + "github.com/iyear/tdl/pkg/consts" ) //go:embed version.tmpl diff --git a/main.go b/main.go index 30633cf..6c3f481 100644 --- a/main.go +++ b/main.go @@ -2,10 +2,12 @@ package main import ( "context" - "github.com/fatih/color" - "github.com/iyear/tdl/cmd" "os" "os/signal" + + "github.com/fatih/color" + + "github.com/iyear/tdl/cmd" ) func main() { diff --git a/pkg/clock/clock.go b/pkg/clock/clock.go index a17d7ae..8757252 100644 --- a/pkg/clock/clock.go +++ b/pkg/clock/clock.go @@ -2,9 +2,10 @@ package clock import ( "fmt" + "time" + "github.com/beevik/ntp" "github.com/gotd/td/clock" - "time" ) const defaultHost = "pool.ntp.org" diff --git a/pkg/dcpool/dcpool.go b/pkg/dcpool/dcpool.go index 5f7ab86..bfc7b13 100644 --- a/pkg/dcpool/dcpool.go +++ b/pkg/dcpool/dcpool.go @@ -2,13 +2,15 @@ package dcpool import ( "context" + "sync" + "github.com/gotd/td/telegram" "github.com/gotd/td/tg" - "github.com/iyear/tdl/pkg/logger" - "github.com/iyear/tdl/pkg/takeout" "go.uber.org/multierr" "go.uber.org/zap" - "sync" + + "github.com/iyear/tdl/pkg/logger" + "github.com/iyear/tdl/pkg/takeout" ) type Pool interface { diff --git a/pkg/downloader/downloader.go b/pkg/downloader/downloader.go index 0a4280e..a33f9dd 100644 --- a/pkg/downloader/downloader.go +++ b/pkg/downloader/downloader.go @@ -4,20 +4,22 @@ import ( "context" "errors" "fmt" - "github.com/fatih/color" - "github.com/gabriel-vasile/mimetype" - "github.com/gotd/td/telegram/downloader" - "github.com/iyear/tdl/pkg/dcpool" - "github.com/iyear/tdl/pkg/logger" - "github.com/iyear/tdl/pkg/prog" - "github.com/iyear/tdl/pkg/utils" - "github.com/jedib0t/go-pretty/v6/progress" - "go.uber.org/zap" - "golang.org/x/sync/errgroup" "os" "path/filepath" "strings" "time" + + "github.com/fatih/color" + "github.com/gabriel-vasile/mimetype" + "github.com/gotd/td/telegram/downloader" + "github.com/jedib0t/go-pretty/v6/progress" + "go.uber.org/zap" + "golang.org/x/sync/errgroup" + + "github.com/iyear/tdl/pkg/dcpool" + "github.com/iyear/tdl/pkg/logger" + "github.com/iyear/tdl/pkg/prog" + "github.com/iyear/tdl/pkg/utils" ) const TempExt = ".tmp" diff --git a/pkg/downloader/iter.go b/pkg/downloader/iter.go index ff29400..9f5efb8 100644 --- a/pkg/downloader/iter.go +++ b/pkg/downloader/iter.go @@ -3,6 +3,7 @@ package downloader import ( "context" "errors" + "github.com/gotd/td/tg" ) diff --git a/pkg/downloader/ps.go b/pkg/downloader/ps.go index d675eca..684b465 100644 --- a/pkg/downloader/ps.go +++ b/pkg/downloader/ps.go @@ -2,10 +2,12 @@ package downloader import ( "context" - "github.com/iyear/tdl/pkg/ps" - "github.com/jedib0t/go-pretty/v6/progress" "strings" "time" + + "github.com/jedib0t/go-pretty/v6/progress" + + "github.com/iyear/tdl/pkg/ps" ) func (d *Downloader) renderPinned(ctx context.Context, pw progress.Writer) { diff --git a/pkg/downloader/write_at.go b/pkg/downloader/write_at.go index 7ce00f8..a8ec818 100644 --- a/pkg/downloader/write_at.go +++ b/pkg/downloader/write_at.go @@ -1,9 +1,10 @@ package downloader import ( - "github.com/jedib0t/go-pretty/v6/progress" "os" "time" + + "github.com/jedib0t/go-pretty/v6/progress" ) // writeAt wrapper for file to use progress bar diff --git a/pkg/key/key.go b/pkg/key/key.go index a15d5a2..72b6400 100644 --- a/pkg/key/key.go +++ b/pkg/key/key.go @@ -2,10 +2,11 @@ package key import ( "bytes" - "github.com/gotd/td/telegram/peers" "strconv" "strings" "sync" + + "github.com/gotd/td/telegram/peers" ) var keyPool = sync.Pool{ diff --git a/pkg/kv/kv.go b/pkg/kv/kv.go index 80d46db..10164e0 100644 --- a/pkg/kv/kv.go +++ b/pkg/kv/kv.go @@ -2,11 +2,13 @@ package kv import ( "errors" - "github.com/iyear/tdl/pkg/validator" - "go.etcd.io/bbolt" - "go.uber.org/multierr" "os" "time" + + "go.etcd.io/bbolt" + "go.uber.org/multierr" + + "github.com/iyear/tdl/pkg/validator" ) var ( diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index cb08d20..ea1634b 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -2,6 +2,7 @@ package logger import ( "context" + "go.uber.org/zap" "go.uber.org/zap/zapcore" "gopkg.in/natefinch/lumberjack.v2" diff --git a/pkg/prog/prog.go b/pkg/prog/prog.go index 3f354d2..141cfe3 100644 --- a/pkg/prog/prog.go +++ b/pkg/prog/prog.go @@ -1,9 +1,10 @@ package prog import ( + "time" + "github.com/fatih/color" "github.com/jedib0t/go-pretty/v6/progress" - "time" ) func New(formatter progress.UnitsFormatter) progress.Writer { diff --git a/pkg/ps/ps.go b/pkg/ps/ps.go index 0d48feb..540bc97 100644 --- a/pkg/ps/ps.go +++ b/pkg/ps/ps.go @@ -3,10 +3,12 @@ package ps import ( "context" "fmt" - "github.com/iyear/tdl/pkg/utils" - "github.com/shirou/gopsutil/v3/process" "os" "runtime" + + "github.com/shirou/gopsutil/v3/process" + + "github.com/iyear/tdl/pkg/utils" ) var proc *process.Process diff --git a/pkg/storage/peers.go b/pkg/storage/peers.go index ea0518d..e86a04e 100644 --- a/pkg/storage/peers.go +++ b/pkg/storage/peers.go @@ -3,10 +3,12 @@ package storage import ( "context" "encoding/json" + "strconv" + "github.com/gotd/td/telegram/peers" + "github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/kv" - "strconv" ) type Peers struct { diff --git a/pkg/storage/session.go b/pkg/storage/session.go index b9b92bb..1ae08f0 100644 --- a/pkg/storage/session.go +++ b/pkg/storage/session.go @@ -3,7 +3,9 @@ package storage import ( "context" "errors" + "github.com/gotd/td/telegram" + "github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/kv" ) diff --git a/pkg/storage/state.go b/pkg/storage/state.go index fe8a798..0e837a7 100644 --- a/pkg/storage/state.go +++ b/pkg/storage/state.go @@ -4,7 +4,9 @@ import ( "context" "encoding/json" "errors" + "github.com/gotd/td/telegram/updates" + "github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/kv" ) diff --git a/pkg/takeout/middleware.go b/pkg/takeout/middleware.go index 50c9770..da72d34 100644 --- a/pkg/takeout/middleware.go +++ b/pkg/takeout/middleware.go @@ -3,6 +3,7 @@ package takeout import ( "context" "errors" + "github.com/gotd/td/bin" "github.com/gotd/td/telegram" "github.com/gotd/td/tg" diff --git a/pkg/takeout/takeout.go b/pkg/takeout/takeout.go index 351c7a6..9a10064 100644 --- a/pkg/takeout/takeout.go +++ b/pkg/takeout/takeout.go @@ -2,7 +2,9 @@ package takeout import ( "context" + "github.com/gotd/td/tg" + "github.com/iyear/tdl/pkg/consts" ) diff --git a/pkg/tdesktop/tdesktop.go b/pkg/tdesktop/tdesktop.go index fe72fdc..e3733bc 100644 --- a/pkg/tdesktop/tdesktop.go +++ b/pkg/tdesktop/tdesktop.go @@ -2,8 +2,9 @@ package tdesktop import ( + _ "unsafe" // for go:linkname + _ "github.com/gotd/td/session/tdesktop" // for FileKey - _ "unsafe" // for go:linkname ) //go:linkname FileKey github.com/gotd/td/session/tdesktop.fileKey diff --git a/pkg/texpr/expr.go b/pkg/texpr/expr.go index 2983f14..3df7309 100644 --- a/pkg/texpr/expr.go +++ b/pkg/texpr/expr.go @@ -1,9 +1,10 @@ package texpr import ( + "sync" + "github.com/antonmedv/expr" "github.com/antonmedv/expr/vm" - "sync" ) var vmPool = sync.Pool{New: func() any { diff --git a/pkg/texpr/fields.go b/pkg/texpr/fields.go index c2219c0..ad652db 100644 --- a/pkg/texpr/fields.go +++ b/pkg/texpr/fields.go @@ -2,9 +2,10 @@ package texpr import ( "fmt" - "github.com/fatih/color" "reflect" "strings" + + "github.com/fatih/color" ) type FieldsGetter struct { diff --git a/pkg/texpr/fields_test.go b/pkg/texpr/fields_test.go index a9be751..7c475a2 100644 --- a/pkg/texpr/fields_test.go +++ b/pkg/texpr/fields_test.go @@ -1,9 +1,10 @@ package texpr import ( + "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func TestFieldsGetter(t *testing.T) { diff --git a/pkg/tmedia/document.go b/pkg/tmedia/document.go index d5f4a58..4ecd783 100644 --- a/pkg/tmedia/document.go +++ b/pkg/tmedia/document.go @@ -1,10 +1,12 @@ package tmedia import ( + "strconv" + "github.com/gabriel-vasile/mimetype" "github.com/gotd/td/tg" + "github.com/iyear/tdl/pkg/downloader" - "strconv" ) func GetDocumentInfo(doc *tg.MessageMediaDocument) (*downloader.Item, bool) { diff --git a/pkg/tmedia/media.go b/pkg/tmedia/media.go index 0a8b395..cef3abb 100644 --- a/pkg/tmedia/media.go +++ b/pkg/tmedia/media.go @@ -2,6 +2,7 @@ package tmedia import ( "github.com/gotd/td/tg" + "github.com/iyear/tdl/pkg/downloader" ) diff --git a/pkg/tmedia/photo.go b/pkg/tmedia/photo.go index 2ad331b..72815cc 100644 --- a/pkg/tmedia/photo.go +++ b/pkg/tmedia/photo.go @@ -1,9 +1,11 @@ package tmedia import ( - "github.com/gotd/td/tg" - "github.com/iyear/tdl/pkg/downloader" "strconv" + + "github.com/gotd/td/tg" + + "github.com/iyear/tdl/pkg/downloader" ) func GetPhotoInfo(photo *tg.MessageMediaPhoto) (*downloader.Item, bool) { diff --git a/pkg/tpath/tpath_linux.go b/pkg/tpath/tpath_linux.go index ae0f265..c76a4b3 100644 --- a/pkg/tpath/tpath_linux.go +++ b/pkg/tpath/tpath_linux.go @@ -3,8 +3,9 @@ package tpath import ( - "github.com/iyear/tdl/pkg/utils" "path/filepath" + + "github.com/iyear/tdl/pkg/utils" ) // https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/SourceFiles/platform/linux/specific_linux.cpp#L669-L684 diff --git a/pkg/tplfunc/string.go b/pkg/tplfunc/string.go index d84c7f4..a4f9a93 100644 --- a/pkg/tplfunc/string.go +++ b/pkg/tplfunc/string.go @@ -1,9 +1,10 @@ package tplfunc import ( - "github.com/iancoleman/strcase" "strings" "text/template" + + "github.com/iancoleman/strcase" ) var String = []Func{ diff --git a/pkg/uploader/progress.go b/pkg/uploader/progress.go index f0ee4ec..9fe6229 100644 --- a/pkg/uploader/progress.go +++ b/pkg/uploader/progress.go @@ -2,6 +2,7 @@ package uploader import ( "context" + "github.com/gotd/td/telegram/uploader" "github.com/jedib0t/go-pretty/v6/progress" ) diff --git a/pkg/uploader/ps.go b/pkg/uploader/ps.go index 3a47140..234b9a0 100644 --- a/pkg/uploader/ps.go +++ b/pkg/uploader/ps.go @@ -2,10 +2,12 @@ package uploader import ( "context" - "github.com/iyear/tdl/pkg/ps" - "github.com/jedib0t/go-pretty/v6/progress" "strings" "time" + + "github.com/jedib0t/go-pretty/v6/progress" + + "github.com/iyear/tdl/pkg/ps" ) func runPS(ctx context.Context, pw progress.Writer) { diff --git a/pkg/uploader/uploader.go b/pkg/uploader/uploader.go index 5bb1a33..0aa2f70 100644 --- a/pkg/uploader/uploader.go +++ b/pkg/uploader/uploader.go @@ -4,20 +4,22 @@ import ( "context" "errors" "fmt" + "io" + "time" + "github.com/fatih/color" "github.com/gotd/td/telegram/message" "github.com/gotd/td/telegram/message/styling" "github.com/gotd/td/telegram/peers" "github.com/gotd/td/telegram/uploader" "github.com/gotd/td/tg" + "github.com/jedib0t/go-pretty/v6/progress" + "golang.org/x/sync/errgroup" + "github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/prog" "github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/utils" - "github.com/jedib0t/go-pretty/v6/progress" - "golang.org/x/sync/errgroup" - "io" - "time" ) var formatter = utils.Byte.FormatBinaryBytes diff --git a/pkg/utils/cmd.go b/pkg/utils/cmd.go index 70e2674..1251718 100644 --- a/pkg/utils/cmd.go +++ b/pkg/utils/cmd.go @@ -2,9 +2,10 @@ package utils import ( "fmt" + "strings" + "github.com/spf13/cobra" "github.com/spf13/pflag" - "strings" ) type cmd struct{} diff --git a/pkg/utils/media.go b/pkg/utils/media.go index ac6076c..abc7d36 100644 --- a/pkg/utils/media.go +++ b/pkg/utils/media.go @@ -2,9 +2,10 @@ package utils import ( "fmt" - "github.com/yapingcat/gomedia/go-mp4" "io" "strings" + + "github.com/yapingcat/gomedia/go-mp4" ) type media struct{} diff --git a/pkg/utils/proxy.go b/pkg/utils/proxy.go index 88d0c01..c638449 100644 --- a/pkg/utils/proxy.go +++ b/pkg/utils/proxy.go @@ -1,8 +1,9 @@ package utils import ( - "golang.org/x/net/proxy" "net/url" + + "golang.org/x/net/proxy" ) type _proxy struct{} diff --git a/pkg/utils/telegram.go b/pkg/utils/telegram.go index b5cf6e2..111bd3a 100644 --- a/pkg/utils/telegram.go +++ b/pkg/utils/telegram.go @@ -3,12 +3,13 @@ package utils import ( "context" "fmt" - "github.com/gotd/td/telegram/peers" - "github.com/gotd/td/telegram/query" - "github.com/gotd/td/tg" "net/url" "strconv" "strings" + + "github.com/gotd/td/telegram/peers" + "github.com/gotd/td/telegram/query" + "github.com/gotd/td/tg" ) type telegram struct{} diff --git a/test/archive_test.go b/test/archive_test.go index 14569f9..651ef5d 100644 --- a/test/archive_test.go +++ b/test/archive_test.go @@ -1,10 +1,11 @@ package test import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" "os" "path/filepath" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" ) var _ = Describe("Test tdl archive", func() { diff --git a/test/chat_ls_test.go b/test/chat_ls_test.go index eb65f7f..3d7a4a7 100644 --- a/test/chat_ls_test.go +++ b/test/chat_ls_test.go @@ -2,10 +2,12 @@ package test import ( "encoding/json" - "github.com/iyear/tdl/app/chat" + "strings" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "strings" + + "github.com/iyear/tdl/app/chat" ) var _ = Describe("Test tdl chat ls", FlakeAttempts(3), func() { diff --git a/test/suite_test.go b/test/suite_test.go index 7e84ea5..87389b6 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -1,17 +1,19 @@ package test import ( - "github.com/fatih/color" - tcmd "github.com/iyear/tdl/cmd" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/spf13/cobra" "io" "log" "os" "strconv" "testing" "time" + + "github.com/fatih/color" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/spf13/cobra" + + tcmd "github.com/iyear/tdl/cmd" ) func TestCommand(t *testing.T) { diff --git a/test/upload_test.go b/test/upload_test.go index e3c9ed9..57de9dc 100644 --- a/test/upload_test.go +++ b/test/upload_test.go @@ -1,15 +1,16 @@ package test import ( - "github.com/google/uuid" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/tidwall/gjson" "log" "math/rand" "os" "path/filepath" "strconv" + + "github.com/google/uuid" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/tidwall/gjson" ) var _ = Describe("Test tdl upload", FlakeAttempts(3), func() {