mattn / go-tty

MIT License
211 stars 18 forks source link

method ReadRune() (rune, error) should have signature ReadRune() (rune, int, error) #53

Open nicks opened 2 months ago

nicks commented 2 months ago

Repro steps

If I try to run go vet on this library, I get:

go vet ./...
go: downloading github.com/mattn/go-runewidth v0.0.16
# github.com/mattn/go-tty
./tty.go:35:17: method ReadRune() (rune, error) should have signature ReadRune() (rune, int, error)

Root cause

ReadRune is now defined as a "standard method" in the go stdlib.

https://cs.opensource.google/go/x/tools/+/refs/tags/v0.24.0:go/analysis/passes/stdmethods/stdmethods.go;l=57

so the Go tooling complains if it has a non-standard signature.

Additional info

Mostly logging this here in case other people run into this problem. It causes all sorts of weird inscrutable errors downstream, e.g., if you try to use define an interface for TTY

type TerminalInput interface {
    ReadRune() (rune, error)
}

var _ TerminalInput = &tty.TTY{}

There's some discussion upstream about adding ways to suppress the error.

https://github.com/golang/go/issues/52445