10 examples of 'golang stack' in Go

Every line of 'golang stack' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
63func main() {
64 var stack *Stack = &Stack{}
65 stack.New()
66 var reference1 *ReferenceCounter = newReferenceCounter()
67 var reference2 *ReferenceCounter = newReferenceCounter()
68 var reference3 *ReferenceCounter = newReferenceCounter()
69 var reference4 *ReferenceCounter = newReferenceCounter()
70
71 stack.Push(reference1)
72 stack.Push(reference2)
73 stack.Push(reference3)
74 stack.Push(reference4)
75 fmt.Println(stack.Pop(), stack.Pop(), stack.Pop(), stack.Pop())
76}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

89func (stack *Stack) StackOn(stack2 *Stack) (success bool, notZero bool, stackCount int) {
90 canStack, count := stack.CanStackOn(stack2)
91 countLeft := stack.Count != 0
92 if !canStack {
93 return false, countLeft, count
94 }
95 stack2.Count += count
96 stack.Count -= count
97 return true, countLeft, count
98}
236func reserveStack(dummy bool) {
237 var buf [8 << 10]byte
238 // avoid compiler optimize the buf out.
239 if dummy {
240 for i := range buf {
241 buf[i] = byte(i)
242 }
243 }
244}
104func main3() {
105 stk := new(Stack)
106 stk.Push(1)
107 stk.Push(2)
108 stk.Push(3)
109 insertAtBottom(stk, 5)
110 stk.Print()
111}
249func StackCont(p interface{}, name string) {
250 cont := p.(*Parser).TxContract
251 if len(name) > 0 {
252 cont.StackCont = append(cont.StackCont, name)
253 } else {
254 cont.StackCont = cont.StackCont[:len(cont.StackCont)-1]
255 }
256 return
257}
52func main() {
53 a := []int{1, 1, 1, 1, 2}
54 fmt.Println(findTargetSumWays(a, 4))
55 fmt.Println(findTargetSumWays1(a, 4))
56}
329func signalstack(s *stack) {
330 var st sigaltstackt
331 if s == nil {
332 st.ss_flags = _SS_DISABLE
333 } else {
334 st.ss_sp = (*byte)(unsafe.Pointer(s.lo))
335 st.ss_size = s.hi - s.lo
336 st.ss_flags = 0
337 }
338 sigaltstack(&st, nil)
339}
554func (p runtimeProfile) Stack(i int) []uintptr { return p[i].Stack() }
740func (p *runtimeProfile) Stack(i int) []uintptr { return p.stk[i].Stack() }
40func minStack(pops, push int) int {
41 return pops
42}

Related snippets