Golang recently introduced their Go 1.17, which implements several changes to toolchain, runtime, and libraries. Instead of relaying every single change in the Golang 1.17 release, we wanted to highlight some changes that will impact the Golang errors you receive within your application.
Without further ado, here is a quick list of Golang changes to be aware of with this new release.
This new release updated the //go:build
lines and how they function within code, hopefully leading to fewer Golang errors.
Before 1.17, the //+ build
line could confuse both syntax and placement in code. Some issues associated with the //+ build
include:
/* */
) and package declaration ignored due to placementWith this new release, the go command will value //go:build
over // +build
lines. It’s the hope that using this boolean expression and relaxing constraints will result in fewer errors.
Keep in mind that even though Go will value //go:build
over //+ build
, it will still recognize and fully support both forms, in order to aid in migration, gofmt
now automatically synchronizes the two forms.
Go 1.17 introduced a new warning for methods named As
, Is
, or Unwrap
. If one of these methods has a different signature than what’s expected by the errors
package, it will result in a warning. Signatures and methods that do not correlate will be ignored.
Before Golang v 1.17, you could use a semicolon (;) or ampersand (&) within net/url
and new/http
packages as a setting separator in URL queries. This is no longer the case. Using non-percent-encoded semicolons within a net/http
setting will result in a Server.ErrorLog
.
For users who aren’t comfortable with this new setting style, you may use AllowQuerySemicolons
handler wrapper within your net/http
package to restore the old behavior. Golang does warn that doing this could open you up to potential security issues.
Since this release alters how Golang calls functions, if your code violates unsafe.pointer
rules when passing a function argument, it may behave in unexpected ways. While not a Golang error necessarily, it could result in issues within your Go application.
As a Golang developer, keep in mind that these four major changes might result in new warnings, errors, and behaviors within your Golang application.
Along with these major changes, Golang also released a few minor changes to their library that could impact errors.
If the private and parent key don’t match, you’ll receive an error.
Receiving ErrClosed
sentinel error and the ParseError
will now implement a net.Error
.
You’ll receive an error if the ReadRequest
function contains multiple Host headers.
If you haven’t done so yet, we strongly recommend checking out and reading through Golang’s updates. While we only focused on changes to Go errors and warnings, their updates include various improvements to performance and security.
Looking for an easier way to find and resolve errors within your Golang code? Give Airbrake Error and Performance Monitoring a try!
Our error monitoring and debugger give you all the tools you need to quickly fix errors within your application before they have time to impact your users. Plus, every Airbrake account gives you unlimited users, unlimited projects, and unlimited integrations.
Discover the power of Airbrake today with a free 14-day trial.