From 052c2ec1d1921835f3757e00f726ca9be214d701 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Tue, 10 May 2022 20:59:28 +1000 Subject: [PATCH] appease linter --- go.mod | 3 ++- go.sum | 3 ++- main.go | 2 +- pkg/gui/containers_panel.go | 2 -- pkg/gui/options_menu_panel.go | 4 +--- pkg/gui/services_panel.go | 5 ----- pkg/gui/view_helpers.go | 1 - pkg/i18n/dutch.go | 1 + pkg/i18n/english.go | 2 ++ pkg/i18n/german.go | 3 ++- pkg/i18n/i18n.go | 5 ++--- pkg/i18n/polish.go | 1 + pkg/i18n/turkish.go | 1 + pkg/tasks/tasks.go | 15 ++++++-------- test/testmain/main.go | 21 -------------------- vendor/github.com/docker/go-units/circle.yml | 11 ++++++++++ vendor/modules.txt | 2 ++ 17 files changed, 34 insertions(+), 48 deletions(-) delete mode 100644 test/testmain/main.go create mode 100644 vendor/github.com/docker/go-units/circle.yml diff --git a/go.mod b/go.mod index ca4184a..ba63330 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d github.com/boz/go-throttle v0.0.0-20160922054636-fdc4eab740c1 github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 - github.com/davecgh/go-spew v1.1.1 github.com/docker/docker v0.7.3-0.20190307005417-54dddadc7d5d github.com/fatih/color v1.7.0 github.com/go-errors/errors v1.0.1 @@ -29,6 +28,7 @@ require ( require ( github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect github.com/Microsoft/go-winio v0.4.14 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/distribution v2.7.1+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect @@ -50,6 +50,7 @@ require ( golang.org/x/exp v0.0.0-20220428152302-39d4317da171 // indirect golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect + golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect google.golang.org/grpc v1.22.0 // indirect gopkg.in/yaml.v2 v2.2.2 // indirect diff --git a/go.sum b/go.sum index 2216794..65bfd4e 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,9 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/main.go b/main.go index 0cb3dc2..09f3718 100644 --- a/main.go +++ b/main.go @@ -97,7 +97,7 @@ func main() { stackTrace := newErr.ErrorStack() app.Log.Error(stackTrace) - log.Fatal(fmt.Sprintf("%s\n\n%s", app.Tr.ErrorOccurred, stackTrace)) + log.Fatalf("%s\n\n%s", app.Tr.ErrorOccurred, stackTrace) } } diff --git a/pkg/gui/containers_panel.go b/pkg/gui/containers_panel.go index 821c0c1..3412496 100644 --- a/pkg/gui/containers_panel.go +++ b/pkg/gui/containers_panel.go @@ -242,7 +242,6 @@ func (gui *Gui) renderContainerLogsAux(container *commands.Container, stop, noti gui.Log.Warn(err) } gui.Log.Info("killed container logs process") - return }() _ = cmd.Wait() @@ -411,7 +410,6 @@ type removeContainerOption struct { description string command string configOptions types.ContainerRemoveOptions - runCommand bool } // GetDisplayStrings is a function. diff --git a/pkg/gui/options_menu_panel.go b/pkg/gui/options_menu_panel.go index d1220d8..24dd968 100644 --- a/pkg/gui/options_menu_panel.go +++ b/pkg/gui/options_menu_panel.go @@ -1,8 +1,6 @@ package gui import ( - "strings" - "github.com/go-errors/errors" "github.com/jesseduffield/gocui" @@ -73,5 +71,5 @@ func (gui *Gui) handleCreateOptionsMenu(g *gocui.Gui, v *gocui.View) error { return bindings[index].Handler(g, v) } - return gui.createMenu(strings.Title(gui.Tr.Menu), bindings, len(bindings), handleMenuPress) + return gui.createMenu(gui.Tr.MenuTitle, bindings, len(bindings), handleMenuPress) } diff --git a/pkg/gui/services_panel.go b/pkg/gui/services_panel.go index 87b72cc..2812655 100644 --- a/pkg/gui/services_panel.go +++ b/pkg/gui/services_panel.go @@ -126,11 +126,6 @@ func (gui *Gui) renderServiceTop(service *commands.Service) error { } func (gui *Gui) renderServiceLogs(service *commands.Service) error { - service, err := gui.getSelectedService() - if err != nil { - return nil - } - if service.Container == nil { return gui.T.NewTask(func(stop chan struct{}) { gui.clearMainView() diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index edc6398..9f435da 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -199,7 +199,6 @@ func (gui *Gui) focusPoint(selectedX int, selectedY int, lineCount int, v *gocui if originalCy != cy { _ = v.SetCursor(cx, selectedY-oy) } - return } func (gui *Gui) cleanString(s string) string { diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index 9abce8e..daaee85 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -26,6 +26,7 @@ func dutchSet() TranslationSet { Execute: "voer uit", Close: "sluit", Menu: "menu", + MenuTitle: "Menu", Scroll: "scroll", OpenConfig: "open de lazydocker configuratie", EditConfig: "verander de lazydocker configuratie", diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index ce509b6..4c0b8da 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -8,6 +8,7 @@ type TranslationSet struct { GlobalTitle string Navigate string Menu string + MenuTitle string Execute string Scroll string Close string @@ -127,6 +128,7 @@ func englishSet() TranslationSet { Execute: "execute", Close: "close", Menu: "menu", + MenuTitle: "Menu", Scroll: "scroll", OpenConfig: "open lazydocker config", EditConfig: "edit lazydocker config", diff --git a/pkg/i18n/german.go b/pkg/i18n/german.go index 7edcfc8..aba4f73 100644 --- a/pkg/i18n/german.go +++ b/pkg/i18n/german.go @@ -25,7 +25,8 @@ func germanSet() TranslationSet { Navigate: "navigieren", Execute: "ausführen", Close: "schließen", - Menu: "Menü", + Menu: "menü", + MenuTitle: "Menü", Scroll: "scrollen", OpenConfig: "öffne lazydocker Konfiguration", EditConfig: "bearbeite lazydocker Konfiguration", diff --git a/pkg/i18n/i18n.go b/pkg/i18n/i18n.go index 914ec1b..25ad5a1 100644 --- a/pkg/i18n/i18n.go +++ b/pkg/i18n/i18n.go @@ -12,9 +12,8 @@ import ( // Localizer will translate a message into the user's language type Localizer struct { - language string - Log *logrus.Entry - S TranslationSet + Log *logrus.Entry + S TranslationSet } func NewTranslationSetFromConfig(log *logrus.Entry, configLanguage string) (*TranslationSet, error) { diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go index 8762821..2525d63 100644 --- a/pkg/i18n/polish.go +++ b/pkg/i18n/polish.go @@ -26,6 +26,7 @@ func polishSet() TranslationSet { Execute: "wykonaj", Close: "zamknij", Menu: "menu", + MenuTitle: "Menu", Scroll: "przewiń", OpenConfig: "otwórz konfigurację", EditConfig: "edytuj konfigurację", diff --git a/pkg/i18n/turkish.go b/pkg/i18n/turkish.go index 22b2604..9b51af2 100644 --- a/pkg/i18n/turkish.go +++ b/pkg/i18n/turkish.go @@ -26,6 +26,7 @@ func turkishSet() TranslationSet { Execute: "çalıştır", Close: "kapat", Menu: "menü", + MenuTitle: "Menü", Scroll: "kaydır", OpenConfig: "lazydocker ayarlarını aç", EditConfig: "lazzydocker ayarlarını düzenle", diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index e028dbd..0568770 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -10,14 +10,12 @@ import ( ) type TaskManager struct { - waitingTask *Task - currentTask *Task - waitingMutex sync.Mutex - taskIDMutex sync.Mutex - Log *logrus.Entry - Tr *i18n.TranslationSet - waitingTaskAlerts chan struct{} - newTaskId int + currentTask *Task + waitingMutex sync.Mutex + taskIDMutex sync.Mutex + Log *logrus.Entry + Tr *i18n.TranslationSet + newTaskId int } type Task struct { @@ -104,7 +102,6 @@ func (t *Task) Stop() { <-t.notifyStopped t.Log.Info("received notifystopped message") t.stopped = true - return } // NewTickerTask is a convenience function for making a new task that repeats some action once per e.g. second diff --git a/test/testmain/main.go b/test/testmain/main.go deleted file mode 100644 index 3a9d579..0000000 --- a/test/testmain/main.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -import "log" - -func main() { - c := make(chan struct{}) - - close(c) - - close(c) - - select { - case <-c: - log.Println("hmm") - } - - select { - case <-c: - log.Println("okay") - } -} diff --git a/vendor/github.com/docker/go-units/circle.yml b/vendor/github.com/docker/go-units/circle.yml new file mode 100644 index 0000000..af9d605 --- /dev/null +++ b/vendor/github.com/docker/go-units/circle.yml @@ -0,0 +1,11 @@ +dependencies: + post: + # install golint + - go get golang.org/x/lint/golint + +test: + pre: + # run analysis before tests + - go vet ./... + - test -z "$(golint ./... | tee /dev/stderr)" + - test -z "$(gofmt -s -l . | tee /dev/stderr)" diff --git a/vendor/modules.txt b/vendor/modules.txt index f98c24d..fb6caf8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -146,6 +146,8 @@ golang.org/x/net/proxy golang.org/x/sys/internal/unsafeheader golang.org/x/sys/unix golang.org/x/sys/windows +# golang.org/x/text v0.3.7 +## explicit; go 1.17 # golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 ## explicit # golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1