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

Support showing variable initialization values when printing types #97

Open
segevfiner opened this issue Nov 27, 2018 · 0 comments
Open

Comments

@segevfiner
Copy link

It's quite useful to be able to see the value of a const/var when godef is used to show hovers. It's currently only shown for consts.

The case for also doing this for variables is that consts in Go don't support any type, if you need some "constant" value that isn't scalar, e.g. a slice, you often see a global variable used instead.

Screenshot from VS Code

image

Example

$ godef -t -f foo.go foo
foo.go:5:7
const foo string = "foo"

$ godef -t -f foo.go baz
foo.go:8:5
baz string

Sample Code

package main

import "fmt"

const foo = "foo"
const Bar = "bar"

var baz = "baz"
var Qux = "Qux"

func main() {
	fmt.Println(foo, Bar, baz, Qux)
}

Originally reported at: microsoft/vscode-go#2146

cc @ramya-rao-a

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

1 participant