Tear down everything

Fix config
This commit is contained in:
Martin Pander
2026-02-26 20:00:56 +01:00
parent 6b1418fc71
commit 418bcd96a8
50 changed files with 256 additions and 8377 deletions

47
internal/common/stack.go Normal file
View File

@@ -0,0 +1,47 @@
package common
import (
"errors"
"sync"
)
type Stack[T any] struct {
items []T
mutex sync.Mutex
}
func NewStack[T any]() *Stack[T] {
return &Stack[T]{
items: make([]T, 0),
mutex: sync.Mutex{},
}
}
func (s *Stack[T]) Push(item T) {
s.mutex.Lock()
defer s.mutex.Unlock()
s.items = append(s.items, item)
}
func (s *Stack[T]) Pop() (T, error) {
s.mutex.Lock()
defer s.mutex.Unlock()
if len(s.items) == 0 {
var empty T
return empty, errors.New("stack is empty")
}
item := s.items[len(s.items)-1]
s.items = s.items[:len(s.items)-1]
return item, nil
}
func (s *Stack[T]) IsEmpty() bool {
s.mutex.Lock()
defer s.mutex.Unlock()
return len(s.items) == 0
}