我是一名 Python 開發(fā)人員,正在嘗試學(xué)習(xí) Go。目前我正在嘗試重構(gòu)我的第一個(gè)小項(xiàng)目,但我不太確定如何在結(jié)構(gòu)之間共享方法。長話短說,你會(huì)如何在 Go 中做這樣的 Python 代碼?class Super(object): def CommonMethod(self): print 'I am the common method.'class One(Super): def MethodOne(self): self.CommonMethod() print 'I am method one.'class Two(Super): def MethodTwo(self): self.CommonMethod() print 'I am method two.'one = One()one.MethodOne()two = Two()two.MethodTwo()
- 3 回答
- 0 關(guān)注
- 178 瀏覽
添加回答
舉報(bào)
0/150
提交
取消