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

}
相关推荐
樱花树下的数学喵26 分钟前
手写简易 STL string|C++ 字符串底层实现
开发语言·c++
IT_陈寒1 小时前
SpringBoot自动配置的坑,这次终于爬出来了
前端·人工智能·后端
jimy11 小时前
C++ 报错的 qualifiers 的意思
开发语言·c++
RainbowFish1 小时前
# RAG 与智能体记忆:从原理到工程实践 > 一篇给学习者的总结。
后端
苏三说技术1 小时前
为什么越来越多人用Arthas 4 ?
后端
ServBay2 小时前
AI 开发平台出事后,API Key 泄露要怎么办
后端·aigc·ai编程
程序员老申2 小时前
解剖 PDF 底层二进制:一行代码如何抓出假薪资流水的 3 处破绽
后端
JuiceFS2 小时前
从 Meta 的工程实践看 EB 级 AI 存储架构
人工智能·后端
数据库小学妹2 小时前
MySQL NULL陷阱:NOT IN、三值逻辑与NOT EXISTS
数据库·后端·mysql
AI入职记2 小时前
10 万个会话吃掉 1.1G 内存:Spring AI 会话记忆的两个隐藏成本
后端