小编Har*_*son的帖子

go golang,语法错误:意外++,期待:

  func test(args ...string) {
    var msg map[string] interface{}

    i := 0
    msg["product"] = args[i++]
    msg["key"] = args[i++]
    msg["signature"] = args[i++]
    msg["string_to_sign"] = args[i++]
  }

  go build utils.go
Run Code Online (Sandbox Code Playgroud)

编译后,我收到错误信息

    ./utils.go:28: syntax error: unexpected ++, expecting :
    ./utils.go:28: missing statement after label
    ./utils.go:29: syntax error: unexpected ++, expecting :
    ./utils.go:30: syntax error: unexpected ++, expecting :
    ./utils.go:31: syntax error: unexpected ++, expecting :
    ./utils.go:36: syntax error: unexpected ++, expecting :
    ./utils.go:37: syntax error: unexpected ++, expecting :
Run Code Online (Sandbox Code Playgroud)

为什么我不能把i ++放在切片索引中?切片指数有任何限制吗?

syntax go

35
推荐指数
4
解决办法
5万
查看次数

标签 统计

go ×1

syntax ×1