Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/motemen/go-quickfix
Quick fix non-compiling well-typed Go source code e.g. "x declared and not used."
https://github.com/motemen/go-quickfix
Last synced: 3 months ago
JSON representation
Quick fix non-compiling well-typed Go source code e.g. "x declared and not used."
- Host: GitHub
- URL: https://github.com/motemen/go-quickfix
- Owner: motemen
- License: mit
- Created: 2015-02-25T16:04:58.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-09-25T23:14:51.000Z (over 1 year ago)
- Last Synced: 2024-06-18T18:49:10.750Z (7 months ago)
- Language: Go
- Homepage:
- Size: 55.7 KB
- Stars: 31
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= goquickfix image:https://github.com/motemen/go-quickfix/workflows/CI/badge.svg["CI Status", link="https://github.com/motemen/go-quickfix/actions"] image:https://pkg.go.dev/badge/github.com/motemen/go-quickfix["go.pkg.dev", link="https://pkg.go.dev/github.com/motemen/go-quickfix"] image:http://gocover.io/_badge/github.com/motemen/go-quickfix["Test Coverage", link="http://gocover.io/github.com/motemen/go-quickfix"]
The goquickfix command quick fixes Go source that is well typed but
Go refuses to compile e.g. "x declared and not used".== Installation
go get github.com/motemen/go-quickfix/cmd/goquickfix
== Usage
goquickfix [-w] [-revert] ...
Flags:
-revert=false: try to revert possible quickfixes introduced by goquickfix
-w=false: write result to (source) file instead of stdout== Description
While coding, sometimes you may write a Go program that is completely well typed
but `go build` (or `run` or `test`) refuses to build, like this:[source,go]
----
package mainimport (
"fmt"
"log"
)func main() {
nums := []int{3, 1, 4, 1, 5}
for i, n := range nums {
fmt.Println(n)
}
}
----The Go compiler will complain:
eg.go:5: imported and not used: "log"
Or
eg.go:9: i declared and not used
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 eg.go
and you will get the source rewritten so that Go compiles it well without
changing the semantics:[source,go]
----
package mainimport (
"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 safely.
== TODO
* `-d` option to show diffs
* `-hard=true` option to remove erroneous code rather than adding new code