我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Go-包含切片的接口不会编译

type MyType interface {
    MyStringSlice []string
}

What is wrong with this?

It works well as a struct as in:

type MyType struct {
    MyStringSlice []string
}

but compiles with the following error when set as interface:

syntax error: unexpected [, expecting (

An interface can only hold methods or other interfaces. Have a look at the Language Specification.

近期文章

  • 强制去读取一个Uvarint的多个字节
  • 为什么FlagSet无法正确解析这些参数?
  • 正则表达式-解析正则表达式时出错:无效的转义序列:\\ K
  • 如何在Golang中为多种类型编写函数?
  • 如何在GO编程中的特定索引处更改byte []中的某些字节?
  • 找不到code.google.com/p/go.crypto/pbkdf2文件?
  • 动态解析文件
  • 如何在Go中制作模型
  • Go导入中的名称冲突
  • 从Go中的URL进行JSON解码
  • 转到线程-停止执行
  • 使用go-cairo绘画到屏幕
  • 生成核心转储
  • 去应用服务器?
  • 存储Go编码数据的通用功能
  • Go中的简单RPC调用
  • Go中具有嵌套XML-RPC的非编组
  • 在Go中编写通用数据访问功能
  • Go如何在G-WAN上运行?
  • 将JSON响应表示为struct

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华