8000 GitHub - WillAbides/totally-not-a-global
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WillAbides/totally-not-a-global

Repository files navigation

totally-not-a-global

godoc ci

When you don't want to sully your package with globals, don't worry because totally-not-a-global will sully itself instead.

Usage

package main

import (
	"fmt"

	totallynotaglobal "github.com/willabides/totally-not-a-global"
)

func main() {
	totallynotaglobal.Set("foo", "bar")
	totallynotaglobal.SetOnce("baz", func() interface{} {
		return "qux"
	})
	totallynotaglobal.SetOnce("baz", func() interface{} {
		return "not qux"
	})

	foo, ok := totallynotaglobal.Get("foo")
	if ok {
		fmt.Print(foo)
	}

	totallynotaglobal.WithTotallyNotAGlobalValue("baz", func(notAGlobalValue interface{}) {
		fmt.Println(notAGlobalValue)
	})
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0