Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

false positive #6

@jacobbogdanov

Description

@jacobbogdanov

the following code

package main

import (
	"context"
	"fmt"
)

func main() {

	ctx := context.Background()
	value := ctx.Value("key")
	if value == nil {
		panic("")
	}

	fmt.Println(value.(string))
}

produces this error (when running through golangci-lint version 1.36.0);

test.go:11:2: variable 'value' is only used in the if-statement (test.go:12:2); consider using short syntax (ifshort)
        value := ctx.Value("key")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions