On Sunday, June 1, 2025 at 11:21:28 PM UTC+8 Oliver Eikemeier wrote:

> Am 27.06.2024 um 05:17 schrieb Ian Lance Taylor <ia...@golang.org>: 
> 
> On Tue, Jun 25, 2024 at 9:37 PM 'Axel Wagner' via golang-nuts 
> <golan...@googlegroups.com> wrote: 
>> 
>> you might be interested to learn that Ian has filed a CL adding an FAQ 
entry. 
> 
> Now committed at https://go.dev/doc/faq#zero_size_types . 
> 
> Ian 

Thanks for that. I discovered that comparing pointers to ZSTs is pretty 
popular in Go: 

- x/sync/singleflight: 
https://cs.opensource.google/go/x/sync/+/refs/tags/v0.14.0:singleflight/singleflight_test.go;l=78
 

- Delve: 
https://github.com/go-delve/delve/blob/v1.24.2/service/debugger/debugger.go#L387
 

- Grafana: 
https://github.com/grafana/grafana/blob/v12.0.1/pkg/services/serviceaccounts/extsvcaccounts/service.go#L353
 

- Skaffold: 
https://github.com/GoogleContainerTools/skaffold/blob/v2.16.0/pkg/skaffold/hooks/render.go#L93
 

- Coder: https://github.com/coder/coder/blob/v2.22.1/cli/ssh.go#L578 

- quic-go: 
https://github.com/quic-go/quic-go/blob/v0.52.0/connection_test.go#L1008 

- SigStore Cosign: 
https://github.com/sigstore/cosign/blob/v2.5.0/cmd/cosign/cli/attest/attest_blob_test.go#L60
 

Seems like a classic example of Hyrum's Law, we now have a lot of code that 
depends on runtime.zerobase. 


It looks all of bad code (using errors.Is) should use errors.As instead.
This indeed reflects that the design of the errors APIs is prone to being 
misused.

An "errros/v2" is really needed to avoid such misuses.
 



I’ve written a linter along with an accompanying blog post about the 
subject: 

fillmore-labs.com/zerolint: https://github.com/fillmore-labs/zerolint 

“The Perils of Pointers in the Land of the Zero-Sized Type”: 
https://blog.fillmore-labs.com/posts/zerosized-1/ 


I would be interested whether I got the “default” level right. Or maybe 
everything wrong. 

Thanks for the insight, again 
Oliver 


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/7750b85c-2e09-4e42-a290-480b81caf19dn%40googlegroups.com.

Reply via email to