8000 S1024: incorrect suggested fix for embedded type · Issue #756 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

S1024: incorrect suggested fix for embedded type #756

Open

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0