Skip to content

proposal: cmd/vet: detect values assigned but not used #23142

Description

@rmanansa

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.9 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

on MacOS X Sierra

What did you do?

I wrote this code below and then run go vet. err is never used or checked.

	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)

	return body, resp.StatusCode, nil
}

What did you expect to see?

I expect that when I run $> go vet then I should see some error
notification that this err variable is not used or something.

What did you see instead?

None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ProposalProposal-Hold

    Type

    No type

    Projects

    Status
    Hold

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions