1
0
Fork 0

Add examples to readme

This commit is contained in:
Gregory Eremin 2018-06-17 13:56:44 +02:00
parent df01f2eed7
commit 0df8b1ec84
No known key found for this signature in database
GPG Key ID: 8CB79D42167BEB7F
2 changed files with 32 additions and 2 deletions

View File

@ -1 +1,32 @@
# Go tool belt
# Gobelt
Gobelt is a collection of Go tools.
### Thread pool
```go
import "github.com/localhots/gobelt/threadpool"
```
```go
ctx := context.Background()
pool := threadpool.New(5)
pool.Enqueue(ctx, func() {
fmt.Println("Hello")
})
pool.Close()
```
### File cache
```go
import "github.com/localhots/gobelt/filecache"
```
```go
var val int
filecache.Load(&val, "path/to/cachefile", func() interface{} {
// Expensive calls here
return 100
})
```

View File

@ -19,7 +19,6 @@ func TestFileCache(t *testing.T) {
if err != nil {
t.Fatalf("Error occurred while loading cache: %v", err)
}
if res != exp {
t.Errorf("Expected %d, got %d", exp, res)
}