This is a fork of: https://github.com/roglew/puppy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
514 B

package main
import (
"sync"
"log"
"io/ioutil"
)
type ConstErr string
func (e ConstErr) Error() string { return string(e) }
func DuplicateBytes(bs []byte) ([]byte) {
retBs := make([]byte, len(bs))
copy(retBs, bs)
return retBs
}
func IdCounter() func() int {
var nextId int = 1
var nextIdMtx sync.Mutex
return func() int {
nextIdMtx.Lock()
defer nextIdMtx.Unlock()
ret := nextId
nextId++
return ret
}
}
func NullLogger() *log.Logger {
return log.New(ioutil.Discard, "", log.Lshortfile)
}