From ddc27f34abd81bcb80c55e2fa7cc05e232d12a03 Mon Sep 17 00:00:00 2001 From: Vladislav Yarmak Date: Fri, 2 Apr 2021 00:46:17 +0300 Subject: [PATCH] fmt --- main.go | 2 +- seclient/seclient.go | 2 +- utils.go | 46 ++++++++++++++++++++++---------------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/main.go b/main.go index 7be846d..f267a14 100644 --- a/main.go +++ b/main.go @@ -208,7 +208,7 @@ func run() int { } cl() - runTicker(context.Background(), args.refresh, func (ctx context.Context) { + runTicker(context.Background(), args.refresh, func(ctx context.Context) { mainLogger.Info("Refreshing login...") loginCtx, cl := context.WithTimeout(ctx, args.timeout) defer cl() diff --git a/seclient/seclient.go b/seclient/seclient.go index 36e7d1e..17ed238 100644 --- a/seclient/seclient.go +++ b/seclient/seclient.go @@ -126,7 +126,7 @@ func (c *SEClient) AnonRegister(ctx context.Context) error { func (c *SEClient) Register(ctx context.Context) error { var regRes SERegisterSubscriberResponse err := c.RpcCall(ctx, c.Settings.Endpoints.RegisterSubscriber, StrKV{ - "email": c.SubscriberEmail, + "email": c.SubscriberEmail, "password": c.SubscriberPassword, }, ®Res) if err != nil { diff --git a/utils.go b/utils.go index 8cbeafc..566e0a4 100644 --- a/utils.go +++ b/utils.go @@ -13,7 +13,7 @@ import ( ) const ( - COPY_BUF = 128 * 1024 + COPY_BUF = 128 * 1024 WALLCLOCK_PRECISION = 1 * time.Second ) @@ -148,30 +148,30 @@ func copyBody(wr io.Writer, body io.Reader) { } func AfterWallClock(d time.Duration) <-chan time.Time { - ch := make(chan time.Time, 1) - deadline := time.Now().Add(d).Truncate(0) - after_ch := time.After(d) - ticker := time.NewTicker(WALLCLOCK_PRECISION) - go func() { - var t time.Time - defer ticker.Stop() - for { - select { - case t = <-after_ch: - ch <-t - return - case t = <-ticker.C: - if t.After(deadline) { - ch <-t - return - } - } - } - }() - return ch + ch := make(chan time.Time, 1) + deadline := time.Now().Add(d).Truncate(0) + after_ch := time.After(d) + ticker := time.NewTicker(WALLCLOCK_PRECISION) + go func() { + var t time.Time + defer ticker.Stop() + for { + select { + case t = <-after_ch: + ch <- t + return + case t = <-ticker.C: + if t.After(deadline) { + ch <- t + return + } + } + } + }() + return ch } -func runTicker(ctx context.Context, interval time.Duration, cb func (context.Context)) { +func runTicker(ctx context.Context, interval time.Duration, cb func(context.Context)) { go func() { for { select {