Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(key string)
Delete deletes a variable from the local storage of the current go routine
func Go ¶
func Go(f func())
Go executes the given function in a go routine and ensures that the local storage is initialized before the function is called and deleted before after the function returns or panics
Example ¶
Init() var wg sync.WaitGroup wg.Add(2) Set(`key`, `main value`) Go(func() { Set(`key`, `value 1`) Go(func() { Set(`key`, `value 2`) v, _ := Get(`key`) fmt.Printf("g2 = %s\n", v) Delete(`key`) wg.Done() }) v, _ := Get(`key`) fmt.Printf("g1 = %s\n", v) Delete(`key`) wg.Done() }) wg.Wait() v, _ := Get(`key`) fmt.Printf("main = %v\n", v)
Output: g1 = value 1 g2 = value 2 main = main value
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.