Golang报错mixture of field:value and value initializers
Golang 在使用匿名成员初始化时,如果出现
mixture of field:value and value initializers 是因为初始化的方式不对,见代码:
package main import (
"fmt"
) type Person struct {
Name string
Age int
Sex string
} type Student struct {
Person
Id string
Grade string
} func main() {
s1 := Student{Person: Person{Name: "张三", Age: , Sex: "男"}, Id: "", Grade: "三年级"}
fmt.Printf("%+v\n", s1) s2 := Student{Person{"张三", , "男"}, "", "三年级"}
fmt.Println(s2) s3 := Student{Person{Name: "张三", Age: , Sex: "男"}, Id: "", Grade: "三年级"} //报错 mixture of field:value and value initializers(字段的混合:值和值初始化器)
fmt.Println(s3)
}
s3直接导致代码编译不过去,想要指定字段就必须按 s1的方式 Person:Person{xxx:"xxx"},要么就不指定按照s2的方式
Golang报错mixture of field:value and value initializers的更多相关文章
- golang 报错illegal rune literal
记录一下,今天运行一端代码遇到这个报错"illegal rune literal",代码如下: func main() { http.HandleFunc('/login', lo ...
- Golang报错:Cannot convert expression of type interface{} to type []byte
在使用golang实现后端登录逻辑的时候,碰到下面的问题:Cannot convert expression of type interface{} to type []byte 首先介绍下问题出现的 ...
- Django报错 The serializer field might be named incorrectly and not match any Got AttributeError when attempting to get a value for field `author_for` on serializer `KnownledgeBaseListSerializer`
1.问题描述,在设置,model部分字段的serialier时,出现如下报错 字段如下: # 知识库List class KnownledgeBaseListSerializer(serializer ...
- 外显子分析报错解决方案bin field of BAM record does not equal value computed based on alignment start and end, and length of sequence to which read is aligned
以下链接给出了解决方案:https://gatkforums.broadinstitute.org/gatk/discussion/4290/sam-bin-field-error-for-the-g ...
- 微信小程序 报错Setting data field "variableName" to undefined is invalid.
Setting data field "variableName" to undefined is invalid. 将数据字段“variableName”设置为未定义是无效的. ...
- Django中search fields报错:related Field has invalid lookup: icontains
models.py 文件 # coding:utf8from django.db import models class Book(models.Model): name = model ...
- Django中pycharm中 报错 ---ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'system.sysuser', bu
问题是:已经在settings.py文件中注册过app仍旧提示没有安装,并且使用makegirations命令时会抛出如下异常 解决方法: 找到自己的python3.x,进入site-packages ...
- Spring Cloud 使用 FeignClient 启动报错
我们首先来看一下报错信息 Description: Field businessFeignClient in com.ysc.service.BusinessConfigService require ...
- 【ActiveMQ】消息生产者自动注入报错:Could not autowire. No beans of 'JmsMessagingTemplate' type found
使用ActiveMQ过程中,定义消息生产者: package com.sxd.jms.producer; import org.springframework.beans.factory.annota ...
随机推荐
- sqlite 插入数据 too many variables
相关文档:http://www.sqlite.org/limits.html#max_variable_number 一次插入条数限制500,参数最多999个.
- eclipse的debug模式经常自动跳到TheadPoolExecutor的断点
1.问题:eclipse的debug模式经常自动跳到TheadPoolExecutor的断点,实在烦人 解决方法是: 在eclipse中选择Window->Preference->Java ...
- BZOJ 1426--收集邮票(概率与期望&DP)
1426: 收集邮票 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 504 Solved: 417[Submit][Status][Discuss] ...
- Qt5学习笔记(控件)
上面的程序仅仅可以显示一个 大概 的界面,对其进行单击等操作,界面仅有一些简单的反应,对应的程序不能得知界面有什么改变(是否进行单击选择,文本框中是否有文字输入) 下面对程序进行完善. T05Cont ...
- eclipse打包jar文件
论文仿真做线性回归分类在人脸识别中应用与研究,在单机下实现LRC算法后,又在Hadoop云平台下实现了该算法.在比较实验结果时候需要放在相同硬件条件下比较.但是LRC单机算法是在windows下的ec ...
- 找到windows中的环境变量
我的电脑,右击--->属性---->高级系统设置---->高级----->环境变量
- AssertJ断言系列-----------<数据库断言二>
那么,在实际的接口测试中,我们除了要断言响应的数据正确之外,可能有的还需要断言数据层是否数据真的有入库. assertj db是可以直接对数据库进行断言和操作的. 一.创建一个students表 CR ...
- 架构师养成记--29.redis开篇
主要有从下几点讲解 NOSQL(Redis) 简介.redis安装与部署 Redis基础事件类型详解 Redis高级命令 Redis与java的使用 Redis集群搭建 Redis集群与spring的 ...
- ltp-ddt eth过程中遇到的问题
eth_iperf_tcp ETH_S_PERF_IPERF_TCP_INTPACING_8K_1448B source 'common.sh'; iface=`get_eth_iface_name. ...
- java获取某段时间内的月份列表
/**获取两个时间节点之间的月份列表**/ private static List<String> getMonthBetween(String minDate, String maxDa ...