Skip to content

S1024: incorrect suggested fix for embedded type #756

Description

@stamblerre

This reproduces with Staticcheck 2020.1.4 (built into gopls), go version is go1.14.1 darwin/amd64.

Repro:

package main

import "time"

type embedTime struct {
	time.Time
}

func main() {
	t := embedTime{}
	t.Sub(time.Now())
}

The suggested fix will convert t.Sub(time.Now()) to time.Until(t), which does not compile. The correct fix would be time.Until(t.Time).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions