Skip to content

Commit

Permalink
fix: add Cursor Go rules (#4740)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas authored Mar 2, 2025
1 parent b2342f0 commit 0260f48
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .cursor/rules/go.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
description: Rules for writing Go code
globs: **/*.go
alwaysApply: false
---

- Always handle errors.
- Always wrap errors using `fmt.Errorf("...: %w", err)`
- Never use pointers to represent optional values, always use `github.com/alecthomas/types/optional.Option[T]`
- For tests, always use github.com/alecthomas/assert for assertions.
- When using assert.Equal, the parameters are `assert.Equal(t, <expected>, <actual>)` in that order.
- Always update or create tests for new changes to Go code.
- After making changes to Go files, always run tests.
- Never use `os.Getenv()` outside of `main()`

0 comments on commit 0260f48

Please sign in to comment.