This is a creation in Article, where the information may have evolved or changed.
Package Mainimport ("FMT") type Stack struct {top intdata [10]int}func initstack (S *stack) {s.top = 0}func push (s *stack, element int) {S.data[s.top] = Elements.top++}func Pop (s *stack) int {S.top--return S.data[s.top]}func showstack (S *Stack) {for I: = s.top; I >= 0; i--{fmt. Printf ("element%d is%d \ t", I, S.data[i])}}func showdiscribe () {fmt. Println ("***********operations description****************") fmt. Println ("") fmt. Println ("Press 1 push element to Stack") fmt. Println ("Press 2 pop element to Stack") fmt. Println ("Press 3 show elements to Stack") fmt. Println ("Press 4 show Operations") FMT. Println ("Press 5 exit") Fmt. Println ("") fmt. Println ("*************************************************")}func Main () {Showdiscribe () var op intvar value INTs: = New (Stack) Initstack (s) for {fmt. SCANF ("%d", &op) switch op {case 1:fmt. PRINTLN ("Please input the Vaule") fmt. SCANF ("%d", &value) push (s, value) case 2:fmt. Println ("The value is:", POPs (s)) case 3:fmt. Println ("All elements:") Showstack (s) CAse 4:showdiscribe () Case 5:goto Exit}}exit:}