FAQ

On Friday, 17 April 2015 09:04:55 UTC+3, jonathan...@gmail.com wrote:
Hey Egon, Yes those are the kinds of things in Machine, actions too like
ChangeRaid() or whatever. So this sounds like what Paul was suggesting but
how do the extra interfaces help? Could you guys point out some usages in
the standard lib maybe (or stdlib tests) which use interfaces embedded in
structs?
I don't know such examples in stdlib.

Maybe these help you out:
https://github.com/nwidger/nintengo/blob/master/nes/nes.go#L52
http://gobot.io/

They also use interfaces a lot and are similar in building "machines".

The extra interfaces help, by being able to stub them out: e.g.

type Machine struct {
CPU
RAM
}

func TestCPU() {
m := Machine{CPU: NewCPU(), RAM: ramStub{}}
// ...
}

func TestMem() {
m := Machine{CPU: cpuStub(), RAM: NewRAM()}
// ...
}

Also could you elaborate more on the context. I mean I have no clue what it
is supposed to do (https://github.com/golang/go/wiki/howtoask). Essentially
you know what you are talking about and it seems like I got the gist of it,
but really I don't. (See Barnum effect)

Essentially... who will use the thing you build, where will it be used, how
is it valuable to the end user etc.

+ Egon

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 9 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 17, '15 at 1:15a
activeApr 17, '15 at 7:05p
posts9
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase