diff --git a/examples/credit-card-form/main.go b/examples/credit-card-form/main.go index 71b3bf58bf..5e075bb124 100644 --- a/examples/credit-card-form/main.go +++ b/examples/credit-card-form/main.go @@ -1,6 +1,7 @@ package main import ( + "errors" "fmt" "log" "strconv" @@ -50,17 +51,17 @@ func ccnValidator(s string) error { // Credit Card Number should a string less than 20 digits // It should include 16 integers and 3 spaces if len(s) > 16+3 { - return fmt.Errorf("CCN is too long") + return errors.New("CCN is too long") } if len(s) == 0 || len(s)%5 != 0 && (s[len(s)-1] < '0' || s[len(s)-1] > '9') { - return fmt.Errorf("CCN is invalid") + return errors.New("CCN is invalid") } // The last digit should be a number unless it is a multiple of 4 in which // case it should be a space if len(s)%5 == 0 && s[len(s)-1] != ' ' { - return fmt.Errorf("CCN must separate groups with spaces") + return errors.New("CCN must separate groups with spaces") } // The remaining digits should be integers @@ -76,12 +77,12 @@ func expValidator(s string) error { e := strings.ReplaceAll(s, "/", "") _, err := strconv.ParseInt(e, 10, 64) if err != nil { - return fmt.Errorf("EXP is invalid") + return errors.New("EXP is invalid") } // There should be only one slash and it should be in the 2nd index (3rd character) if len(s) >= 3 && (strings.Index(s, "/") != 2 || strings.LastIndex(s, "/") != 2) { - return fmt.Errorf("EXP is invalid") + return errors.New("EXP is invalid") } return nil diff --git a/inputreader_windows.go b/inputreader_windows.go index 5969721bc8..8e3f834743 100644 --- a/inputreader_windows.go +++ b/inputreader_windows.go @@ -4,6 +4,7 @@ package tea import ( + "errors" "fmt" "io" "os" @@ -129,11 +130,11 @@ func waitForInput(conin, cancel windows.Handle) error { return fmt.Errorf("unexpected wait object is ready: %d", event-windows.WAIT_OBJECT_0) case windows.WAIT_ABANDONED <= event && event < windows.WAIT_ABANDONED+2: - return fmt.Errorf("abandoned") + return errors.New("abandoned") case event == uint32(windows.WAIT_TIMEOUT): - return fmt.Errorf("timeout") + return errors.New("timeout") case event == windows.WAIT_FAILED: - return fmt.Errorf("failed") + return errors.New("failed") default: return fmt.Errorf("unexpected error: %w", err) }