goformat icon indicating copy to clipboard operation
goformat copied to clipboard

goformat does not understand template arguments

Open fskypro opened this issue 2 years ago • 1 comments

func BoolToNumber[T T_Number](v bool) T { if v { return T(1) } return T(0) }


when run goformat commant, it will be changed to:

func BoolToNumber(v bool) T { if v { return T(1) } return T(0) }

fskypro avatar Apr 27 '23 06:04 fskypro

That's because goformat doesn't know anything about this syntax because it was added after the last sync with upstream gofmt. I haven't used Go in years, so I'm not going to do this sync anytime soon. Maybe you want to try it. There is a script get-upstream-changes that helps with this.

mbenkmann avatar Jul 08 '23 19:07 mbenkmann