如何在只给定一个属性的情况下访问go结构体?

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

How to access a go struct whilst only being given one property of it?

问题

假设你有一个结构体的属性。你也知道结构体类型的名称,但是有一个特定的结构体叫做StructAccess,你想要定位它。你只知道id这个属性的值,其他属性一无所知。如何通过只有id的值(StructAccess.ID)获取StructAccess的其他值呢?

只是问一下。

英文:

So lets say you have one property of a struct. You also know the name of the struct type, but there is a specific struct created called StructAccess you want to target. You know the id, but only that property, and none others. How would you get the other values of StructAccess with only the value of id (StructAccess.ID)

Just Asking.

答案1

得分: 2

你只有id (StructAccess.ID)的值,无法获取StructAccess的其他值。这是不可能的。

英文:

> How would you get the other values of StructAccess with only the value of id (StructAccess.ID)

Not at all. This is impossible.

huangapple
  • 本文由 发表于 2022年11月5日 21:40:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/74328208.html
匿名

发表评论

匿名网友

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

确定