mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 03:55:28 +08:00
29 lines
381 B
Go
Executable File
29 lines
381 B
Go
Executable File
// main_stack.go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"./stack/stack"
|
|
)
|
|
|
|
var st1 stack.Stack
|
|
|
|
func main() {
|
|
st1.Push("Brown")
|
|
st1.Push(3.14)
|
|
st1.Push(100)
|
|
st1.Push([]string{"Java", "C++", "Python", "C#", "Ruby"})
|
|
for {
|
|
item, err := st1.Pop()
|
|
if err != nil {
|
|
break
|
|
}
|
|
fmt.Println(item)
|
|
}
|
|
}
|
|
/* Output:
|
|
[Java C++ Python C# Ruby]
|
|
100
|
|
3.14
|
|
Brown
|
|
*/ |