GithubHelp home page GithubHelp logo

Comments (5)

ixre avatar ixre commented on August 16, 2024

windows上似乎有bug. 不支持匿名组合的方法继承。 go2o 是在mac下开发的,
跟windows有些不同,建议在非windows下使用。

from go2o.

bzhkl avatar bzhkl commented on August 16, 2024

type Base struct {
...
}

func (base *Base) Bar() { ... }

type Foo struct {
Base
...
}

func (foo *Foo) Bar() {
foo.Base.Bar()
...
}
据我有限的知识, 匿名组合继承的方式是上面这种, 可是在web_c.go, base_c.go中,类的名字完全一样,方法的声明也完全一样,且都属于www包, 从逻辑上讲, 如果我声明一个baseC类去调用GetPartnerId, 我该调用哪个呢(base_c.go 还是 web_c.go里的GetPartnerId)?

from go2o.

ixre avatar ixre commented on August 16, 2024

web_c.go 中调用GetPartnerId ,前提是web_c.go没有定义GetPartnerId。
如果有的话,相当于重写了。执行的是web_c.go 里的实现。

这处代码是gof里web 筛选器的应用,这里有个示例代码:
https://github.com/atnet/gof/blob/master/web/demo/web_demo.go

from go2o.

bzhkl avatar bzhkl commented on August 16, 2024

谢谢 .
web_c.go 中调用GetPartnerId ,前提是web_c.go没有定义GetPartnerId。
如果有的话,相当于重写了。执行的是web_c.go 里的实现。

这个我明白, 但是 
type listC struct {
*baseC
}

如果list_c.go 中的listC类调用了GetPartner,那么调用了web_c.go还是base_c.go中的呢? 我怎么可以看出web_c.go 中的GetPartner重写了base_c.go中的GetPartner , 而不是 base_c.go 中的GetPartner重写了web_c.go中的GetPartner?
他们的继承关系是怎么决定的,有什么原则吗?

from go2o.

ixre avatar ixre commented on August 16, 2024

我好像晕了,这我说不上来。这个在网上没有相关介绍的。
原则基本上是遵循OO的吧

from go2o.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.