Skip to content
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

Godef has been Invalid in code with "import C" #3624

Open
BraveSoilder opened this issue Dec 29, 2023 · 4 comments
Open

Godef has been Invalid in code with "import C" #3624

BraveSoilder opened this issue Dec 29, 2023 · 4 comments

Comments

@BraveSoilder
Copy link

What did you do? (required: The issue will be closed when not provided)

:GoDef in code with “import C”

What did you expect to happen?

go to taget function

What happened instead?

 Report:vim-go: godef: no file found at search pos 455; 
 but when i deleted "import C",it suddenly successed to go to target function

Configuration (MUST fill this out):

vim-go version:

    code from branch of "master e2e7ad7c" and PluginUpdated by .vimrc

vimrc you used to reproduce:

vimrc
 let g:go_bin_path = expand("~/.vim/bin")
 let g:go_highlight_functions            = 1
 let g:go_highlight_methods              = 1
 let g:go_highlight_fields               = 1
 let g:go_highlight_types                = 1
 let g:go_highlight_operators            = 1
 let g:go_highlight_build_constraints    = 1
 let g:go_def_mode = 'godef'
 let g:go_fmt_command = "goimports"
 let g:go_play_open_browser = 0
 let g:go_autodetect_gopath = 1
 let g:go_list_type = "quickfix"
 let g:go_gopls_enabled = 1
 au FileType go map <F12>      <Plug>(go-def)
 au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
 " go-doc
 au FileType go nmap <Leader>gd <Plug>(go-doc)
 au FileType go nmap <Leader>gv <Plug>(go-doc-vertical) 
 "go-debug
 au FileType go nmap <F9> :GoDebugBreakpoint<CR>
 au FileType go nmap <Leader>ds :GoDebugStart<CR>
 au FileType go nmap <Leader>dt :GoDebugStop<CR>
 let g:go_debug_mappings = {
      \ '(go-debug-continue)':   {'key': '<F5>'},
      \ '(go-debug-print)':      {'key': '<F6>'},
      \ '(go-debug-breakpoint)': {'key': '<F9>'},
      \ '(go-debug-next)':       {'key': '<F10>'},
      \ '(go-debug-step)':       {'key': '<F11>'},
      \ '(go-debug-halt)':       {'key': '<F8>'},
   \ }
 let g:go_debug_windows = {
       \ 'vars':       'rightbelow 30vnew',
       \ 'stack':      'rightbelow 20new',
 \ }
 
 au FileType go nmap <Leader>i <Plug>(go-info)
 au FileType go nmap <Leader>e <Plug>(go-rename)

Vim version (first three lines from :version):

VIM - Vi IMproved 8.1

Go version (go version):

go version go1.21.5 linux/386

Go environment

go env Output:
GO111MODULE='on'
GOARCH='386'
GOBIN=''
GOCACHE='/home/myLinux/.cache/go-build'
GOENV=''/home/myLinux/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='386'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE=''/home/myLinux/godev/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH=''/home/myLinux/godev'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/data/env/golang/default'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/data/env/golang/default/pkg/tool/linux_386'
GOVCS=''
GOVERSION='go1.21.5'
GCCGO='gccgo'
GO386='sse2'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m32 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2194529222=/tmp/go-build -gno-record-gcc-switches'

gopls version

gopls version Output:
golang.org/x/tools/gopls v0.8.3
    golang.org/x/tools/gopls@v0.8.3 h1:Mxm94ix8oSARQ6svioO6SxKEYWT/VCP54/448LOHzrk=
@bhcleek
Copy link
Collaborator

bhcleek commented Dec 29, 2023

This would be a problem for https://github.com/rogpeppe/godef then, because the error is actually coming from godef.

@BraveSoilder
Copy link
Author

BraveSoilder commented Jan 2, 2024

This would be a problem for https://github.com/rogpeppe/godef then, because the error is actually coming from godef.

ok,thanks for your help; but it looks like dosen't been maintained anymore

@bhcleek
Copy link
Collaborator

bhcleek commented Jan 2, 2024

Yes, godef is old and the community has mostly moved on from it. I'd recommend changing your g:go_def_mode setting to use gopls instead (see :help g:go_def_mode). Alternatively, you could fix the problem in godef and install it locally.

@bhcleek
Copy link
Collaborator

bhcleek commented Jan 7, 2024

@BraveSoilder I just want to make sure you know that you can use gopls instead of godef for jumping to definitions. Since 'gopls' is the default value for g:go_def_mode, you can either remove let g:go_def_mode = 'godef' from your .vimrc or you can change it to let g:go_def_mode = 'gopls' to start using gopls instead. You'll find that gopls is faster than godef.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants