go/token has had a global "keywords" map filled at init time for years. Overall, the package's init time cost is small, as per GODEBUG=inittrace=1: init go/token @0.51 ms, 0.004 ms clock, 1776 bytes, 5 allocs init go/token @0.44 ms, 0.003 ms clock, 1776 bytes, 5 allocs init go/token @0.45 ms, 0.003 ms clock, 1568 bytes, 4 allocs However, adding the map size hint does help with the allocations: init go/token @0.45 ms, 0.002 ms clock, 944 bytes, 2 allocs init go/token @0.46 ms, 0.002 ms clock, 944 bytes, 2 allocs init go/token @0.55 ms, 0.003 ms clock, 1152 bytes, 3 allocs Three samples are rather unscientific, and the clock time is basically unchanged, but we might as well reduce the allocs. Change-Id: I48121a4cea4113d991882e32f274d7b7736800dc Reviewed-on: https://go-review.googlesource.com/c/go/+/391094 Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> |
||
|---|---|---|
| .github | ||
| api | ||
| doc | ||
| lib/time | ||
| misc | ||
| src | ||
| test | ||
| .gitattributes | ||
| .gitignore | ||
| AUTHORS | ||
| CONTRIBUTING.md | ||
| CONTRIBUTORS | ||
| LICENSE | ||
| PATENTS | ||
| README.md | ||
| SECURITY.md | ||
| codereview.cfg | ||
README.md
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://golang.org/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.