diff --git a/.golangci-soft.yml b/.golangci-soft.yml index 55255e59..93a1caf0 100644 --- a/.golangci-soft.yml +++ b/.golangci-soft.yml @@ -14,17 +14,12 @@ issues: linters: enable: - # - dupl - exhaustive - # - exhaustivestruct - goconst - godot - - godox - - gomnd + - mnd - gomoddirectives - goprintffuncname - # - ifshort - # - lll - misspell - nakedret - nestif @@ -35,13 +30,10 @@ linters: # disable default linters, they are already enabled in .golangci.yml disable: - - deadcode - errcheck - gosimple - govet - ineffassign - staticcheck - - structcheck - typecheck - unused - - varcheck diff --git a/field_text.go b/field_text.go index 7424a48e..a5c3a40c 100644 --- a/field_text.go +++ b/field_text.go @@ -310,8 +310,8 @@ func (t *Text) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case key.Matches(msg, t.keymap.Editor): ext := strings.TrimPrefix(t.editorExtension, ".") tmpFile, _ := os.CreateTemp(os.TempDir(), "*."+ext) - cmd := exec.Command(t.editorCmd, append(t.editorArgs, tmpFile.Name())...) //nolint - _ = os.WriteFile(tmpFile.Name(), []byte(t.textarea.Value()), 0600) + cmd := exec.Command(t.editorCmd, append(t.editorArgs, tmpFile.Name())...) //nolint:gosec + _ = os.WriteFile(tmpFile.Name(), []byte(t.textarea.Value()), 0o644) //nolint:mnd,gosec cmds = append(cmds, tea.ExecProcess(cmd, func(error) tea.Msg { content, _ := os.ReadFile(tmpFile.Name()) _ = os.Remove(tmpFile.Name()) @@ -364,8 +364,8 @@ func (t *Text) activeTextAreaStyles() *textarea.Style { // View renders the text field. func (t *Text) View() string { - var styles = t.activeStyles() - var textareaStyles = t.activeTextAreaStyles() + styles := t.activeStyles() + textareaStyles := t.activeTextAreaStyles() // NB: since the method is on a pointer receiver these are being mutated. // Because this runs on every render this shouldn't matter in practice, diff --git a/form.go b/form.go index b576d4db..eee47fe3 100644 --- a/form.go +++ b/form.go @@ -3,6 +3,7 @@ package huh import ( "context" "errors" + "fmt" "io" "os" "sync" @@ -651,7 +652,7 @@ func (f *Form) run(ctx context.Context) error { if errors.Is(err, tea.ErrProgramKilled) { return ErrTimeout } - return err + return fmt.Errorf("huh: %w", err) } // runAccessible runs the form in accessible mode. diff --git a/group.go b/group.go index 147bc230..d890751b 100644 --- a/group.go +++ b/group.go @@ -54,8 +54,7 @@ func NewGroup(fields ...Field) *Group { } height := group.fullHeight() - //nolint:gomnd - v := viewport.New(80, height) + v := viewport.New(80, height) //nolint:mnd group.viewport = v group.height = height diff --git a/layout.go b/layout.go index c7632188..513d22cf 100644 --- a/layout.go +++ b/layout.go @@ -70,7 +70,7 @@ func (l *layoutColumns) View(f *Form) string { return "" } - var columns []string + columns := make([]string, 0, len(groups)) for _, group := range groups { columns = append(columns, group.Content()) } @@ -149,7 +149,7 @@ func (l *layoutGrid) View(f *Form) string { return "" } - var rows []string + rows := make([]string, 0, len(grid)) for _, row := range grid { var columns []string for _, group := range row {