gmsm icon indicating copy to clipboard operation
gmsm copied to clipboard

[go1.18] change interface{} to any, and remove "+build" build tag

Open emmansun opened this issue 1 year ago • 2 comments

  1. change interface{} to any gofmt -w -r 'interface{} -> any' ./...

  2. remove "+build" tag go fix -fix=buildtag

emmansun avatar Aug 19 '22 03:08 emmansun

//go:build lines Go 1.17 introduced //go:build lines as a more readable way to write build constraints, instead of // +build lines. As of Go 1.17, gofmt adds //go:build lines to match existing +build lines and keeps them in sync, while go vet diagnoses when they are out of sync.

Since the release of Go 1.18 marks the end of support for Go 1.16, all supported versions of Go now understand //go:build lines. In Go 1.18, go fix now removes the now-obsolete // +build lines in modules declaring go 1.18 or later in their go.mod files.

For more information, see https://go.dev/design/draft-gobuild.

emmansun avatar Aug 19 '22 06:08 emmansun

The new predeclared identifier any is an alias for the empty interface. It may be used instead of interface{}.

emmansun avatar Aug 19 '22 06:08 emmansun