You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/instructions/go.instructions.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,14 +28,17 @@ applyTo: "**/*.go"
28
28
- Interface Segregation - Prefer small, specific interfaces over large, general-purpose ones
29
29
- Programming for interfaces, not implementations - Use interfaces to define behavior and allow for flexible implementations
30
30
- Stick strictly to the existing coding conventions in this repository
31
-
- For error handling we like to wrap errors: `return fmt.Errorf("context: %w", err)`. Define global errors where it makes sense: `var ErrName = errors.New("...")`
31
+
- For error handling we like to wrap errors: `return fmt.Errorf("context:\n%w", err)`. Define global errors where it makes sense: `var ErrName = errors.New("...")`
32
+
- For error messages with context, add a newline after the context message, before the error format specifier. Examples:
33
+
-`fmt.Errorf("This is an error context with wrapped error:\n%w")`
34
+
-`fmt.Errorf("This is a regular error with context string:\n%v")`
32
35
- Follow established Go language practices and conventions:
33
36
- Follow Go naming conventions (e.g., CamelCase for exported names)
34
37
- Write concise, readable code with appropriate comments
35
38
- Use Go idioms and standard library functions where appropriate
36
39
- In formatted strings enclose string types in quotes. For that purpose use the `%#q` format verb unless the message already encloses the string in quotes. Examples:
37
-
-`return fmt.Errorf("failed to open %#q:%w", filename, err)`
38
-
-`return fmt.Errorf("failed to run command 'go %s':%w", strings.Join(args, " "), err)`
40
+
-`return fmt.Errorf("failed to open %#q:\n%w", filename, err)`
41
+
-`return fmt.Errorf("failed to run command 'go %s':\n%w", strings.Join(args, " "), err)`
39
42
- Comments referring to types should encapsulate the type name in square brackets. Example: `// [packagename.MyType] is a custom type`
0 commit comments