https://play.golang.org/p/qxhocI6mjY
In this play, I get this error : invalid operation: s[0] (type AlmostSlice does not support indexing)
So I am wondering, is it possible to implement indexing ?
Given a struct like this :
type AlmostSlice struct {
Entities []string
Id string
Stuffs string
}
Is it possible to make it support indexing ?
s := AlmostSlice{Id: "bar", Entities: []string{"foo"}}
... := s[0]
s[0] = "stuffs"
For example, by implementing something like this :
func (s *AlmostSlice) Index(i int) string {
return s.Entities[i]
}