fatih / vim-go

Go development plugin for Vim
https://www.patreon.com/bhcleek
Other
15.95k stars 1.45k forks source link

Delve: function calls not allowed without using 'call' #3250

Closed CamiloGarciaLaRotta closed 3 years ago

CamiloGarciaLaRotta commented 3 years ago

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

  1. run :GoDebugTest in a test file
  2. stop at a moment in time where there is an error variable
  3. run :GoDebugPrint err.Error()

What did you expect to happen?

Being able to print the result of a function call. This is currently possible for other editors relying on delve:

What happened instead?

vim-go: evaluation failed: function calls not allowed without using 'call'

Configuration (MUST fill this out):

vim-go version: 1.25 (just pulled from the main branch)

vimrc you used to reproduce:

vimrc ```vim let g:go_debug_mappings = { \ '(go-debug-continue)': {'key': 'c', 'arguments': ''}, \ '(go-debug-breakpoint)': {'key': 'b'}, \ '(go-debug-stop)': {'key': 'x', 'arguments': ''}, \ '(go-debug-next)': {'key': 'n', 'arguments': ''}, \ '(go-debug-step)': {'key': 's'}, \ '(go-debug-print)': {'key': 'p'}, \} let g:go_version_warning = 0 let g:go_fmt_command = "goimports" let g:go_auto_type_info = 1 " display func signature when on top of it let g:go_auto_sameids = 1 " highlight same var let g:go_list_type = "quickfix" " only quickfix, no location list windows let g:go_def_mode = 'gopls' let g:go_info_mode = 'gopls' let g:go_rename_command = 'gopls' let g:go_gopls_complete_unimported = 1 let g:go_metalinter_enabled = ['govet', 'golint', 'errcheck', 'gocyclo', 'deadcode', 'gosimple', 'staticcheck'] let g:go_metalinter_autosave_enabled = ['govet', 'golint', 'errcheck', 'gocyclo', 'deadcode', 'gosimple', 'staticcheck'] let g:go_metalinter_deadline = "60s" let g:go_metalinter_autosave = 1 " vet, lint, errcheck on save let g:go_metalinter_command='golangci-lint run' ```

Vim version (first three lines from :version):

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 1 2021 21:01:15) macOS version - x86_64 Included patches: 1-2681

Go version (go version):

go version go1.16.5 darwin/amd64

Go environment

go env Output:

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/camilogarcialarotta/Library/Caches/go-build"
GOENV="/Users/camilogarcialarotta/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/camilogarcialarotta/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/camilogarcialarotta/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.16.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.16.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="/usr/bin/gcc"
CXX="/usr/bin/g++"
CGO_ENABLED="1"
GOMOD="/Users/camilogarcialarotta/go/src/github.com/github/authzd/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cp/bdrsjffj3hq1_pk6hm53pjf40000gn/T/go-build711817489=/tmp/go-build -gno-record-gcc-switches -fno-common"

gopls version

gopls version Output:

golang.org/x/tools/gopls v0.7.0
    golang.org/x/tools/gopls@v0.7.0 h1:JQBHW81Gsyim6iDjUwGoPeSpXrSqwen3isPJLfDfaYU=

vim-go configuration:

vim-go configuration
g:go_auto_type_info = 1
g:go_list_type = 'quickfix'
g:go_gopls_complete_unimported = 1
g:go_highlight_extra_types = 1
g:go_highlight_function_calls = 1
g:go_debug_mappings = {'(go-debug-step)': {'key': 's'}, '(go-debug-print)': {'key': 'p'}, '(go-debug-next)': {'key': 'n', 'arguments': ''}, '(go-debug-continue)': {'key': 'c', 'arguments': ''}, '(go-debug-stop)': {'key': 'x', 'arguments': ''}, '(go-debug-breakpoint)': {'key': 'b'}}
g:go_debug_windows = {'vars': 'rightbelow 75vnew', 'out': 'botright 10new', 'stack': 'rightbelow 25new'}
g:go_metalinter_deadline = '60s'
g:go_highlight_fields = 1
g:go_highlight_trailing_whitespace_error = 1
g:go_rename_command = 'gopls'
g:go_metalinter_autosave_enabled = ['govet', 'golint', 'errcheck', 'gocyclo', 'deadcode', 'gosimple', 'staticcheck']
g:go_metalinter_command = 'golangci-lint run'
g:go_def_mode = 'gopls'
g:go_auto_sameids = 1
g:go_highlight_chan_whitespace_error = 1
g:go_highlight_functions = 1
g:go_highlight_space_tab_error = 1
g:go_metalinter_enabled = ['govet', 'golint', 'errcheck', 'gocyclo', 'deadcode', 'gosimple', 'staticcheck']
g:go_metalinter_autosave = 1
g:go_highlight_types = 1
g:go_fmt_command = 'goimports'
g:go_jump_to_error = 1
g:go_info_mode = 'gopls'
g:go_loaded_gosnippets = 1
g:go_highlight_generate_tags = 1
g:go_version_warning = 0
g:go_highlight_build_constraints = 1
g:go_loaded_install = 1
g:go_highlight_array_whitespace_error = 1

filetype detection configuration:

filetype detection
filetype detection:ON  plugin:ON  indent:ON
bhcleek commented 3 years ago

Did you try using call err.Error()?

bhcleek commented 3 years ago

I should say that call err.Error() won't work either; there's a different error message that delve returns in that case. I'm trying to figure out exactly what change needs to be made to vim-go.

CamiloGarciaLaRotta commented 3 years ago

Oh thanks for the quick turnaround! Let me take it for a spin

CamiloGarciaLaRotta commented 3 years ago

👋🏽 @bhcleek I haven't been able to use call. Mind clarifying the usage 🙇🏼

Here you can see I start a debugging session, and I am able to :GoDebugPrint foo, but I am not able to call any method on foo itself even if it is part of the current stack.

dlv

bhcleek commented 3 years ago

:GoDebugPrint call foo.Error() is what you're looking for

ohadbitt commented 1 year ago

This (adding the phrase "call" before the function call) also works in vscode go debug Thanks