mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-01-20 11:37:56 +00:00
*: Move state example to root package
Also updated it to use Connect instead of Open and Close.
This commit is contained in:
parent
b1a54c0b41
commit
5e0d1cfe4a
|
@ -1,4 +1,4 @@
|
||||||
package state_test
|
package arikawa_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -20,13 +20,7 @@ func Example() {
|
||||||
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
|
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
if err := s.Open(ctx); err != nil {
|
if err := s.Connect(ctx); err != nil {
|
||||||
log.Println("cannot open:", err)
|
log.Println("cannot open:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
<-ctx.Done() // block until Ctrl+C
|
|
||||||
|
|
||||||
if err := s.Close(); err != nil {
|
|
||||||
log.Println("cannot close:", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue