Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates and initialises a new Closer persisted in Bolt.
Example ¶
path := getTmpPath() defer os.Remove(path) storage, err := New(path) if err != nil { log.Fatal(err) } defer storage.Close() storage.LoadOrStore("foo", "bar") key, _ := storage.Resolve("bar") fmt.Printf("Key for 'bar' is '%s'\n", key)
Output: Key for 'bar' is 'foo'
Example (Other) ¶
path := getTmpPath() defer os.Remove(path) storage, _ := New(path) // We ignore the error this time. Naughty! defer storage.Close() storage.LoadOrStore("foo", "bar") value, loaded := storage.LoadOrStore("foo", "42") key, _ := storage.Resolve("bar") fmt.Printf("Value of 'foo' is '%s'\n", value) fmt.Printf("Value of 'foo' was loaded from storage: %t\n", loaded) fmt.Printf("Key for 'bar' is '%s'\n", key) _, ok := storage.Resolve("42") fmt.Printf("Key for '42' could be resolved: %t", ok)
Output: Value of 'foo' is 'bar' Value of 'foo' was loaded from storage: true Key for 'bar' is 'foo' Key for '42' could be resolved: false
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.