Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
taowen committed Mar 1, 2018
1 parent b3b0aa9 commit 18e3a66
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,36 @@
Thanks https://github.com/huandu/go-tls for original idea

* get current goroutine id
* goroutine local storage
* goroutine local storage

require go version >= 1.4

# gls.GoID

get the identifier unique for this goroutine

```go
go func() {
gls.GoID()
}()
go func() {
gls.GoID()
}()
```

# gls.Set / gls.Get

goroutine local storage is a `map[interface{}]interface{}` local to current goroutine

It is intended to be used by framworks to simplify context passing.

Use `context.Context` to pass context if possible.

```go
gls.Set("user_id", "abc")
doSomeThing()

func doSomeThing() {
gls.Get("user_id") // will be "abc"
}
```

0 comments on commit 18e3a66

Please sign in to comment.