Convenient Go linting package with workspace support and automated execution
Convenient Go linting package with workspace support and automated golangci-lint execution.
π― Convenient Linting: Simple golangci-lint execution with workspace detection
β‘ Project Set Support: Capable of handling single packages, multiple root paths, and workspace operations
π Error Handling: Comprehensive error parsing and debugging capabilities
π Workspace Integration: Auto discovers Go modules with configurable filtering options
π Detailed Reporting: Colorized output with file positions and issue descriptions
go install github.com/go-mate/go-lint/cmd/go-lint@latestcd project-path && go-lintAnalyze and report lint issues in the current Go project.
cd workspace-path && go-lintAuto detect and analyze Go project set in the workspace.
# Enable debug mode with detailed output
cd project-path && go-lint run --debug
# Explicit debug settings
cd project-path && go-lint run --debug=1
cd project-path && go-lint run --debug=0This package auto discovers Go modules using configurable options:
- Include current package: β Enabled by default
- Include submodules: β Enabled by default
- Exclude non-Go projects: β Smart filtering
- Debug output: π§ Configurable
Execute linting on the current package:
go-lintExecute linting on multiple root paths:
go-lint runExecute linting across entire workspace:
go-lint run --debug=1-
Unified Interface Package (
golint/): Provides comprehensive linting execution- Single path execution (
Run) - Multi-root path processing (
RootsRun,WorksRun) - Batch operations with custom configuration (
BatchRun) - Aggregated results with sequence preservation
- Success/failure analysis
- Single path execution (
-
Core Execution Engine (
golangcilint/): Direct golangci-lint integration- JSON result parsing
- Complex error handling
- Warning processing
- Detailed issue reporting
This package handles multiple golangci-lint failure scenarios:
- Complete Failures: Command execution errors with detailed diagnostics
- Partial Results: Mixed success/warning scenarios with JSON extraction
- Clean Success: Standard success with result processing
- Colorized Console Output: Intuitive visual feedback
- Detailed Issue Reports: File positions and descriptions
- JSON Debug Output: Raw results for integration
- Progress Tracking: Project set execution progress
config := workspath.NewOptions().
WithIncludeCurrentPackage(true).
WithIncludeSubModules(true).
WithExcludeNoGo(true).
WithDebugMode(debugMode)Default timeout: 5 minutes each module
result := golint.RootsRun(modulePaths, time.Minute*5)This example demonstrates direct usage of the base-level golangcilint.Run function with comprehensive result validation.
package main
import (
"time"
"github.com/go-mate/go-lint/golangcilint"
"github.com/yyle88/must"
"github.com/yyle88/must/mustslice"
"github.com/yyle88/osexec"
"github.com/yyle88/runpath"
"github.com/yyle88/zaplog"
)
func main() {
projectPath := runpath.PARENT.Path()
zaplog.SUG.Debugln(projectPath)
// Execute golangci-lint with debug config and validate results
result := golangcilint.Run(osexec.NewCommandConfig().WithDebug(), projectPath, time.Minute*5)
must.Done(result.Cause)
mustslice.Have(result.Output)
mustslice.None(result.Warnings)
mustslice.None(result.Result.Issues)
}β¬οΈ Source: Source
This example shows how to use BatchRun to execute linting on multiple projects with custom execution configuration.
package main
import (
"time"
"github.com/go-mate/go-lint/golint"
"github.com/yyle88/osexec"
"github.com/yyle88/runpath"
"github.com/yyle88/zaplog"
)
func main() {
projectPath := runpath.PARENT.Path()
zaplog.SUG.Debugln(projectPath)
// Execute batch linting with debug config and display results
projectPaths := []string{projectPath}
result := golint.BatchRun(osexec.NewCommandConfig().WithDebug(), projectPaths, time.Minute*5)
result.DebugIssues()
}β¬οΈ Source: Source
This example demonstrates integration with the cobra command framework to create a CLI application using RootsRun.
package main
import (
"time"
"github.com/go-mate/go-lint/golint"
"github.com/spf13/cobra"
"github.com/yyle88/must"
"github.com/yyle88/runpath"
"github.com/yyle88/zaplog"
)
func main() {
projectPath := runpath.PARENT.Path()
zaplog.SUG.Debugln(projectPath)
projectPaths := []string{projectPath}
// Create root command with usage hint
var rootCmd = &cobra.Command{
Use: "lint",
Short: "lint",
Long: "lint",
Run: func(cmd *cobra.Command, args []string) {
zaplog.LOG.Info("Use 'lint run' to execute linting")
},
}
// Add run subcommand that executes RootsRun
rootCmd.AddCommand(&cobra.Command{
Use: "run",
Short: "golangci-lint run",
Long: "golangci-lint run",
Run: func(cmd *cobra.Command, args []string) {
result := golint.RootsRun(projectPaths, time.Minute*5)
result.DebugIssues()
},
})
must.Done(rootCmd.Execute())
}β¬οΈ Source: Source
Supported golangci-lint version:
golangci-lint versionOutput:
golangci-lint has version 2.0.2 built with go1.25.3 from 2b224c2 on 2025-03-25T20:33:26Z
MIT License. See LICENSE.
Contributions are welcome! Report bugs, suggest features, and contribute code:
- π Found a mistake? Open an issue on GitHub with reproduction steps
- π‘ Have a feature idea? Create an issue to discuss the suggestion
- π Documentation confusing? Report it so we can improve
- π Need new features? Share the use cases to help us understand requirements
- β‘ Performance issue? Help us optimize through reporting slow operations
- π§ Configuration problem? Ask questions about complex setups
- π’ Follow project progress? Watch the repo to get new releases and features
- π Success stories? Share how this package improved the workflow
- π¬ Feedback? We welcome suggestions and comments
New code contributions, follow this process:
- Fork: Fork the repo on GitHub (using the webpage UI).
- Clone: Clone the forked project (
git clone https://github.com/yourname/repo-name.git). - Navigate: Navigate to the cloned project (
cd repo-name) - Branch: Create a feature branch (
git checkout -b feature/xxx). - Code: Implement the changes with comprehensive tests
- Testing: (Golang project) Ensure tests pass (
go test ./...) and follow Go code style conventions - Documentation: Update documentation to support client-facing changes and use significant commit messages
- Stage: Stage changes (
git add .) - Commit: Commit changes (
git commit -m "Add feature xxx") ensuring backward compatible code - Push: Push to the branch (
git push origin feature/xxx). - PR: Open a merge request on GitHub (on the GitHub webpage) with detailed description.
Please ensure tests pass and include relevant documentation updates.
Welcome to contribute to this project via submitting merge requests and reporting issues.
Project Support:
- β Give GitHub stars if this project helps you
- π€ Share with teammates and (golang) programming friends
- π Write tech blogs about development tools and workflows - we provide content writing support
- π Join the ecosystem - committed to supporting open source and the (golang) development scene
Have Fun Coding with this package! πππ
