-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
goreturns configuration #208
Comments
@tobstarr and I talked a bit about this on Twitter: https://twitter.com/tobstarr/status/522655779518939136. It seems like goreturns is working by itself but not in vim-go. I don't use vim, but if anyone can determine if there's something I need to fix in goreturns, please let me know and I will make a fix asap. |
Due to nature of Vim, before I do a formatting I'm creating a temporary file and doing the formatting on it. Now this temporary file is created in a the systems temp dir. Both ~ ❯ gofmt /var/folders/mc/hxkh39y93dn__458mq8xrbcm0000gn/T/vKrskW5/4
package main
import "errors"
func main() {
F()
}
func F() (string, int, error) {
return errors.New("foo")
}
~ ❯ goimports /var/folders/mc/hxkh39y93dn__458mq8xrbcm0000gn/T/vKrskW5/4
package main
import "errors"
func main() {
F()
}
func F() (string, int, error) {
return errors.New("foo")
}
~ ❯ goreturns /var/folders/mc/hxkh39y93dn__458mq8xrbcm0000gn/T/vKrskW5/4
no buildable Go source files in /var/folders/mc/hxkh39y93dn__458mq8xrbcm0000gn/T/vKrskW5 Another thing is (which I think should be changed). demo ❯ gofmt demo.go
package main
import "errors"
func main() {
F()
}
func F() (string, int, error) {
return errors.New("foo")
}
demo ❯ goimports demo.go
package main
import "errors"
func main() {
F()
}
func F() (string, int, error) {
return errors.New("foo")
}
demo ❯ goreturns demo.go
demo.go:10:2: wrong number of return values (want 3, got 1)
package main
import "errors"
func main() {
F()
}
func F() (string, int, error) {
return "", 0, errors.New("foo")
} |
Ah, got it. I will eliminate the error output. As for the temp file, goreturns needs the file to be in the existing dir because it builds and type checks the files, unlike gofmt/goimports which just parse it. Is it possible to eliminate the usage of a temp file? Thanks for looking into this. |
@sqs that's unfortunately not possible. Because the undo history in Vim break when I don't use the temp file. So maybe you can do something that goreturns can be executed in that folder. On my side when I change the behavior it will just break the plugin. |
This reverts commit 4cbe6c0. `goreturns` was returning output to stdout, rather than writing to a file. I was hoping for a drop-in replacement for `gofmt`/`goimports`. See also: fatih/vim-go#208
A lot of scripts filter files based on their name to make sure they operate only on the appropriate content. By appending a Go file type to a temporary file when running a formatter, we add support for a broader range of Go formating tools. Fixes fatih#208
A lot of scripts filter files based on their name to make sure they operate only on the appropriate content. By appending a Go file type to a temporary file when running a formatter, we add support for a broader range of Go formating tools. Fixes fatih#208
Append Go file type when creating temporary file A lot of scripts filter files based on their name to make sure they operate only on the appropriate content. By appending a Go file type to a temporary file when running a formatter, we add support for a broader range of Go formating tools. Fixes #208
I am struggling setting up vim-go with goreturns https://github.com/sqs/goreturns. What I tried is this:
but it seems it always ignores the
-w
flag (and just prints the output to stdout). Any tips on that?Thanx!
The text was updated successfully, but these errors were encountered: