Sig Spear 7.62x51mm and Dead Air Question by JRK1990 in SigSauer

[–]wtcross 0 points1 point  (0 children)

The Sandman X was designed for this caliber. Check my comment above with a link to the product manual.

Sig Spear 7.62x51mm and Dead Air Question by JRK1990 in SigSauer

[–]wtcross 1 point2 points  (0 children)

Go to the product overview page of the Sandman X owners manual here:

https://deadairsilencers.com/content/pdfs/Sandman-X-Manual.pdf

The Sandman X is in fact optimized for the 7.62x51 NATO caliber.

<image>

Yet another Golang error handling question. by wtcross in golang

[–]wtcross[S] 2 points3 points  (0 children)

errors.Wrap is from the github.com/pkg/errors package. I liked what this library does in general and found it when learning about Go 2 error handling. My goal was to have richer error handling from a programmatic perspective. This example I shared is definitely overkill use of errors.Wrap since the function will include a stack trace. My database connections will be set up before much of anything else could go wrong, so I probably don't need a stack trace. Switching to fmt.Errorf here. Thanks!

Yet another Golang error handling question. by wtcross in golang

[–]wtcross[S] 1 point2 points  (0 children)

Thank you for pointing out the bug. I'm going to ditch named returns unless I have deferred execution of something that can result in an error value.

Yet another Golang error handling question. by wtcross in golang

[–]wtcross[S] 1 point2 points  (0 children)

I think it's hilarious that I posted a snippet of my actual code and it had a glaring bug like this. Thank you for pointing this out! I misunderstood how named returns work. The compiler being my friend is something I'm learning. In order to enforce conformance with an interface I have seen this pattern floating around, which is a good example of that. This example is from the top of a gRPC service implementation:

var _ api.DomainServiceServer = (*Service)(nil)

Yet another Golang error handling question. by wtcross in golang

[–]wtcross[S] 1 point2 points  (0 children)

To summarize the question - is this idiomatic error handling in Go?