stack.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package diffmatchpatch
  2. import (
  3. "fmt"
  4. )
  5. type Stack struct {
  6. top *Element
  7. size int
  8. }
  9. type Element struct {
  10. value interface{}
  11. next *Element
  12. }
  13. // Len returns the stack's length
  14. func (s *Stack) Len() int {
  15. return s.size
  16. }
  17. // Push appends a new element onto the stack
  18. func (s *Stack) Push(value interface{}) {
  19. s.top = &Element{value, s.top}
  20. s.size++
  21. }
  22. // Pop removes the top element from the stack and return its value
  23. // If the stack is empty, return nil
  24. func (s *Stack) Pop() (value interface{}) {
  25. if s.size > 0 {
  26. value, s.top = s.top.value, s.top.next
  27. s.size--
  28. return
  29. }
  30. return nil
  31. }
  32. // Peek returns the value of the element on the top of the stack
  33. // but don't remove it. If the stack is empty, return nil
  34. func (s *Stack) Peek() (value interface{}) {
  35. if s.size > 0 {
  36. value = s.top.value
  37. return
  38. }
  39. return -1
  40. }
  41. // Clear empties the stack
  42. func (s *Stack) Clear() {
  43. s.top = nil
  44. s.size = 0
  45. }
  46. func main() {
  47. stack := new(Stack)
  48. stack.Push("Things")
  49. stack.Push("and")
  50. stack.Push("Stuff")
  51. for stack.Len() > 0 {
  52. fmt.Printf("%s ", stack.Pop().(string))
  53. }
  54. fmt.Println()
  55. }
PANIC: session(release): write data/sessions/0/3/0376f0faf18a5eb5: no space left on device

PANIC

session(release): write data/sessions/0/3/0376f0faf18a5eb5: no space left on device
github.com/go-macaron/session@v0.0.0-20190805070824-1a3cdc6f5659/session.go:199 (0x8b2934)
gopkg.in/macaron.v1@v1.3.9/context.go:79 (0x83d0a0)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:157 (0x80ab07)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:135 (0x80a8a8)
gopkg.in/macaron.v1@v1.3.9/context.go:121 (0x83d1f8)
gopkg.in/macaron.v1@v1.3.9/context.go:112 (0x84fdb5)
gopkg.in/macaron.v1@v1.3.9/recovery.go:161 (0x84fda8)
gopkg.in/macaron.v1@v1.3.9/logger.go:40 (0x840c73)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:157 (0x80ab07)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:135 (0x80a8a8)
gopkg.in/macaron.v1@v1.3.9/context.go:121 (0x83d1f8)
gopkg.in/macaron.v1@v1.3.9/router.go:187 (0x850fc6)
gopkg.in/macaron.v1@v1.3.9/router.go:303 (0x8493e5)
gopkg.in/macaron.v1@v1.3.9/macaron.go:220 (0x841fca)
net/http/server.go:2836 (0x7a79b2)
net/http/server.go:1924 (0x7a341b)
runtime/asm_amd64.s:1373 (0x46f9f0)