modulepackage
0.0.0-20250224075427-39bb724d71b7
Repository: https://github.com/motemen/go-quickfix.git
Documentation: pkg.go.dev
# README
goquickfix
The goquickfix
command quickly fixes Go source that is well typed but
Go refuses to compile e.g. declared and not used: x
.
Installation
go install github.com/motemen/go-quickfix/cmd/goquickfix@latest
Usage
goquickfix [-w] [-revert] <path>...
Flags:
-revert: try to revert possible quickfixes introduced by goquickfix
-w: write result to (source) file instead of stdout
Description
While coding, you may write a Go program that is completely well typed
but go build
(or run
or test
) refuses to build, like this:
package main
import (
"fmt"
"log"
)
func main() {
nums := []int{3, 1, 4, 1, 5}
for i, n := range nums {
fmt.Println(n)
}
}
The Go compiler will complain:
main.go:5:2: "log" imported and not used
main.go:10:6: declared and not used: i
Do we have to bother to comment out the import line or remove
the unused identifier one by one for the Go compiler? Of course no,
goquickfix
does the work instead of you.
Run
goquickfix -w main.go
and you will get the source rewritten so that Go compiles it well without changing the semantics:
package main
import (
"fmt"
_ "log"
)
func main() {
nums := []int{3, 1, 4, 1, 5}
for i, n := range nums {
fmt.Println(n)
_ = i
}
}
Now, you can go run
or go test
your code successfully.
# Packages
No description provided by the author
# Type aliases
ErrorList represents a collection of errors.