我在 CI 工具上運行 go vet,并開始收到錯誤消息:composite literal uses unkeyed fields因為我正在實例化type A struct { *B}像這樣:A // b is of type *B我不在乎這個警告,想在我的獸醫檢查中禁用它。我該怎么做呢?
3 回答

慕標5832272
TA貢獻1966條經驗 獲得超4個贊
$ go doc cmd/vet
默認情況下執行所有檢查。如果任何標志顯式設置為 true,則僅運行那些測試。相反,如果任何標志顯式設置為 false,則僅禁用那些測試。因此 -printf=true 運行 printf 檢查,-printf=false 運行除 printf 檢查之外的所有檢查。
Unkeyed composite literals
Flag: -composites
Composite struct literals that do not use the field-keyed syntax.

大話西游666
TA貢獻1817條經驗 獲得超14個贊
如果您使用的是語言服務器。
Gopls on by default in the VS Code Go extension
"gopls": { "analyses": { "composites": false } },
添加回答
舉報
0/150
提交
取消