Golang. Add a property to a struct at runtime

huangapple go评论56阅读模式
英文:

Golang. Add a property to a struct at runtime

问题

你好!根据你的要求,我将为你翻译以下内容:

class type User {
    name string
}

是否可以在运行时添加一个名为age的字段?

英文:
class type User {
    name string
}

Is it possible to add a field age at runtime?

答案1

得分: 7

不,这是不可能的。

即使使用Java或C++语法代替有效的Go语法也不行。

英文:

No it is not possible.

Not even with Java or C++ syntax instead of valid Go.

huangapple
  • 本文由 发表于 2015年8月15日 23:06:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/32026009.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定