有沒有任何解決方案可以強制結構具有特定屬性(在接口中定義)?或者在接口中定義一個屬性(屬性,字段)?正如我所看到的,接口總是接受方法而不是屬性?( https://gobyexample.com/interfaces)type geo interface { PrintType() typ string//not function , but field}type circle struct { typ string}func (c circle) PrintType() { fmt.Println(c.typ)}謝謝
接口[golang]中的字段?
慕無忌1623718
2023-07-10 14:36:27