-
-
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
Error when running Fmt: #24
Comments
That's really tricky, however the |
Hi @fatih, I've pulled and it's still outputting the original file in the console and doesn't seem to be formatting. This is what I'm seeing when writing to the file and when calling Fmt manually: :w
1 package test
2
3 import (
4 "fmt"
5 )
6
7 func main() {
8 fmt.Println("This is a test.")
"test.go" 9L, 82C written
Press ENTER or type command to continue
:Fmt
1 package test
2
3 import (
4 "fmt"
5 )
6
7 func main() {
8 fmt.Println("This is a test.")
9 }
Press ENTER or type command to continue Seems goimports is working from a terminal though (it fixed indenting on the ➜ vim-go git:(master) ~/.vim-go/goimports $GOPATH/src/test.go
package test
import (
"fmt"
)
func main() {
fmt.Println("This is a test.")
}
➜ .vim-go echo $?
0 If it helps, I'm using The Ulimate vimrc, and my extra plugins are:
My custom config is: set guifont=Source\ Code\ Pro\ Light\ 10
set cc=80
set nu
set autoindent
set noexpandtab
set tabstop=4
set shiftwidth=4
set cursorline I'm having a play around with ftplugin/go/fmt.vim to see if I can figure out something on this end. |
Upon further investigation, it seems goimports isn't in PATH. When I output the out variable I'm getting:
I'm using zsh instead of bash or bourne shell but I don't think that should cause an issue, I'll try to locate where ~/.vim-go is meant to be added to PATH. |
@beefsack can you provide more information. What is your operating system? You are sure you are not using any other plugins that might conflict with it? Btw I've just pushed a fix. There was a problem where it fallback to |
The following seems to fix the issue, but it means adding ~/.vim-go to path: ➜ .vim-go export PATH=$HOME/.vim-go:$PATH
➜ .vim-go gvim $GOPATH/src/test Changing the system call to include the path works too, but that would break gofmt calls so it's not much of a solution: let out = system(g:go_bin_path . g:go_fmt_command . " " . l:tmpname) |
@fatih, your last commit seems to have fixed it, thanks! 👍 |
vim's rename() function will output messages for non-fatal conditions, such as setting SELinux context. This will cause vim-go to annoyingly display a "Press ENTER to continue" message in conjunction with go_fmt_autosave = 1. For example, if the original Go source file is located on a FUSE filesystem that does not support `setxattr()`, and vim is compiled with SELINUX_ENABLED, `rename()` will attempt to call `setfilecon()`, which will fail and output an annoying error message. Call stack: ``` #0 mch_copy_sec (from_file=0xc2e3d0 "/tmp/vRUr7yU/7.go", to_file=0xc59910 "/fuse/test.go") at os_unix.c:2866 fatih#1 0x00000000004e7dcf in vim_rename (from=0xc2e3d0 "/tmp/vRUr7yU/7.go", to=0xc59910 "/fuse/test.go") at fileio.c:6731 fatih#2 0x0000000000480ab7 in f_rename (argvars=0x7ffec6fddac0, rettv=0x7ffec6fddd08) at evalfunc.c:9646 fatih#3 0x0000000000474011 in call_internal_func (name=0xc51b00 "rename", argcount=2, argvars=0x7ffec6fddac0, rettv=0x7ffec6fddd08) at evalfunc.c:1110 fatih#4 0x0000000000660d8e in call_func (funcname=0xc62d20 "rename", len=6, rettv=0x7ffec6fddd08, argcount_in=2, argvars_in=0x7ffec6fddac0, argv_func=0x0, firstline=12, lastline=12, doesrange=0x7ffec6fddcfc, evaluate=1, partial=0x0, selfdict_in=0x0) at userfunc.c:1507 fatih#5 0x0000000000660690 in get_func_tv (name=0xc62d20 "rename", len=6, rettv=0x7ffec6fddd08, arg=0x7ffec6fddd38, firstline=12, lastline=12, doesrange=0x7ffec6fddcfc, evaluate=1, partial=0x0, selfdict=0x0) at userfunc.c:455 fatih#6 0x0000000000666961 in ex_call (eap=0x7ffec6fddf38) at userfunc.c:3171 fatih#7 0x00000000004af3c2 in do_one_cmd (cmdlinep=0x7ffec6fde6c8, sourcing=1, cstack=0x7ffec6fde210, fgetline=0x666be0 <get_func_line>, cookie=0xc48fd0) at ex_docmd.c:2537 fatih#8 0x00000000004ac3d8 in do_cmdline (cmdline=0x0, fgetline=0x666be0 <get_func_line>, cookie=0xc48fd0, flags=7) at ex_docmd.c:1038 fatih#9 0x0000000000662123 in call_user_func (fp=0xbfe220, argcount=2, argvars=0x7ffec6fdf0e0, rettv=0x7ffec6fdf328, firstline=12, lastline=12, selfdict=0x0) at userfunc.c:954 fatih#10 0x0000000000660d01 in call_func (funcname=0xc59fb0 "go#fmt#update_file", len=18, rettv=0x7ffec6fdf328, argcount_in=2, argvars_in=0x7ffec6fdf0e0, argv_func=0x0, firstline=12, lastline=12, doesrange=0x7ffec6fdf31c, evaluate=1, partial=0x0, selfdict_in=0x0) at userfunc.c:1488 fatih#11 0x0000000000660690 in get_func_tv (name=0xc59fb0 "go#fmt#update_file", len=18, rettv=0x7ffec6fdf328, arg=0x7ffec6fdf358, firstline=12, lastline=12, doesrange=0x7ffec6fdf31c, evaluate=1, partial=0x0, selfdict=0x0) at userfunc.c:455 fatih#12 0x0000000000666961 in ex_call (eap=0x7ffec6fdf558) at userfunc.c:3171 fatih#13 0x00000000004af3c2 in do_one_cmd (cmdlinep=0x7ffec6fdfce8, sourcing=1, cstack=0x7ffec6fdf830, fgetline=0x666be0 <get_func_line>, cookie=0xc61900) at ex_docmd.c:2537 fatih#14 0x00000000004ac3d8 in do_cmdline (cmdline=0x0, fgetline=0x666be0 <get_func_line>, cookie=0xc61900, flags=7) at ex_docmd.c:1038 fatih#15 0x0000000000662123 in call_user_func (fp=0xc59340, argcount=1, argvars=0x7ffec6fe0700, rettv=0x7ffec6fe0948, firstline=12, lastline=12, selfdict=0x0) at userfunc.c:954 fatih#16 0x0000000000660d01 in call_func (funcname=0xc64a40 "go#fmt#Format", len=13, rettv=0x7ffec6fe0948, argcount_in=1, argvars_in=0x7ffec6fe0700, argv_func=0x0, firstline=12, lastline=12, doesrange=0x7ffec6fe093c, evaluate=1, partial=0x0, selfdict_in=0x0) at userfunc.c:1488 fatih#17 0x0000000000660690 in get_func_tv (name=0xc64a40 "go#fmt#Format", len=13, rettv=0x7ffec6fe0948, arg=0x7ffec6fe0978, firstline=12, lastline=12, doesrange=0x7ffec6fe093c, evaluate=1, partial=0x0, selfdict=0x0) at userfunc.c:455 fatih#18 0x0000000000666961 in ex_call (eap=0x7ffec6fe0b78) at userfunc.c:3171 fatih#19 0x00000000004af3c2 in do_one_cmd (cmdlinep=0x7ffec6fe1308, sourcing=1, cstack=0x7ffec6fe0e50, fgetline=0x4cc2a0 <getexline>, cookie=0x0) at ex_docmd.c:2537 fatih#20 0x00000000004ac3d8 in do_cmdline (cmdline=0xc65380 "call go#fmt#Format(-1)", fgetline=0x4cc2a0 <getexline>, cookie=0x0, flags=11) at ex_docmd.c:1038 fatih#21 0x00000000004ba24b in do_ucmd (eap=0x7ffec6fe15d8) at ex_docmd.c:7018 fatih#22 0x00000000004af390 in do_one_cmd (cmdlinep=0x7ffec6fe1d68, sourcing=0, cstack=0x7ffec6fe18b0, fgetline=0x4cc2a0 <getexline>, cookie=0x0) at ex_docmd.c:2528 fatih#23 0x00000000004ac3d8 in do_cmdline (cmdline=0x0, fgetline=0x4cc2a0 <getexline>, cookie=0x0, flags=0) at ex_docmd.c:1038 fatih#24 0x0000000000558c59 in nv_colon (cap=0x7ffec6fe1eb8) at normal.c:5388 fatih#25 0x000000000054ec81 in normal_cmd (oap=0x7ffec6fe1f58, toplevel=1) at normal.c:1121 fatih#26 0x00000000006bf4b9 in main_loop (cmdwin=0, noexmode=0) at main.c:1374 fatih#27 0x00000000006bdf2b in vim_main2 () at main.c:920 fatih#28 0x00000000006bb637 in main (argc=2, argv=0x7ffec6fe2168) at main.c:444 ``` Fixes fatih#1081
I'm incredibly impressed with the plugin, looking to switch to this full time for my Go development!
Have come across one issue, but I'm having a bit of trouble getting some troubleshooting information about it. Running Fmt is returning an error, but I can't seem to figure out what that error or the return code of goimports is.
My test file:
When running Fmt:
My Go version:
Checking to see what the Fmt command delegates to:
Running goimports manually seems to work:
I'm happy to keep debugging here locally as I'm assuming this will be very tricky to reproduce. Do you have any advice as to where I would start looking to get some more valuable debugging information?
The text was updated successfully, but these errors were encountered: