Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goformat does not understand template arguments #2

Open
fskypro opened this issue Apr 27, 2023 · 1 comment
Open

goformat does not understand template arguments #2

fskypro opened this issue Apr 27, 2023 · 1 comment

Comments

@fskypro
Copy link

fskypro commented Apr 27, 2023

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

@mbenkmann
Copy link
Owner

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 mbenkmann changed the title the template argument weill be removed as bellow goformat does not understand template arguments Jul 8, 2023
gopherbot pushed a commit to golang/vscode-go that referenced this issue Jan 15, 2025
goformat can't format modern Go code that uses generics.
See mbenkmann/goformat#2

Change-Id: I6ef36db10677fd7e31ea20bb95d75db5d152edd1
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/641875
Reviewed-by: Michael Knyszek <[email protected]>
Commit-Queue: Hyang-Ah Hana Kim <[email protected]>
kokoro-CI: kokoro <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants