Thursday, October 9, 2025
HomeGolangSuppressing Go vet - Getting Assist

Suppressing Go vet – Getting Assist


nolink

Am going through troubles persevering with my contribution to an open supply and I’II like your assist.

Downside:
Am upgrading a library that used the deprecated protobuf to make use of the brand new one. For those who’ve used the library earlier than you’ll discover the brand new lib has a few of it struct with discipline that as a

DoNotCopy mutex •[O]sync.Mutex•

The lib am upgrading will not be involved with whether or not the struct is copied or not… in-fact it does copies it and the logic across the codebase accounts for it however “Go vet” is the issue.

Complains of a copylocks.

The apparent answer Is to go a pointer to the struct, within the case is in a channel, and doing that will break

perform signatures,
kind declarations and
interfaces definition

to account for the pointers.
I don’t know if there’s a technique to suppress or maneuver round this. The “go vet” grievance are all the time on perform arguments or return values, when you’ll want me clarifying extra… I’ll be right here. :pray:t6:

Protobuf messages can’t be trivially copied. This library you’re utilizing won’t care about copies (what library is that this?), however the protobuf implementation does care. You must use a perform like proto.Clone to go copies round by worth, or else it’s important to go a pointer.



3 Likes

I’ve seen the Proto.Clone() and Proto.Merge()…, they appear like viable options however my concern is perform signatures. If the kind am having on a perform signature embeds the DoNotCopy kind or any kind that embeds it, go vet complains. How am i able to work my method round this?

Coping with “go vet” copylock complaints could be difficult. Evaluate your code design and use pointers selectively, contemplating the impression on perform signatures and interfaces. It’s essential to work inside Go’s finest practices for sturdy and environment friendly code.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments