dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress oflag=sync
loadkeys <your-keymap>
package main | |
import ( | |
"encoding/csv" | |
"flag" | |
"log" | |
"math/rand" | |
"os" | |
"strconv" | |
"time" |
type FailingStorage struct{} | |
func (f *FailingStorage) Add(k, v string) { | |
throw exception.New("now we fail") | |
} | |
var s = NewSafeStorage(&FailingStorage{}) | |
func handleAdd(w http.ResponseWriter, r *http.Request) { | |
key := r.Host | |
value := r.Method |
type FailingStorage struct{} | |
func (f *FailingStorage) Add(k, v string) (err error) { | |
return errors.New("now we fail") | |
} | |
var s = NewSafeStorage(&FailingStorage{}) |
type FailingStorage struct{} | |
func (f *FailingStorage) Add(k, v string) (err error) { | |
return errors.New("now we fail") | |
} | |
var s = NewSafeStorage(&FailingStorage{}) | |
func handleAdd(w http.ResponseWriter, r *http.Request) { | |
key := r.Host | |
value := r.Method |
type storage struct{} | |
func (s *storage) Add(k, v string) {} | |
var s = NewSafeStorage(&storage{}) | |
func handleAdd(w http.ResponseWriter, r *http.Request) { | |
key := r.Host | |
value := r.Method | |
s.Add(key, value) | |
} |
type Storage interface { | |
Add(key, val string) error | |
} | |
func (s *SafeStorage) Add(key, val string) error { | |
s.storageMu.Lock() | |
defer s.storageMu.Unlock() | |
return s.storage.Add(key, val) | |
} |
type Storage interface { | |
Add(key, val string) | |
} | |
type SafeStorage struct { | |
storageMu *sync.Mutex | |
storage Storage | |
} | |
func NewSafeStorage(storage Storage) *SafeStorage { |
/* | |
File that demostrates file descriptor leak | |
in case the client forgets to close response body | |
*/ | |
package main | |
import ( | |
"fmt" | |
"io/ioutil" |
package main | |
import ( | |
"log" | |
"sync" | |
"time" | |
) | |
const Limit = 5 |