package main

import "fmt"

type Stack struct {
    data []string
}
func (s *Stack) Push(x string) {
    s.data = append(s.data, x)
}
func (s *Stack) Pop() (string) {
    if len(s.data) == 0 {
        return "Pop error: Stack is empty"
    }
    n := len(s.data) - 1
    res := s.data[n]
    s.data[n] = "" // to avoid memory leak
    s.data = s.data[:n]
    return res   
}
func (s *Stack) Size() int {
    return len(s.data)
}
func main() {
    var s Stack
    fmt.Println(s.Pop())
    s.Push("one")
    s.Push("two")
    fmt.Println(s.Pop()) 
    fmt.Println(s.Pop()) 
    fmt.Println(s.Pop()) 
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: