Skip to content

Instantly share code, notes, and snippets.

@hidetatz
Last active April 8, 2024 02:13
Show Gist options
  • Save hidetatz/7145b4d2ffddbda4ea00ff4cc50e2852 to your computer and use it in GitHub Desktop.
Save hidetatz/7145b4d2ffddbda4ea00ff4cc50e2852 to your computer and use it in GitHub Desktop.
How to build generics-aware goimports as of 2021/12/07
# In this script I'll use gotip, but there might be other ways
go install golang.org/dl/gotip@latest
# golang/go HEAD will be built
gotip download
# make sure gotip is available
gotip version
git clone https://github.com/golang/tools
cd tools
gotip install ./cmd/goimports/
# Now ~/go/bin/goimports (or somewhere else) can format Go code using generics!
@hidetatz
Copy link
Author

hidetatz commented Dec 7, 2021

For anyone looking for generics-aware gopls, this can help: https://github.com/golang/tools/blob/master/gopls/doc/advanced.md#working-with-generic-code

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