From 85cffcb8a69b8ebb0c53986ea9bd000dbc1da188 Mon Sep 17 00:00:00 2001 From: Ilyes512 Date: Tue, 21 Nov 2023 21:33:28 +0100 Subject: [PATCH] Fixed all golangci-lint issues --- pkg/cmd/root.go | 5 ++++- pkg/cmd/use_test.go | 5 +++-- pkg/prompt/prompt.go | 4 +--- pkg/template/metadata.go | 4 ++-- pkg/template/template.go | 3 +-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index ed42596..096663f 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -49,5 +49,8 @@ func Run() { Version.PersistentFlags().BoolP("dont-prettify", "", false, "Only print the version without fancy formatting") Root.AddCommand(Version) - Root.Execute() + err := Root.Execute() + if err != nil { + panic(err) + } } diff --git a/pkg/cmd/use_test.go b/pkg/cmd/use_test.go index a9dac82..6a924ac 100644 --- a/pkg/cmd/use_test.go +++ b/pkg/cmd/use_test.go @@ -14,9 +14,10 @@ func TestUseExecutesProjectTemplate(t *testing.T) { tmpDirPath, err := ioutil.TempDir("", "template-test") if err != nil { t.Fatalf("ioutil.TempDir() got error -> %v", err) - } else { - //defer os.RemoveAll(tmpDirPath) } + // else { + // defer os.RemoveAll(tmpDirPath) + // } if err := os.MkdirAll(filepath.Join(tmpDirPath, "input", "{{Name}}", "{{Date}}"), 0744); err != nil { t.Fatalf("os.MkdirAll should have created template directories -> got error %v", err) diff --git a/pkg/prompt/prompt.go b/pkg/prompt/prompt.go index 5427f3d..5ef3ea2 100644 --- a/pkg/prompt/prompt.go +++ b/pkg/prompt/prompt.go @@ -10,8 +10,6 @@ import ( "github.com/Ilyes512/boilr/pkg/util/tlog" ) -type templateFunc func() interface{} - // Interface for prompts. type Interface interface { // PromptMessage returns a proper prompt message for the given field with the given default value. @@ -92,7 +90,7 @@ func Func(defval interface{}) Interface { return boolPrompt(defval) case []interface{}: if len(defval) == 0 { - tlog.Warn(fmt.Sprintf("empty list of choices")) + tlog.Warn("empty list of choices") return nil } diff --git a/pkg/template/metadata.go b/pkg/template/metadata.go index e2fc3ce..ab41051 100644 --- a/pkg/template/metadata.go +++ b/pkg/template/metadata.go @@ -17,7 +17,7 @@ type Metadata struct { // String returns the string slice form of Metadata. func (m Metadata) String() []string { - tDelta := time.Now().Sub(time.Time(m.Created)) + tDelta := time.Since(time.Time(m.Created)) return []string{m.Tag, m.Repository, units.HumanDuration(tDelta) + " ago"} } @@ -55,5 +55,5 @@ func (t *JSONTime) UnmarshalJSON(b []byte) error { // String returns the string form of JSONTime. func (t JSONTime) String() string { - return fmt.Sprintf("%s", time.Time(t).Format(timeFormat)) + return time.Time(t).Format(timeFormat) } diff --git a/pkg/template/template.go b/pkg/template/template.go index 6f34b1e..050ede9 100644 --- a/pkg/template/template.go +++ b/pkg/template/template.go @@ -110,7 +110,6 @@ type dirTemplate struct { FuncMap template.FuncMap Metadata Metadata - alignment string ShouldUseDefaults bool } @@ -208,7 +207,7 @@ func (t *dirTemplate) Execute(dirPrefix string) error { return err } if isBin { - _, err = origF.Seek(io.SeekStart, 0) + _, err = origF.Seek(0, io.SeekStart) if err != nil { return err }