As a best-selling author, I invite you to explore my books on Amazon. Don't forget to follow me on Medium and show your support. Thank you! Your support means the world!
On 21 August 2026, two days after Go 1.27 shipped, a developer named Steven Hartland posted a failing build to golang-nuts. His test file had stopped passing, and this was the line he pasted.
./prog_test.go:27:44: %w wants operand of error type HTTPError, not pointer type *HTTPError (defeats errors.Is) He summed it up like this. "Under go 1.26 the errors.Is works as expected but under 1.27 you get a compile failure." So he did what the message seemed to ask and removed the &. Then, in his words, "two of the tests fail as HTTPError is not comparable." He added a custom Is method. Vet still complained. He ended by asking whether this was "a significant compatibility breakage introduced by 1.27?"
If you've just bumped your go directive and CI went red with that message, you're in the same spot. Here's my take, up front. Vet is right about your type, the fix its message seems to suggest is the wrong one, and the real fix is usually a small diff.
The PR that only changed one line of go.mod
First, a correction to the thread's wording, because it changes where you look. This isn't a compiler error. go build is perfectly happy. The failure comes from go test, which runs a small set of vet checks before your tests. The cmd/go docs list them as "atomic, bools, buildtag, directive, errorsas, ifaceassert, nilfunc, printf, stdversion, stringintconv, and tests."
The printf analyzer has been on that list for years. What's new is one more rule inside it. The Go 1.27 release notes describe it like this.
The printf analyzer now reports calls such as
fmt.Errorf("...: %w", p)in which the%woperandphas type*E, where the typeEitself implementserror. Wrapping a pointer in this way is usually a latent bug since it causes spurious failures of operations that test for a particular error type, such as a type assertion or call to errors.Is.
There's also a gate. The analyzer doc puts it in one line. "This feature applies only to files using at least Go 1.27." Installing the new toolchain doesn't trigger it. Changing go 1.26 to go 1.27 in go.mod does. That's why the PR that broke your build looks so innocent.
The rule itself has a long history. It started as issue 61342, opened in July 2023 as "Feature request: Show invalid usage of errors.As()". In March 2026 it was retitled "printf: report Errorf("%w", *E) where E implements error (defeats errors.AsType[E] etc)", put on the Go 1.27 milestone, and closed. So the idea took three years to ship, and it began as a complaint about errors.As, not about printf.
Two types that are both errors
Here's a type shaped like the one in the thread. It embeds an error, so it gets Error() for free, and it carries the response headers, which are a map.
// httperr/httperr.go: the version vet flags under go 1.27 package httperr import ( "errors" "fmt" "net/http" ) type HTTPError struct { error StatusCode int Header http.Header } var ErrNotFound = &HTTPError{ error: errors.New("not found"), StatusCode: http.StatusNotFound, } func GetUser(id string) error { return fmt.Errorf("get user %s: %w", id, ErrNotFound) } The test is the one everybody writes.
// httperr/httperr_test.go package httperr import ( "errors" "testing" ) func TestGetUserNotFound(t *testing.T) { err := GetUser("42") if !errors.Is(err, ErrNotFound) { t.Fatalf("got %v, want ErrNotFound", err) } } Under a go 1.26 directive, on the Go Playground's Go 1.26.11 toolchain, it passes. Change the directive to go 1.27 and run it on Go 1.27.4, and go test stops before a single test runs, with the same %w wants operand of error type HTTPError message from the top of this post. Under 1.26, errors.Is compares the *HTTPError in the chain with the *HTTPError sentinel, and two copies of the same pointer are equal. Fine for years.
So what is vet upset about? This is the part that trips people up. The embedded error field gives HTTPError an Error method on the value. In Go, a method that works on a value also works on a pointer to it. So both HTTPError and *HTTPError satisfy the error interface, which means you now have two distinct types that are both errors, that print the same message, and that errors.Is and errors.As treat as complete strangers at runtime.
In the thread, Sean Liao pointed at exactly this. The promoted Error method means .Error() works on both forms, and vet expects one of them to be the canonical error. Your code picks the pointer at the fmt.Errorf call. Vet sees a type whose own declaration says "I'm an error as a value" and flags the mismatch.
What errors.As actually sees in the chain
The "spurious failures" in the release notes only bite when a second piece of code makes the other choice. Picture a middleware, written by a teammate a year later, that wants the status code:
var he httperr.HTTPError if errors.As(err, &he) { w.WriteHeader(he.StatusCode) } HTTPError implements error, so this compiles, and the errorsas vet check has nothing to say. But errors.As walks the chain looking for an error whose type can be assigned to HTTPError. The chain holds a *HTTPError, and a pointer isn't assignable to the value type. Going by the documented contract, that if never fires, and nothing tells you why. The version that matches takes a pointer target.
var hp *httperr.HTTPError if errors.As(err, &hp) { w.WriteHeader(hp.StatusCode) } errors.Is has the same split. A *HTTPError in the chain will never equal an HTTPError target, because interface equality needs the same dynamic type first.
That's the latent bug.
Nothing is broken today if every caller happens to agree on the pointer. The type just lets them disagree, and before 1.27 nothing caught it when they did. Honestly, that's the bit that should bother you more than a red CI run.
The obvious fix that broke the tests
The message says vet wants "operand of error type HTTPError, not pointer type", so you delete the &:
// the fix most people try first; it quiets vet and breaks errors.Is here var ErrNotFound = HTTPError{ error: errors.New("not found"), StatusCode: http.StatusNotFound, } Vet has nothing left to report, because the operand is no longer a pointer. Green, briefly. Then the test runs on Go 1.27.4, and fails.
=== RUN TestGetUserNotFound prog_test.go:24: got get user 42: not found, want ErrNotFound --- FAIL: TestGetUserNotFound (0.00s) FAIL That's exactly what Hartland reported.
The reason is in errors/wrap.go. errors.Is starts by asking whether the target's type is comparable:
isComparable := reflectlite.TypeOf(target).Comparable() Inside the loop, the == check only runs if targetComparable && err == target. HTTPError holds an http.Header, which is a map, and a struct containing a map can't be compared with ==. So errors.Is skips the equality step entirely. Next it looks for an Is(error) bool method on each error in the chain. There isn't one. So it unwraps, finds nothing, and returns false.
No panic. Just a quiet false.
Plenty of people expect a panic here, because a direct err == target in your own code with two non-comparable values of the same type does panic at runtime. errors.Is guards against that and just answers no. The errors docs do warn you. "The target must be comparable."
So dropping the & swaps one problem for another. Before, you had a type that could be wrapped two ways. Now you have a sentinel that errors.Is can't match at all.
Three ways out, and the one I'd pick
The first way out is to put Error on the pointer. If your code already treats the error as a pointer everywhere, make that official. Replace the embedded interface with a named field and give the pointer its own method.
type HTTPError struct { Err error StatusCode int Header http.Header } func (e *HTTPError) Error() string { return e.Err.Error() } var _ error = (*HTTPError)(nil) var ErrNotFound = &HTTPError{ Err: errors.New("not found"), StatusCode: http.StatusNotFound, } Now HTTPError on its own doesn't implement error, and only *HTTPError does. The release-notes rule only fires when "the type E itself implements error", so this wrap is no longer reported. On Go 1.27.4, with a go 1.27 directive, vet is silent and the test passes. Jason Phillips said the same in the thread. The linter is satisfied once the error type implements error directly. Your errors.Is test still compares pointers, like it did under 1.26. The var _ error = (*HTTPError)(nil) line is for the next reader. It states, in code, which form is the error.
The second way is to go all-in on values. This was Liao's suggestion. If you want Is, he said, make the value type comparable. For a type that has to carry headers, that's not really possible, so the honest version is a value type with its own Is method.
func (e HTTPError) Is(target error) bool { t, ok := target.(HTTPError) return ok && t.StatusCode == e.StatusCode } Wrap the value (no &), and errors.Is reaches this method even though the == step was skipped. That follows from the source above. The cost is everywhere else. Every constructor that returns &HTTPError{...} changes, and so does every errors.As caller using a *HTTPError target, which now has the mirror-image problem. Hartland also argued in the thread that this costs more than the current pointer comparison. I haven't benchmarked that. It's plausible, since you're comparing fields instead of one pointer, but a 404 lookup is rarely your hot path.
The third way is to keep the & and add Is. This is what Hartland tried, and he reported that vet still failed. The reason, as far as I can tell from the rule's wording, is that the check is purely about types. It asks "is the operand *E, and does E implement error?" Whether you've written an Is method doesn't enter into it. An Is method changes runtime behaviour, and vet isn't looking at runtime.
And -vet=off? It's the workaround that came up in the thread, and it does make CI green. It also turns off every check in that list, including errorsas, the one that catches malformed errors.As calls. I wouldn't trade all of those to silence one.
My pick is the first one, for the case in the thread and most cases like it. If every call site already uses &HTTPError{} and every sentinel is a pointer, moving Error to the pointer receiver makes the type say what the code already does. The diff is a field rename and one method. (Okay, plus the var _ line, which I'd add anyway.) Pick the second only if your error really is a small value, like a status code and a message, with no maps or slices. Then it's comparable for free and dropping the & just works.
When the fix is an API change
The pointer-receiver fix is cheap inside an application. In a library it's a breaking change. Any downstream code that does return httperr.HTTPError{...} from a function returning error stops compiling, because the value no longer implements error. A caller's var he httperr.HTTPError; errors.As(err, &he) now has a target that doesn't implement error. errors.As panics on a target like that, and the errorsas check in go test exists to flag that shape of call. For a library, that's a major-version conversation, not a Friday-afternoon fix.
Two more things before you start editing.
The gate is per file, by Go version. In a monorepo with several modules on different go directives, the check will fire in some modules and not in others, even for the same pattern. Don't take a green module as proof the pattern is fine.
To find every type with this split personality, not just the ones that happen to be wrapped with %w, gopls now has a ptrtoerror analyzer. It reports a type E where both E and *E implement error and the code converts it to error one way in some places and the other way elsewhere. Its suggested fixes match the ones above. Standardise on *E, declare intent with var _ error = (*MyError)(nil), or move Error to a pointer receiver. It runs in your editor, not in go vet, so CI won't run it for you.
Hartland's question was whether he was missing something. He wasn't, really. His tests passed and the pattern worked, because every caller in his code agreed on the pointer. Vet in 1.27 is pointing out that the type itself never said so. Add one var _ error = (*YourError)(nil) line per error type, and the next person to write errors.As will see which form you meant.
📘 Checkout my latest ebook for free on my channel!
Be sure to like, share, comment, and subscribe to the channel!
101 Books
101 Books is an AI-driven publishing company co-founded by author Aarav Joshi. By leveraging advanced AI technology, we keep our publishing costs incredibly low—some books are priced as low as $4—making quality knowledge accessible to everyone.
Check out our book Golang Clean Code available on Amazon.
Stay tuned for updates and exciting news. When shopping for books, search for Aarav Joshi to find more of our titles. Use the provided link to enjoy special discounts!
Our Creations
Be sure to check out our creations:
Investor Central | Investor Central Spanish | Investor Central German | Smart Living | Epochs & Echoes | Puzzling Mysteries | Hindutva | Elite Dev | Java Elite Dev | Golang Elite Dev | Python Elite Dev | JS Elite Dev | JS Schools
We are on Medium
Tech Koala Insights | Epochs & Echoes World | Investor Central Medium | Puzzling Mysteries Medium | Science & Epochs Medium | Modern Hindutva

