gopls: How to suppress a warning?

543 views
Skip to first unread message

Torsten Bronger

unread,
Dec 22, 2022, 11:31:43 AM12/22/22
to golan...@googlegroups.com
Hallöchen!

My text editor uses gopls output to enrich the display of the source
code. Unfortunately, I have “struct literal uses unkeyed fields”
all over the place. I don’t want to do anything about it because
this would bloat by bson.D literals (currently interacting with
MongoDB). So, how can I suppress that?

Thank you!

Regards,
Torsten.

--
Torsten Bronger

Robert Findley

unread,
Dec 22, 2022, 7:10:49 PM12/22/22
to golang-nuts
You can disable the "composites" analyzer: https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md#composites

Update the "analyses" configuration to include "composites": false, as described here: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#analyses-mapstringbool 

Torsten Bronger

unread,
Dec 23, 2022, 3:21:39 AM12/23/22
to golan...@googlegroups.com
Hallöchen!

'Robert Findley' via golang-nuts writes:

> You can disable the "composites" analyzer: https://github.com/golang/
> tools/blob/master/gopls/doc/analyzers.md#composites
>
> Update the "analyses" configuration to include "composites": false,
> as described here: https://github.com/golang/tools/blob/master/gopls/
> doc/settings.md#analyses-mapstringbool

Thank you, this worked!

Ernest Micklei

unread,
Feb 12, 2024, 2:42:48 AMFeb 12
to golang-nuts
Applying the answer from Robert, you get
```
"gopls": {
"ui.diagnostic.analyses": {
"composites": false
}
},
```
Reply all
Reply to author
Forward
0 new messages