What Is New in Go 1.11
Go 1.11 introduces significant features focused on dependency management and WebAssembly support, alongside the usual performance improvements and tooling updates.
| Category | Key Changes |
|---|---|
| New Features | Modules (vgo prototype), WebAssembly Support |
| Improvements | Compiler & Toolchain, Runtime, Core Library |
| Changes | Ports, Environment Variables |
How does Go 1.11 change dependency management?
Go 1.11 ships with initial support for versioned modules, an evolution beyond the GOPATH workspace mode. This is the first official release of the 'vgo' prototype, allowing dependency management without a project needing to live inside GOPATH.
You can activate module support by setting the environment variable GO111MODULE=on or by working outside your GOPATH. A module is defined by a go.mod file that lists its dependencies and their versions, providing reproducible builds.
What is the new WebAssembly support in Go 1.11?
This release adds a new port for compiling Go code to WebAssembly (wasm). You can now build your Go applications to run in a web browser by setting GOOS=js and GOARCH=wasm during compilation.
A separate $GOROOT/misc/wasm directory contains a JavaScript support file and a Node.js script to facilitate executing the generated .wasm files. This opens up a new frontier for writing web frontends in Go.
What performance gains can I expect from Go 1.11?
The compiler and toolchain saw meaningful optimizations. The compiler now generates more efficient code, and the build process itself is faster due to enhanced caching and the ability to precompute object dependencies for the standard library.
On the runtime side, the defer mechanism is now much more efficient, reducing the overhead of using defer statements in performance-critical code. The garbage collector also has improved pacing, which should lead to lower latency.
What are the key changes to the Go toolchain?
The go tool now supports module-aware mode, which is the foundation for the new dependency management. The go test command runs each package test in a separate process, improving isolation and reliability.
For the linker, a new -dumpdep flag helps with debugging. The go doc command is now more precise, and the go vet tool includes new checks for suspicious code patterns like string(int) conversions.
Were there any significant port additions or changes?
Yes, besides the major addition of WebAssembly, this release drops support for the native FreeBSD 10.x port. The minimum supported FreeBSD version is now 11.2 or later. Support for 32-bit MIPS was also improved.
FAQ
Is Go 1.11's module support stable and ready for production?
It's a solid prototype but was explicitly labeled as experimental in this release. It's great for trying out and providing feedback, but for critical production systems, you might want to wait for the API to stabilize in a subsequent release.
How do I start using modules in my existing project?
Move your project directory outside of GOPATH, run go mod init [module-path] to create a go.mod file, and then run go build to automatically resolve and add dependencies.
What happens to my existing vendor/ directory with modules?
The module system can integrate with it. The go mod vendor command will create a vendor/ directory from your module dependencies, and the go build -mod=vendor flag will use it.
Can I compile my existing Go code to WebAssembly without changes?
Most pure Go code that doesn't use OS-specific syscalls will compile. However, you'll need to use the provided JavaScript glue code to interact with the DOM and other browser APIs from your Go program.
Why is the defer performance improvement a big deal?
Before 1.11, using defer in hot code paths had measurable overhead, which discouraged its use for things like unlocking mutexes. The new implementation makes the cost negligible, so you can use defer more freely without performance worries.