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/go/packages: struct field tag json "command" not compatible with reflect.StructTag.Get: bad syntax for struct tag pair #31181

Closed
mbana opened this issue Apr 1, 2019 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mbana
Copy link

mbana commented Apr 1, 2019

https://github.com/golang/tools/blob/master/go/packages/external.go#L21

Linter complains:

struct field tag `json "command"` not compatible with reflect.StructTag.Get: bad syntax for struct tag pair

Code:

// Driver
type driverRequest struct {
	Command    string            `json "command"`
	Mode       LoadMode          `json:"mode"`
	Env        []string          `json:"env"`
	BuildFlags []string          `json:"build_flags"`
	Tests      bool              `json:"tests"`
	Overlay    map[string][]byte `json:"overlay"`
}

Feel free to close, if this is false positive.

@josharian
Copy link
Contributor

Looks real. Thanks for reporting.

cc @matloob

I'm surprised the builders aren't failing. I thought vet checked this too(?).

@josharian josharian changed the title https://github.com/golang/tools/blob/master/go/packages/external.go: struct field tag json "command" not compatible with reflect.StructTag.Get: bad syntax for struct tag pair x/tools/go/packages: struct field tag json "command" not compatible with reflect.StructTag.Get: bad syntax for struct tag pair Apr 1, 2019
@gopherbot gopherbot added this to the Unreleased milestone Apr 1, 2019
@josharian josharian added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 1, 2019
@ahsun-ahmed
Copy link
Contributor

according to the code, space is not allowed between key and value, only colon is allowed. i think the error is legit @josharian @mbana

@gopherbot
Copy link

Change https://golang.org/cl/170477 mentions this issue: go/packages: fix json struct tag on driverRequest.Command

@PrasadKasar
Copy link

copy and paste this in your code it should work fine:

// Driver
type driverRequest struct {
Command string json:"command"
Mode LoadMode json:"mode"
Env []string json:"env"
BuildFlags []string json:"build_flags"
Tests bool json:"tests"
Overlay map[string][]byte json:"overlay"
}

@golang golang locked and limited conversation to collaborators Jul 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants