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

}
相关推荐
俞凡9 小时前
分布式日志指标系统设计
后端
策策策lv119 小时前
杂记-@Transactional使用的一点记录
后端
派大鑫wink9 小时前
【Day14】集合框架(二):Set 接口(HashSet、TreeSet)去重与排序
java·开发语言
code_std9 小时前
保存文件到指定位置,读取/删除指定文件夹中文件
java·spring boot·后端
sort浅忆10 小时前
deeptest执行接口脚本,添加python脚本断言
开发语言·python
趣知岛10 小时前
JavaScript性能优化实战大纲
开发语言·javascript·性能优化
汤姆yu10 小时前
基于springboot的热门文创内容推荐分享系统
java·spring boot·后端
im_AMBER10 小时前
weather-app开发手记 04 AntDesign组件库使用解析 | 项目设计困惑
开发语言·前端·javascript·笔记·学习·react.js
lkbhua莱克瓦2410 小时前
MySQL介绍
java·开发语言·数据库·笔记·mysql
武昌库里写JAVA10 小时前
在iview中使用upload组件上传文件之前先做其他的处理
java·vue.js·spring boot·后端·sql