小编dan*_*nto的帖子

Go中的Init结构数组

我是Go的新手.这个问题让我疯了.你如何在Go中初始化结构数组?

type opt struct {
    shortnm      char
    longnm, help string
    needArg      bool
}

const basename_opts []opt { 
        opt {
            shortnm: 'a', 
            longnm: "multiple", 
            needArg: false, 
            help: "Usage for a"}
        },
        opt {
            shortnm: 'b', 
            longnm: "b-option", 
            needArg: false, 
            help: "Usage for b"}
    }
Run Code Online (Sandbox Code Playgroud)

编译器说它期待';' 在[]选择之后.

我应该把大括号'{'放到init我的struct数组中?

谢谢

arrays struct go

49
推荐指数
3
解决办法
8万
查看次数

标签 统计

arrays ×1

go ×1

struct ×1