Skip to content
Collection of dirty hacks in Go
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml
LICENSE
README.md
go.mod
mutex.go
mutex_test.go
once.go
once_test.go
rwmutex.go
rwmutex_test.go
sabotage.jpg
string.go

README.md

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
    }
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.