-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Is your feature request related to a problem? Please describe.
Since my project contains some tool-generated files, such as those from Wire, when executing swag fmt, it modifies these files.
However, in my CI process, there are steps like: wire → swag fmt → detection of uncommitted changes. This ultimately causes such scenarios to fail the CI checks.
Most tools of this kind add comments at the top of the generated files, such as: // Code generated by Wire. DO NOT EDIT.
Therefore, I think we can skip the fmt processing for such files.
Describe the solution you'd like
Since most mainstream lints currently implement special handling for this type of file, I believe we can do the same.
Here is an example reference solution: https://github.com/mgechev/revive/blob/c603da318052d648cceb270a036c559bbbc8757c/lint/linter.go#L207-L216
Of course, to ensure backward compatibility, we can add an option to support this type of switch.
Describe alternatives you've considered
Currently, I skip processing by using --exclude wire_gen.go, but when there are many generated files, such configurations will also become bloated.
Additional context
This is a file change that executes swag fmt:
--- a/cmd/server/wire_gen.go
+++ b/cmd/server/wire_gen.go
@@ -16,10 +16,9 @@ import (
"awslambdaserver/internal/infra"
"awslambdaserver/internal/server"
"context"
+
"github.com/gin-gonic/gin"
-)
-import (
_ "go.uber.org/automaxprocs"
)