package collections import "errors" type Stack struct { valores []interface{} } func (stack *Stack) Push (valor interface{}) { stack.valores = append(stack.valores, valor) } func (stack Stack) Lenght () int { return len(stack.valores) } func (stack Stack) IsEmpty () bool { return stack.Lenght() == 0 } func (stack *Stack) Pull () (interface{}, error) { if stack.IsEmpty() { return nil, errors.New("Pilha Vazia") } valor := stack.valores[stack.Lenght() - 1] stack.valores = stack.valores[:stack.Lenght() - 1] return valor, nil }