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

x/tools/gopls: support fillstruct for anonymous structs #39803

Open
stamblerre opened this issue Jun 24, 2020 · 2 comments
Open

x/tools/gopls: support fillstruct for anonymous structs #39803

stamblerre opened this issue Jun 24, 2020 · 2 comments
Assignees
Labels

Comments

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 24, 2020

The fix needs to be made in the analysisinternal package: https://github.com/golang/tools/blob/master/internal/analysisinternal/analysis.go#L110.

/cc @joshbaum

@stamblerre stamblerre added this to the gopls/v0.5.0 milestone Jun 24, 2020
@stamblerre stamblerre removed this from the gopls/v0.5.0 milestone Jun 24, 2020
@dnwe
Copy link

@dnwe dnwe commented Jun 29, 2020

RE: the original placeholder comment "// TODO: anonymous structs, but who does that"

This may already be well known, but the one place where that is key is when you're filling a slice of some struct:

ss := &appsv1.StatefulSet{
	Spec: appsv1.StatefulSetSpec{
		Template: v1.PodTemplateSpec{
			Spec: v1.PodSpec{
				Containers: []v1.Container{
					{},
				},
			},
		},
	},
}

Currently you'd have to add the redundant v1.Container in front of the {} to allow you to call the fillstruct codeaction, and then remove the redundant v1.Container afterwards

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 29, 2020

Change https://golang.org/cl/240463 mentions this issue: internal/lsp/analysis/fillstruct: permit anonymous structs to be filled

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.