go composite literal uses unkeyed fields错误

1:背景

go vet composite literal uses unkeyed fields错误

2:废话少说,直接上代码

Go 复制代码
//main里面调用GetLoginAuth封装的方法
authDetail, authErr := opMini.GetLoginAuth(ctx, openyun.LoginAuthParam{
    deviceId,
})


//对应方法类
type LoginAuthParam struct {
	DeviceId string
}

func () GetLoginAuth(ctx utils.Context, params LoginAuthParam) (t LoginAuthInfoData, err error) {

}

以上代码在本地可以正常运行,也能正常编译,但语法检查会报错:

在使用go vet进行语法检查时, 报了这么个错composite literal uses unkeyed fields

3:解决(增加对应字段key)

在调用时候需要加上对应的字段可名称,不能直接给值

Go 复制代码
//main里面调用GetLoginAuth封装的方法
authDetail, authErr := opMini.GetLoginAuth(ctx, openyun.LoginAuthParam{
    DeviceId:deviceId   //在调用时候需要加上对应的字段key  !!!!!!!!!!!!
})


//对应方法类
type LoginAuthParam struct {
	DeviceId string
}

func () GetLoginAuth(ctx utils.Context, params LoginAuthParam) (t LoginAuthInfoData, err error) {

}
相关推荐
温轻舟14 分钟前
Python自动办公工具01-Excel文件编辑器
开发语言·python·编辑器·excel·温轻舟
Codebee31 分钟前
Qoder CLI 与 OneCode 平台深度整合技术实践:CLI委托驱动的开发范式革新
后端
码事漫谈37 分钟前
C++程序执行起点不是main:颠覆你认知的真相
后端
可观测性用观测云44 分钟前
玩转 Pipelines 之修正链路错误状态码
后端
码事漫谈1 小时前
C++26:开启新纪元
后端
龙卷风04051 小时前
深入理解Spring AI Alibaba多Agent系统:图结构驱动的智能协作
人工智能·后端
用户8356290780512 小时前
C# 高效生成 Word 表格:复杂表格创建实战指南
后端·c#
q***42822 小时前
SpringCloudGateWay
android·前端·后端
我是小妖怪,潇洒又自在2 小时前
springcloud alibaba搭建
后端·spring·spring cloud
纵有疾風起2 小时前
C++——多态
开发语言·c++·经验分享·面试·开源