|
|
|
|
|
by swah
4291 days ago
|
|
I also find Go pragmatic but lacking abstraction power. The other day I needed a stack, and the best solution I could find was this:
https://groups.google.com/d/msg/golang-nuts/iwlzqNa4h3g/xCy3... to be honest, if i need a stack, i usually implement it for the type
in question, or inline, as it's only a very small number of lines:
type stack []T
func (s *stack) push(t T) {
*s = append(*s, t)
}
func (s *stack) pop() T {
n := len(*s)
t := (*s)[n-1]
*s = (*s)[:n-1]
return t
}
And that's what I'm using... |
|