Skip to content

G118 false positive when cancel is assigned to a package-level variable #1601

@somyabhattz

Description

@somyabhattz

G118 reports a false positive when the cancel function returned by context.WithCancel is assigned to a package-level variable in init() and called in a separate function within the same package (e.g., a signal handler triggered on SIGTERM/SIGINT).

main.go:87:34: G118: context cancellation function returned by WithCancel/WithTimeout/WithDeadline is not called (gosec)
	ctx, cancel = context.WithCancel(context.Background())
	                                ^
1 issues:
* gosec: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions