[go-nuts] Re: how to constrain a type

2023-08-17 Thread Brian Candler
Then make a dummy interface, with a method with a unique name that you never call. On Thursday, 17 August 2023 at 16:48:28 UTC+1 Mark wrote: > Hi Brian, > Sorry for not being clearer. Ideally I don't want an interface: each Shape > is essentially a store of different kinds of values so at some

[go-nuts] Re: how to constrain a type

2023-08-17 Thread Brian Candler
I'm not sure without knowing *how* you want to use []*Shape{}. Perhaps you want Shape to be an interface? type Shape interface { DrawMe() } type BoxShape struct ... func (*BoxShape) DrawMe() { } type LineShape struct ... func (*LineShape) DrawMe() { } shapes := []Shape{} (Note that