chore: initialize containerized Go learning workbook (2026 DevOps/SRE)
This commit is contained in:
commit
84be3e5d77
64 files changed
+1382
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package ds
|
||||
|
||||
import "sync"
|
||||
|
||||
type Stack[T any] struct {
|
||||
items []T
|
||||
}
|
||||
|
||||
func (s *Stack[T]) Push(v T) {
|
||||
panic("TODO: dodaj v na wierzch stosu")
|
||||
}
|
||||
|
||||
func (s *Stack[T]) Pop() (T, bool) {
|
||||
panic("TODO: zdejmij element lub zwróć (zero, false)")
|
||||
}
|
||||
|
||||
func (s *Stack[T]) Len() int {
|
||||
return len(s.items)
|
||||
}
|
||||
|
||||
type SafeCache[K comparable, V any] struct {
|
||||
//lint:ignore U1000 używane po zaimplementowaniu metod
|
||||
mu sync.RWMutex
|
||||
data map[K]V
|
||||
}
|
||||
|
||||
func NewSafeCache[K comparable, V any]() *SafeCache[K, V] {
|
||||
return &SafeCache[K, V]{data: make(map[K]V)}
|
||||
}
|
||||
|
||||
func (c *SafeCache[K, V]) Set(k K, v V) {
|
||||
panic("TODO: użyj c.mu.Lock() + defer c.mu.Unlock()")
|
||||
}
|
||||
|
||||
func (c *SafeCache[K, V]) Get(k K) (V, bool) {
|
||||
panic("TODO: użyj c.mu.RLock() + defer c.mu.RUnlock()")
|
||||
}
|
||||
|
||||
func (c *SafeCache[K, V]) Delete(k K) {
|
||||
panic("TODO: usuń klucz pod c.mu.Lock()")
|
||||
}
|
||||
Reference in new issue
Block a user