9b28623abfc5b5237137ac74b1207273ce2ae206

Author
TheEdgeOfRage <git@theedgeofrage.com>
Committer
TheEdgeOfRage <git@theedgeofrage.com>
Date

Message

Lint cleanup

Diff

 1diff --git a/go.mod b/go.mod
 2index 9f077233d21dfb39f807a297305fbcddb0b718d5..8b46595a7d1f65efbc4aeecb3842f251b19ef4b9 100644
 3--- a/go.mod
 4+++ b/go.mod
 5@@ -1,3 +1,3 @@
 6 module gitea.theedgeofrage.com/theedgeofrage/rpn
 7 
 8-go 1.21.5
 9+go 1.21
10diff --git a/rpn/lexer.go b/rpn/lexer.go
11index 6dbcc8833d634c0136618640419ec4f3cf41a0ee..06f2abac88ac372850d4dc81cdab15faaed7c319 100644
12--- a/rpn/lexer.go
13+++ b/rpn/lexer.go
14@@ -14,11 +14,7 @@ type Lexer struct {
15 func (l *Lexer) parseNumber(negative bool) (*Token, error) {
16 	numStr := ""
17 	char := l.input.NextChar()
18-	for {
19-		if !unicode.IsNumber(char) && char != '.' {
20-			break
21-		}
22-
23+	for unicode.IsNumber(char) || char == '.' {
24 		numStr += string(char)
25 		char = l.input.Eat()
26 	}
27@@ -38,11 +34,7 @@ func (l *Lexer) parseNumber(negative bool) (*Token, error) {
28 func (l *Lexer) parseWord() (*Token, error) {
29 	word := ""
30 	char := l.input.NextChar()
31-	for {
32-		if !unicode.IsLetter(char) {
33-			break
34-		}
35-
36+	for unicode.IsLetter(char) {
37 		word += string(char)
38 		char = l.input.Eat()
39 	}
40@@ -69,7 +61,7 @@ func (l *Lexer) parseWord() (*Token, error) {
41 	case "exit":
42 		return &Token{exit, 0, 0, word}, nil
43 	default:
44-		return nil, fmt.Errorf("Unknown input: %s", word)
45+		return nil, fmt.Errorf("unknown input: %s", word)
46 	}
47 }
48 
49@@ -133,7 +125,7 @@ func (l *Lexer) Parse(input string) ([]*Token, error) {
50 					return nil, err
51 				}
52 			} else {
53-				return nil, fmt.Errorf("Invalid input: %c", char)
54+				return nil, fmt.Errorf("invalid input: %c", char)
55 			}
56 		}
57 
58diff --git a/rpn/rpn.go b/rpn/rpn.go
59index 0b5620378105ac6595ecfc55de7eb7884b0e244c..2cc7bf0207eb348ec0eb4d8c8431d7b3f2f4c5d6 100644
60--- a/rpn/rpn.go
61+++ b/rpn/rpn.go
62@@ -60,14 +60,14 @@ func (r *RPN) Eval(input string) error {
63 				if a == 0 {
64 					r.stack.Push(b)
65 					r.stack.Push(a)
66-					return fmt.Errorf("Can't divide by zero")
67+					return fmt.Errorf("can't divide by zero")
68 				}
69 				r.stack.Push(b / a)
70 			case mod:
71 				if a == 0 {
72 					r.stack.Push(b)
73 					r.stack.Push(a)
74-					return fmt.Errorf("Can't divide by zero")
75+					return fmt.Errorf("can't divide by zero")
76 				}
77 				r.stack.Push(float64(int64(b) % int64(a)))
78 			case power:
79@@ -99,7 +99,7 @@ func (r *RPN) Eval(input string) error {
80 		case exit:
81 			return fmt.Errorf("exit")
82 		default:
83-			return fmt.Errorf("Operation not implemented: %s", token.Original)
84+			return fmt.Errorf("operation not implemented: %s", token.Original)
85 		}
86 	}
87