Go assistant using GPT4.1
- Use gofmt to format your code automatically. Don’t fight the formatter.
- Write clear and concise package names. Use lowercase, single-word names without underscores -r mixed caps.
- Follow Go naming conventions:
- Use MixedCaps or mixedCaps for multiword names, not underscores
- Capitalize exported names
- Use short, descriptive names for variables and functions
- Utilize Go’s built-in error handling. Return errors as values, not exceptions.
- Take advantage of multiple return values, especially for error handling.
- Use defer for cleanup operations like closing files or unlocking mutexes.
- Prefer composition over inheritance. Use embedding to include functionality from other -ypes.
- Make use of interfaces for abstraction. Define interfaces for the methods you need.
- Utilize Go’s concurrency primitives:
- Use goroutines for concurrent tasks
- Use channels for communication between goroutines
- Remember: “Don’t communicate by sharing memory; share memory by communicating”
- Leverage the blank identifier (_) when you need to ignore return values.
- Use type switches to handle multiple types in interfaces.
- Write clear documentation comments for packages, functions, and types.
- Avoid unnecessary else clauses. Handle errors early and return.
- Use named return values when it improves clarity.
- Make good use of the init() function for package initialization when needed.
- Remember that semicolons are mostly implicit in Go. Don’t add them unnecessarily.
- Use the built-in testing package for unit tests.
- Utilize Go’s powerful slice and map types effectively.
- Remember to check for nil before dereferencing pointers.
- Use the context package for managing cancellations and deadlines across API boundaries.
- Follow the principle of “Accept interfaces, return structs” in your API design.
- Use go vet and golint tools regularly to catch common mistakes and style issues.
When working with Go projects, adhere to the Standard Go Project Layout conventions:
1. Place executable entry points in the `cmd/` directory, with each subdirectory representing a single binary.
2. Use the `internal/` directory for packages that should not be imported by other projects.
3. Organize code into focused packages with single responsibilities.
4. Follow Go's standard naming conventions:
- CamelCase for exported names
- Short, lowercase package names
- Use `New[Type]` for constructors
5. Place packages that may be imported by external applications in the `pkg/` directory.
6. Maintain clear separation of concerns between packages.
7. Keep main functions minimal, focusing on initialization and configuration.
8. Create small interfaces focused on the consumer's needs.
9. Pass context through function calls for cancellation support.
10. Follow idiomatic Go error handling patterns.
When structuring new Go code or reorganizing existing code, always suggest a modular approach with proper package boundaries following these conventions. Recommend breaking large files into appropriate packages based on their functionality.
@diff
Generate a commit message for the above set of changes. First, give a single sentence, no more than 80 characters. Then, after 2 line breaks, give a list of no more than 5 short bullet points, each no more than 40 characters. Output nothing except for the commit message, and don't surround it in quotes.
No Data configured
npx -y @modelcontextprotocol/server-filesystem ${{ secrets.lawzava/go-openai/anthropic/filesystem-mcp/PATH }}