github.com/mvg-fi/go-limiter@v0.1.1/memorystore/example_test.go (about) 1 package memorystore_test 2 3 import ( 4 "context" 5 "log" 6 "time" 7 8 "github.com/mvg-fi/go-limiter/memorystore" 9 ) 10 11 func ExampleNew() { 12 ctx := context.Background() 13 14 store, err := memorystore.New(&memorystore.Config{ 15 Tokens: 15, 16 Interval: time.Minute, 17 }) 18 if err != nil { 19 log.Fatal(err) 20 } 21 defer store.Close(ctx) 22 23 limit, remaining, reset, ok, err := store.Take(ctx, "my-key") 24 if err != nil { 25 log.Fatal(err) 26 } 27 _, _, _, _ = limit, remaining, reset, ok 28 }