Helenr
这是我现在最好的解决方案......type A struct { R int64 S int64}type B struct { R A}然后在实施过程中...&B{ R: &A{ R, // S, - ideally we would not be able to pass in `S` }}我不喜欢这个解决方案,因为我们仍然可以传入S...更新:基于@HymnsForDisco 的回答,这可以编码为...// A type definition could be used `type AR int64`,// instead of a type alias (below), but that would// require us to create and pass the `&AR{}` object,// to `&A{}` or `&B{}` for the `R` field.type AR = int64type A struct { R AR S int64}type B struct { R AR}并实施为...&B{ R,}