package two type stack struct { items []interface{} } func newStack() *stack { return &stack{} } func (s *stack) Push(element interface{}) interface{} { s.items = append(s.items, element) return element } func (s *stack) Pop() interface{} { l := len(s.items) element := s.items[l-1] s.items = s.items[:l-1] return element } func (s *stack) Peek() interface{} { return s.items[len(s.items)-1] } func (s *stack) Len() int { return len(s.items) } func (s *stack) IsEmpty() bool { return s.Len() == 0 }