Skip to content

False positive when multiplying with int type struct field #7

@ajpetersons

Description

@ajpetersons

Struct fields are not taken into account when assessing duration multiplication. Consider a struct that has int field. When this field is multiplied by a valid duration value, linter throws an error (to multiply with duration, the field needs to be converted to time.Duration first).

See this example:

package main

import (
	"time"
)

type s struct {
	d int
}

func main() {
	ss := s{10}
	_ = time.Duration(ss.d) * time.Second
}

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