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

GoRun shows a blank line in quickfix window when panic is received #2328

Open
preslavmihaylov opened this issue May 30, 2019 · 3 comments · May be fixed by #2861
Open

GoRun shows a blank line in quickfix window when panic is received #2328

preslavmihaylov opened this issue May 30, 2019 · 3 comments · May be fixed by #2861

Comments

@preslavmihaylov
Copy link

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

Given the following source file:

package main

import "fmt"

func main() {
	fmt.Println("vim-go")
	panic("err")
}

I typed :GoRun.

What did you expect to happen?

Quickfix window opens with line that failed + output showing the panic.

What happened instead?

Quickfix window opens with a blank line & pointer to line that failed.
image

Configuration (MUST fill this out):

vim-go version:

vim-go @ 3e9a292

vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):

vimrc
""" -------------------- vim-go -------------------------
" all errors are shown in the quickfix window
let g:go_list_type = "quickfix"

" automatically add import paths when saving file
"let g:go_fmt_command = "goimports"

" enable syntax highlighting
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_generate_tags = 1

" enable go metalinter
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']

" let g:go_metalinter_autosave_enabled = ['vet', 'golint', 'errcheck']
let g:go_metalinter_autosave_enabled = ['vet', 'errcheck']
let g:go_metalinter_autosave = 1

" automatically show GoInfo output
" let g:go_auto_type_info = 1

" automatically highlight variable your cursor is on
let g:go_auto_sameids = 1

" adjust quickfix window height
let g:go_list_height = 8

" terminal opens as a horizontal split below the main window
let g:go_term_mode = "split above"

" More verbose output on failed tests in quickfix window
let g:go_test_show_name = 1

Vim version (first three lines from :version):

NVIM v0.3.4
Build type: Release
LuaJIT 2.1.0-beta3

Go version (go version):

go version go1.11.4 linux/amd64

Go environment

go env Output:
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pmihaylov/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/pmihaylov/programming/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-build861316129=/tmp/go-build -gno-record-gcc-switches"

@preslavmihaylov preslavmihaylov changed the title GoRun shows an empty quickfix window when panic is received GoRun shows a blank line in quickfix window when panic is received May 30, 2019
@bhcleek
Copy link
Collaborator

bhcleek commented Jun 1, 2019

vim-go won't parse the panic output, because there isn't a reliable way to tell non-panic output from the panic output, especially if there's a substantial output.

vim-go really shouldn't show any errors unless the exit code from go run is 2; that's the exit code when there's a problem compiling what's being go run. If the exit code is 1, then there was an error at runtime.

@preslavmihaylov
Copy link
Author

preslavmihaylov commented Jun 2, 2019

Can we at least then show a generic message in the quickfix window line, such as runtime error occurred.

I actually noticed that vim-go showed the line, where the runtime error occurred while writing this issue.
I believe an explicit message will make it easier for users to detect where the problem is rather than a blank line.

@bhcleek
Copy link
Collaborator

bhcleek commented Jun 2, 2019

Yes. I'm planning to refactor the :GoRun so that it will parse compilation errors if there are any, but leave the runtime errors as output in the usual window that holds the output.

@bhcleek bhcleek added this to the vim-go 1.22 milestone Aug 31, 2019
@bhcleek bhcleek removed this from the vim-go 1.22 milestone Jan 12, 2020
bhcleek added a commit to bhcleek/vim-go that referenced this issue Apr 26, 2020
Capture error messages from panic. I'm not 100% sure that this is the
right course of action. It might be better to treat panics as successes,
because non-zero exit status from go run are generally discarded except
for compiler errors. This change is inconsistent with that fact and may
lead people to expect that non-zero exit statuses from the command being
run should always populate the quickfix list.

Fixes fatih#2328
@bhcleek bhcleek linked a pull request Apr 26, 2020 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants