News for hackers. Stuff that matters.
Re:How to Use Go Interfaces by holografix on Monday March 19, 2018 @11:26PM (#16625802)
Golang newbie here. Using a slice to hold different struct types of the same interface, finding it very annoying that every time I want to access a common attribute of the struct types I need to define a getter/setter.
Re:How to Use Go Interfaces by flashmob on Tuesday March 20, 2018 @05:01AM (#16626939)
Perhaps you could try creating a struct with just the common properties, then embed the common struct in all your 'extended' structs. Eg. http://www.hydrogen18.com/blog/golang-embedding.html
Re:How to Use Go Interfaces by holografix on Wednesday March 21, 2018 @10:37AM (#16638330)
That sounds like a bit of a hack. I like it.