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

}
相关推荐
椰椰椰耶8 分钟前
[SpringCloud][14]OpenFeign参数传递方法
后端·spring·spring cloud
黄毛火烧雪下16 分钟前
Java 核心知识点总结(一)
java·开发语言
onething36522 分钟前
Spring Boot + Spring AI 从入门到实战:7天转型计划 Day 3 —— 消息表设计 + 级联删除 + 事务管理
人工智能·后端
其实防守也摸鱼24 分钟前
软件安全与漏洞--软件安全编码与防御技术理论题库
开发语言·网络·安全·网络安全·软件安全·软件安全与漏洞
荣江25 分钟前
Hermes Agent 代码仓库打包工具使用指南(repomix-rs 高性能版)
后端
x1387028595725 分钟前
c语言中srtlen(指针使用计算字符长度)、传值和传址调用
c语言·开发语言·算法·visual studio
王某某人27 分钟前
LangChain4j 入门:Java 程序员的第一个 AI 对话程序
人工智能·后端
码农刚子32 分钟前
从零开始:在 Windows 服务器上部署 Node.js 项目(小白实战教程)
后端·node.js
Cache技术分享33 分钟前
435. Java 日期时间 API - Clock 灵活获取当前时间
前端·后端
iCxhust40 分钟前
C#进程管理程序
开发语言·汇编·stm32·单片机·c#·微机原理