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) {

}
相关推荐
Evand J16 小时前
【MATLAB程序,一维非线性EKF与RTS】MATLAB,用于一维的位移与速度滤波和RTS平滑/高精度定位,带滤波前后的误差对比
开发语言·matlab·卡尔曼滤波·rts平滑·正向滤波
火云洞红孩儿1 天前
告别界面孤岛:PyMe如何用一站式流程重塑Python GUI开发?
开发语言·python
叫我辉哥e11 天前
新手进阶Python:办公看板集成ERP跨系统同步+自动备份+AI异常复盘
开发语言·人工智能·python
Loo国昌1 天前
【LangChain1.0】第五阶段:RAG高级篇(高级检索与优化)
人工智能·后端·语言模型·架构
晚风吹长发1 天前
初步了解Linux中的命名管道及简单应用和简单日志
linux·运维·服务器·开发语言·数据结构·c++·算法
C++ 老炮儿的技术栈1 天前
不调用C++/C的字符串库函数,编写函数strcpy
c语言·开发语言·c++·windows·git·postman·visual studio
布局呆星1 天前
闭包与装饰器
开发语言·python
计算机学姐1 天前
基于SpringBoot的演唱会抢票系统
java·spring boot·后端·spring·tomcat·intellij-idea·推荐算法
fyzy1 天前
C++写后端实现,实现前后端分离
开发语言·c++
huohuopro1 天前
Mybatis的七种传参方式
java·开发语言·mybatis