Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Interfaces and Go. A bit confused.

  • 23-01-2016 06:10PM
    #1
    Registered Users, Registered Users 2 Posts: 2,238 ✭✭✭


    Hello,

    I am currently learning Go and looking at interfaces right now.

    To say the least I am a little confused. I do understand how it works generally but I'm not entirely sure how things are linked etc regarding mock and complete implementations for example.

    Example: I have an API interface. I then have a Go file with a full implementation. After that I created a Config struct. The full implementation is based on Config therefore Config implements API.

    My question is, when I am want to create a Mock what do I do? How would that look.

    Does anybody have any real life examples of this. Not just a simple Cirlce, Square etc implementing Shape :)

    Thanks in advance.


Comments

  • Registered Users, Registered Users 2 Posts: 7,189 ✭✭✭Talisman


    Do you want to write your Mocks by hand? The GoMock framework has a mockgen tool to generate mock interfaces for a given source file.


Advertisement