You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
go version: go version go1.17.2 darwin/amd64
td version: v0.55.2
// Binary bg-run implements alternative to Run pattern.package main
import (
"context""fmt""time""go.uber.org/zap""github.com/gotd/contrib/bg""github.com/gotd/td/examples""github.com/gotd/td/telegram"
)
funcmain() {
// Some users find explicit client.Run(ctx, f) pattern not very convenient.//// However, it is possible to implement wrapper and use classic "Connect"// pattern instead.//// The `contrib/bg` package is example implementation of such pattern.examples.Run(func(ctx context.Context, log*zap.Logger) error {
phone:="xxxxxxxx"client:=telegram.NewClient(123, "xxxxxxxxx", telegram.Options{
SessionStorage: &telegram.FileSessionStorage{
Path: phone,
},
Logger: log,
})
// bg.Connect will call Run in background.// Call stop() to disconnect and release resources.stop, err:=bg.Connect(client)
iferr!=nil {
fmt.Println("Connect err", err)
returnerr
}
deferfunc() { _=stop() }()
fmt.Println("connect")
// Now you can use client.status, err:=client.Auth().Status(ctx)
iferr!=nil {
fmt.Println("Status err", err)
returnerr
}
fmt.Println(status)
fmt.Println("done")
returnnil
})
}
go version: go version go1.17.2 darwin/amd64
td version: v0.55.2
No output Status err
No output done
This is console log
But on the next line "fmt.Println("connect")"
Add "time.Sleep(time.Duration(200) * time.Millisecond)"
everything is ok
The text was updated successfully, but these errors were encountered: