/sabotage

Collection of dirty hacks in Go

Primary LanguageGoBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

SABOTAGE

Build Status GoDoc Go Report

Collection of dirty hacks in Go.

  1. Repeat sync.Once once more.
  2. Check if sync.Mutex/sync.RWMutex is locked.
  3. []byte <-> string conversion without additional allocation.

logo

Cause what you see, you might not get
And we can bet, so don't you get souped yet
Scheming on a thing, that's a mirage
I'm trying to tell you now, it's sabotage

Whhhhhyyyyyy??????

(c) Beastie Boys - Sabotage

Examples

  1. You can repeat sync.Once as much as you want:
var once sync.Once

once.Do(myFunc)

sabotage.ResetSyncOnce(&once) 

or check if it was invoked earlier:

if sabotage.IsOnceDone(&once) {
    println("well-well-well")
}
  1. You can unlock any mutex from anywhere:
var mu sync.Mutex

// let's yolo begins
sabotage.UnlockMutex(&mu)

or check if it's locked:

if sabotage.IsMutexLocked(&mu) {
    for {
        // let's wait a bit
    }
}