I tried to debug a web server with Go using the command :GoDebugStart
The server starts with the debugger attached, so if I add a breakpoint the server stops and I can trace errors, see variables, etc.
The server didn't start. If I make a http request to the server's endpoint, it should give a response
vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):if has('vim_starting')
set nocompatible " Be iMproved
endif
let vimplug_exists=expand('~/.vim/autoload/plug.vim')
let g:vim_bootstrap_langs = ""
let g:vim_bootstrap_editor = "vim" " nvim or vim
if !filereadable(vimplug_exists)
if !executable("curl")
echoerr "You have to install curl or first install vim-plug yourself!"
execute "q!"
endif
echo "Installing Vim-Plug..."
echo ""
silent !\curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
let g:not_finish_vimplug = "yes"
autocmd VimEnter * PlugInstall
endif
" Required:
call plug#begin(expand('~/.vim/plugged'))
" go
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
call plug#end()
" Basic setup
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set bomb
set binary
set ttyfast
syntax on
set ruler
set number
" Fix backspace indent
set backspace=indent,eol,start
" session management
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.vim/session"
let g:session_autoload = "no"
let g:session_autosave = "no"
let g:session_command_aliases = 1
" Remove trailing whitespaces when saving file
autocmd BufWritePre * %s/\s\+$//e
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4
:version):VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58)
Included patches: 1-1453
Modified by [email protected]
go version):go version go1.11.4 linux/amd64
go env):
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jecepeda/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jecepeda/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build359144130=/tmp/go-build -gno-record-gcc-switches"Can you debug your server using dlv manually?
What happens when you :GoDebugStart?
I can debug manually the program with delve, and set breakpoints. However, when I run the application in the command line I need to type continue so the server can run.
This is what is shown when I call :GoDebugStart

There seems to be a bug currently, but in my testing, running :GoDebugContinue allowed me to workaround it and continue debugging as expected.
From reading https://github.com/go-delve/delve/blob/master/Documentation/cli/getting_started.md#debugging-main-packages, I think it's working as expected. The one improvement we could make is to send the continue command automatically if there are any breakpoints already set.
I've just checked :GoDebugContinue and it works perfectly. If this is the normal behaviour with delve, I wouldn't consider this as a bug.
Yeah, sending the continue command if a breakpoint is set is actually a good idea.
Thank you!
I've been taking a closer look at the debugger code in preparation for merging some PRs for it, and I've realized that the behavior you reported actually is a bug, because the code _already_ tries to send continue when the application starts.
I'll resolve this as soon as I can.
edit: I jumped the gun. I know now where to make this change, but the current code doesn't try to do it.
In keeping with dlv's usual workflow, I don't think vim-go should automatically run :GoDebugContinue, but I'm going to give it some more thought before closing this issue.
Perfect @bhcleek !! Either approach is fine to me. Thank you for the efforts of looking at this issue