MCPcopy Index your code
hub / github.com/allan-simon/go-singleinstance

github.com/allan-simon/go-singleinstance @1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.0 ↗ · + Follow
7 symbols 18 edges 5 files 3 documented · 43%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

go-singleinstance

Cross plateform library to have only one instance of a software (based on python's tendo).

Usage

package main

import (
    "fmt"
    "time"

    "github.com/allan-simon/go-singleinstance"
)

func main() {
    lockFile, err := singleinstance.CreateLockFile("plop.lock")
    if err != nil {
        fmt.Println("An instance already exists")
        return
    }
    defer lockFile.Close()

    fmt.Println("Sleeping...")
    time.Sleep(10 * time.Second)
    fmt.Println("Done")
}

If you try to launch it twice, the second instance will fail.

Thanks

For the python library trendo, from which I've shamelessly adapted the code.

Contribution

Don't be afraid if it says "last commit 2 years ago", this library is made to be small and simple so it's unlikely it changes after some times, however I'm pretty reactive on github overall, so feel free to use issues to ask question, propose patch etc. :)

License

MIT

Core symbols most depended-on inside this repo

CreateLockFile
called by 3
lock_posix.go
GetLockFilePid
called by 1
lock.go
main
called by 0
lock_example.go
CreateLockFile
called by 0
lock_windows.go

Shape

Function 7

Languages

Go100%

Modules by API surface

lock_test.go3 symbols
lock_windows.go1 symbols
lock_posix.go1 symbols
lock_example.go1 symbols
lock.go1 symbols

For agents

$ claude mcp add go-singleinstance \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact