Skip to content

Commit

Permalink
Fixed all golangci-lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilyes512 committed Nov 21, 2023
1 parent 9f2d952 commit 85cffcb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
5 changes: 4 additions & 1 deletion pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
5 changes: 3 additions & 2 deletions pkg/cmd/use_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions pkg/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/template/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
}

Expand Down Expand Up @@ -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)
}
3 changes: 1 addition & 2 deletions pkg/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ type dirTemplate struct {
FuncMap template.FuncMap
Metadata Metadata

alignment string
ShouldUseDefaults bool
}

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 85cffcb

Please sign in to comment.