Downloading dependencies with Go modules can be significantly faster than using GOPATH
-based dependency management. A fresh dependency download experiment for this post took 9 minutes and 33.845 seconds in GOPATH
mode and 10.185 seconds in module mode. This post explains why. The key difference is that modules avoid deep repository clones and can use a module proxy.
For an introduction to Go modules, see https://blog.golang.org/using-go-modules.
GOPATH
-based dependency management downloads every dependency into GOPATH/src
, doing a deep clone of the version control repository in the process.
So, if you’re in GOPATH
mode and your project depends on A, which depends on B, which depends on C, the go
command will git clone
all three repositories (assuming they're all using git). …
Go has several built-in numeric types, “sets of integer or floating-point values.” Some architecture-independent types are uint8
(8-bit, unsigned integer), int16
(16-bit, signed integer), and complex128
(128-bit complex number). Curiously, the Go spec also includes architecture-dependent types:
uint
int
uintptr
How many bits do these types require? Unhelpfully, the spec says int
and uint
are the same size, “either 32 or 64 bits.” A uintptr
is “an unsigned integer large enough to store the uninterpreted bits of a pointer value.”
By far the most common of these three types I’ve seen is int
. If you know your program will only use non-negative numbers, you could use uint
instead. The most common time to use uintptr
is when you’re importing unsafe
, which is as safe to use as it sounds. …
About