Browse Source

go mod tidy && go mod vendor

master
Andrey Kovalev 2 years ago
parent
commit
7fe2f59f05
Signed by: Russia9
GPG Key ID: EC3AA65373CA51DC
  1. 8
      Dockerfile
  2. 4
      bot/bot.go
  3. 4
      bot/handlers/add.go
  4. 8
      bot/handlers/code.go
  5. 8
      bot/handlers/delete.go
  6. 10
      bot/handlers/list.go
  7. 10
      bot/handlers/password.go
  8. 4
      bot/handlers/phone.go
  9. 4
      bot/handlers/router.go
  10. 23
      go.mod
  11. 113
      go.sum
  12. 14
      main.go
  13. 4
      userbot/bot.go
  14. 25
      vendor/github.com/cenkalti/backoff/v4/.gitignore
  15. 10
      vendor/github.com/cenkalti/backoff/v4/.travis.yml
  16. 20
      vendor/github.com/cenkalti/backoff/v4/LICENSE
  17. 32
      vendor/github.com/cenkalti/backoff/v4/README.md
  18. 66
      vendor/github.com/cenkalti/backoff/v4/backoff.go
  19. 62
      vendor/github.com/cenkalti/backoff/v4/context.go
  20. 158
      vendor/github.com/cenkalti/backoff/v4/exponential.go
  21. 112
      vendor/github.com/cenkalti/backoff/v4/retry.go
  22. 97
      vendor/github.com/cenkalti/backoff/v4/ticker.go
  23. 35
      vendor/github.com/cenkalti/backoff/v4/timer.go
  24. 38
      vendor/github.com/cenkalti/backoff/v4/tries.go
  25. 22
      vendor/github.com/cespare/xxhash/v2/LICENSE.txt
  26. 69
      vendor/github.com/cespare/xxhash/v2/README.md
  27. 235
      vendor/github.com/cespare/xxhash/v2/xxhash.go
  28. 13
      vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go
  29. 215
      vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s
  30. 76
      vendor/github.com/cespare/xxhash/v2/xxhash_other.go
  31. 15
      vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
  32. 57
      vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go
  33. 21
      vendor/github.com/dgryski/go-rendezvous/LICENSE
  34. 79
      vendor/github.com/dgryski/go-rendezvous/rdv.go
  35. 20
      vendor/github.com/fatih/color/LICENSE.md
  36. 178
      vendor/github.com/fatih/color/README.md
  37. 618
      vendor/github.com/fatih/color/color.go
  38. 135
      vendor/github.com/fatih/color/doc.go
  39. 19
      vendor/github.com/go-co-op/gocron/.gitignore
  40. 49
      vendor/github.com/go-co-op/gocron/.golangci.yaml
  41. 73
      vendor/github.com/go-co-op/gocron/CODE_OF_CONDUCT.md
  42. 40
      vendor/github.com/go-co-op/gocron/CONTRIBUTING.md
  43. 21
      vendor/github.com/go-co-op/gocron/LICENSE
  44. 33
      vendor/github.com/go-co-op/gocron/Makefile
  45. 132
      vendor/github.com/go-co-op/gocron/README.md
  46. 15
      vendor/github.com/go-co-op/gocron/SECURITY.md
  47. 111
      vendor/github.com/go-co-op/gocron/executor.go
  48. 101
      vendor/github.com/go-co-op/gocron/gocron.go
  49. 381
      vendor/github.com/go-co-op/gocron/job.go
  50. 1205
      vendor/github.com/go-co-op/gocron/scheduler.go
  51. 25
      vendor/github.com/go-co-op/gocron/timeHelper.go
  52. 8
      vendor/github.com/go-faster/errors/.codecov.yml
  53. 25
      vendor/github.com/go-faster/errors/.editorconfig
  54. 8
      vendor/github.com/go-faster/errors/.gitignore
  55. 108
      vendor/github.com/go-faster/errors/.golangci.yml
  56. 27
      vendor/github.com/go-faster/errors/LICENSE
  57. 10
      vendor/github.com/go-faster/errors/Makefile
  58. 22
      vendor/github.com/go-faster/errors/PATENTS
  59. 36
      vendor/github.com/go-faster/errors/README.md
  60. 193
      vendor/github.com/go-faster/errors/adaptor.go
  61. 9
      vendor/github.com/go-faster/errors/doc.go
  62. 37
      vendor/github.com/go-faster/errors/errors.go
  63. 47
      vendor/github.com/go-faster/errors/format.go
  64. 56
      vendor/github.com/go-faster/errors/frame.go
  65. 6
      vendor/github.com/go-faster/errors/go.coverage.sh
  66. 12
      vendor/github.com/go-faster/errors/go.test.sh
  67. 13
      vendor/github.com/go-faster/errors/noerrtrace.go
  68. 37
      vendor/github.com/go-faster/errors/trace.go
  69. 120
      vendor/github.com/go-faster/errors/wrap.go
  70. 8
      vendor/github.com/go-faster/jx/.codecov.yml
  71. 25
      vendor/github.com/go-faster/jx/.editorconfig
  72. 15
      vendor/github.com/go-faster/jx/.gitignore
  73. 108
      vendor/github.com/go-faster/jx/.golangci.yml
  74. 21
      vendor/github.com/go-faster/jx/LICENSE
  75. 13
      vendor/github.com/go-faster/jx/Makefile
  76. 306
      vendor/github.com/go-faster/jx/README.md
  77. 143
      vendor/github.com/go-faster/jx/dec.go
  78. 80
      vendor/github.com/go-faster/jx/dec_arr.go
  79. 46
      vendor/github.com/go-faster/jx/dec_b64.go
  80. 38
      vendor/github.com/go-faster/jx/dec_bool.go
  81. 27
      vendor/github.com/go-faster/jx/dec_capture.go
  82. 26
      vendor/github.com/go-faster/jx/dec_depth.go
  83. 360
      vendor/github.com/go-faster/jx/dec_float.go
  84. 303
      vendor/github.com/go-faster/jx/dec_int.go
  85. 20
      vendor/github.com/go-faster/jx/dec_null.go
  86. 75
      vendor/github.com/go-faster/jx/dec_num.go
  87. 86
      vendor/github.com/go-faster/jx/dec_obj.go
  88. 39
      vendor/github.com/go-faster/jx/dec_raw.go
  89. 146
      vendor/github.com/go-faster/jx/dec_read.go
  90. 472
      vendor/github.com/go-faster/jx/dec_skip.go
  91. 324
      vendor/github.com/go-faster/jx/dec_str.go
  92. 22
      vendor/github.com/go-faster/jx/dec_validate.go
  93. 199
      vendor/github.com/go-faster/jx/enc.go
  94. 9
      vendor/github.com/go-faster/jx/enc_b64.go
  95. 34
      vendor/github.com/go-faster/jx/enc_comma.go
  96. 17
      vendor/github.com/go-faster/jx/enc_float.go
  97. 25
      vendor/github.com/go-faster/jx/enc_int.go
  98. 7
      vendor/github.com/go-faster/jx/enc_num.go
  99. 16
      vendor/github.com/go-faster/jx/enc_str.go
  100. 19
      vendor/github.com/go-faster/jx/fuzz.go
  101. Some files were not shown because too many files have changed in this diff Show More

8
Dockerfile

@ -1,14 +1,8 @@ @@ -1,14 +1,8 @@
FROM golang:1.18
FROM golang:1.17
# Set app workdir
WORKDIR /go/src/app
# Copy dependencies list
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy application sources
COPY . .

4
bot/bot.go

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
package bot
import (
"gopkg.in/tucnak/telebot.v3"
"gopkg.in/tucnak/telebot.v3/layout"
"gopkg.in/telebot.v3"
"gopkg.in/telebot.v3/layout"
)
var Bot *telebot.Bot

4
bot/handlers/add.go

@ -2,8 +2,8 @@ package handlers @@ -2,8 +2,8 @@ package handlers
import (
"context"
"gopkg.in/tucnak/telebot.v3"
"muskrat/storage"
"gitea.russia9.dev/russia9/muskrat/storage"
"gopkg.in/telebot.v3"
)
func Add(ctx telebot.Context) error {

8
bot/handlers/code.go

@ -4,13 +4,13 @@ import ( @@ -4,13 +4,13 @@ import (
"bytes"
"context"
"errors"
"gitea.russia9.dev/russia9/muskrat/storage"
"gitea.russia9.dev/russia9/muskrat/types"
"gitea.russia9.dev/russia9/muskrat/userbot"
"github.com/gotd/td/session"
"github.com/gotd/td/telegram"
"github.com/gotd/td/telegram/auth"
"gopkg.in/tucnak/telebot.v3"
"muskrat/storage"
"muskrat/types"
"muskrat/userbot"
"gopkg.in/telebot.v3"
"os"
"regexp"
"strconv"

8
bot/handlers/delete.go

@ -2,11 +2,11 @@ package handlers @@ -2,11 +2,11 @@ package handlers
import (
"fmt"
"gitea.russia9.dev/russia9/muskrat/storage"
"gitea.russia9.dev/russia9/muskrat/types"
"gitea.russia9.dev/russia9/muskrat/userbot"
"github.com/rs/zerolog/log"
"gopkg.in/tucnak/telebot.v3"
"muskrat/storage"
"muskrat/types"
"muskrat/userbot"
"gopkg.in/telebot.v3"
"strconv"
"strings"
)

10
bot/handlers/list.go

@ -3,11 +3,11 @@ package handlers @@ -3,11 +3,11 @@ package handlers
import (
"context"
"fmt"
"gopkg.in/tucnak/telebot.v3"
"muskrat/storage"
"muskrat/types"
"muskrat/userbot"
"muskrat/utils"
"gitea.russia9.dev/russia9/muskrat/storage"
"gitea.russia9.dev/russia9/muskrat/types"
"gitea.russia9.dev/russia9/muskrat/userbot"
"gitea.russia9.dev/russia9/muskrat/utils"
"gopkg.in/telebot.v3"
"regexp"
"strconv"
"strings"

10
bot/handlers/password.go

@ -2,12 +2,12 @@ package handlers @@ -2,12 +2,12 @@ package handlers
import (
"context"
"gitea.russia9.dev/russia9/muskrat/storage"
"gitea.russia9.dev/russia9/muskrat/types"
"gitea.russia9.dev/russia9/muskrat/userbot"
"github.com/gotd/td/session"
"github.com/gotd/td/telegram"
"gopkg.in/tucnak/telebot.v3"
"muskrat/storage"
"muskrat/types"
"muskrat/userbot"
"gopkg.in/telebot.v3"
"os"
"strconv"
"time"
@ -66,7 +66,7 @@ func Password(ctx telebot.Context, metadata []string) error { @@ -66,7 +66,7 @@ func Password(ctx telebot.Context, metadata []string) error {
delete(userbot.Userbots, account.ID)
}
ubot := &userbot.Userbot{
Account: account,
Account: account,
}
go ubot.Start(c)
userbot.Userbots[account.ID] = ubot

4
bot/handlers/phone.go

@ -3,11 +3,11 @@ package handlers @@ -3,11 +3,11 @@ package handlers
import (
"bytes"
"context"
"gitea.russia9.dev/russia9/muskrat/storage"
"github.com/gotd/td/session"
"github.com/gotd/td/telegram"
"github.com/gotd/td/telegram/auth"
"gopkg.in/tucnak/telebot.v3"
"muskrat/storage"
"gopkg.in/telebot.v3"
"os"
"regexp"
"strconv"

4
bot/handlers/router.go

@ -2,8 +2,8 @@ package handlers @@ -2,8 +2,8 @@ package handlers
import (
"context"
"gopkg.in/tucnak/telebot.v3"
"muskrat/storage"
"gitea.russia9.dev/russia9/muskrat/storage"
"gopkg.in/telebot.v3"
)
func Router(ctx telebot.Context) error {

23
go.mod

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
module muskrat
module gitea.russia9.dev/russia9/muskrat
go 1.18
go 1.17
require (
github.com/go-co-op/gocron v1.13.0
github.com/go-redis/redis/v8 v8.11.5
github.com/gotd/td v0.56.0
github.com/rs/zerolog v1.26.1
gopkg.in/tucnak/telebot.v3 v3.0.0-20211126232936-7f936709f3ee
gopkg.in/telebot.v3 v3.0.0
gorm.io/driver/postgres v1.3.4
gorm.io/gorm v1.23.4
)
@ -18,9 +18,10 @@ require ( @@ -18,9 +18,10 @@ require (
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/go-faster/errors v0.5.0 // indirect
github.com/go-faster/jx v0.34.0 // indirect
github.com/go-faster/jx v0.32.2 // indirect
github.com/go-faster/xor v0.3.0 // indirect
github.com/goccy/go-yaml v1.9.5 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gotd/ige v0.2.2 // indirect
github.com/gotd/neo v0.1.5 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
@ -32,24 +33,20 @@ require ( @@ -32,24 +33,20 @@ require (
github.com/jackc/pgtype v1.10.0 // indirect
github.com/jackc/pgx/v4 v4.15.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/jinzhu/now v1.1.4 // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/segmentio/asm v1.1.3 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cast v1.3.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3 // indirect
golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e // indirect
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
nhooyr.io/websocket v1.8.7 // indirect

113
go.sum

@ -1,25 +1,32 @@ @@ -1,25 +1,32 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129/go.mod h1:rFgpPQZYZ8vdbc+48xibu8ALc3yeyd64IhHS+PU6Yyg=
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo=
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@ -29,20 +36,17 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE @@ -29,20 +36,17 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
github.com/go-co-op/gocron v1.11.0 h1:ujOMubCpGcTxnnR/9vJIPIEpgwuAjbueAYqJRNr+nHg=
github.com/go-co-op/gocron v1.11.0/go.mod h1:qtlsoMpHlSdIZ3E/xuZzrrAbeX3u5JtPvWf2TcdutU0=
github.com/go-co-op/gocron v1.13.0 h1:BjkuNImPy5NuIPEifhWItFG7pYyr27cyjS6BN9w/D4c=
github.com/go-co-op/gocron v1.13.0/go.mod h1:GD5EIEly1YNW+LovFVx5dzbYVcIc8544K99D8UVRpGo=
github.com/go-faster/errors v0.5.0 h1:hS/zHFJ2Vb14jcupq5J9tk05XW+PFTmySOkDRByHBo4=
github.com/go-faster/errors v0.5.0/go.mod h1:/9SNBcg2ESJTYztBFEiM5Np6ns85BtPNMJd8lFTiFwk=
github.com/go-faster/jx v0.32.0 h1:AVAtgZ1FefKWMfD69DUIAQBV4ypXwHhFjh1ln9WAEEw=
github.com/go-faster/jx v0.32.0/go.mod h1:T561ezgn74siJgc+QzZzoGHokGBKxV6WZugVyfw+68c=
github.com/go-faster/jx v0.34.0 h1:4V/7G+v6S7MNRihCrMXqKgiZLLVs57Qv9HqAJ8zprtg=
github.com/go-faster/jx v0.34.0/go.mod h1:FdJhlaqQP+Drk7zHphPa6fF0Lg19rc6eh6dOugjpEFI=
github.com/go-faster/jx v0.32.2 h1:xrBsEiawju+56UqBpNAjQ3/9ZmiSRzOletSsehRPeRw=
github.com/go-faster/jx v0.32.2/go.mod h1:T561ezgn74siJgc+QzZzoGHokGBKxV6WZugVyfw+68c=
github.com/go-faster/xor v0.3.0 h1:tc0bdVe31Wj999e5rEj7K3DhHyQNp2VydYyLFj3YSN8=
github.com/go-faster/xor v0.3.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7UxcipQ=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
@ -51,8 +55,6 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+ @@ -51,8 +55,6 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-redis/redis/v8 v8.11.4 h1:kHoYkfZP6+pe04aFTnhDH6GDROa5yJdHJVNxV3F46Tg=
github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
@ -63,7 +65,6 @@ github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= @@ -63,7 +65,6 @@ github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/goccy/go-yaml v1.9.1/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
github.com/goccy/go-yaml v1.9.5 h1:Eh/+3uk9kLxG4koCX6lRMAPS1OaMSAi+FJcya0INdB0=
github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
@ -84,22 +85,24 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu @@ -84,22 +85,24 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gotd/getdoc v0.7.0/go.mod h1:kw448DAm7r8JfjwMMi7BUxw0liLSWIMWCieyiI87Lkw=
github.com/gotd/ige v0.2.2 h1:XQ9dJZwBfDnOGSTxKXBGP4gMud3Qku2ekScRjDWWfEk=
github.com/gotd/ige v0.2.2/go.mod h1:tuCRb+Y5Y3eNTo3ypIfNpQ4MFjrnONiL2jN2AKZXmb0=
github.com/gotd/neo v0.1.5 h1:oj0iQfMbGClP8xI59x7fE/uHoTJD7NZH9oV1WNuPukQ=
github.com/gotd/neo v0.1.5/go.mod h1:9A2a4bn9zL6FADufBdt7tZt+WMhvZoc5gWXihOPoiBQ=
github.com/gotd/td v0.55.2 h1:pxd4LgSnWODqRx1uQ79GgTjHMSRVnFO3YaKHWWSljF8=
github.com/gotd/td v0.55.2/go.mod h1:L3N+aEIojKkN7vjqnijFSMbwCSr+m5wpSyFZdxTCMA0=
github.com/gotd/td v0.56.0 h1:SlpVIxKbEhNzQ83lbkbBB0uS1QONCP+K1EE0YQOAHJU=
github.com/gotd/td v0.56.0/go.mod h1:wILjug50hgK8UkPwGcYRGQ6+7TYX5Uuf2yU873umgvM=
github.com/gotd/tl v0.4.0/go.mod h1:CMIcjPWFS4qxxJ+1Ce7U/ilbtPrkoVo/t8uhN5Y/D7c=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
@ -111,8 +114,6 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU @@ -111,8 +114,6 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.10.1 h1:DzdIHIjG1AxGwoEEqS+mGsURyjt4enSmqzACXvVzOT8=
github.com/jackc/pgconn v1.10.1/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.11.0 h1:HiHArx4yFbwl91X3qqIHtUFoiIfLNJXCQRsnzkiwwaQ=
github.com/jackc/pgconn v1.11.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
@ -139,47 +140,37 @@ github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01C @@ -139,47 +140,37 @@ github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01C
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
github.com/jackc/pgtype v1.9.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgtype v1.9.1 h1:MJc2s0MFS8C3ok1wQTdQxWuXQcB6+HwAm5x1CzW7mf0=
github.com/jackc/pgtype v1.9.1/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgtype v1.10.0 h1:ILnBWrRMSXGczYvmkYD6PsYyVFUNLTnIUJHHDLmqk38=
github.com/jackc/pgtype v1.10.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
github.com/jackc/pgx/v4 v4.14.0/go.mod h1:jT3ibf/A0ZVCp89rtCIN0zCJxcE74ypROmHEZYsG/j8=
github.com/jackc/pgx/v4 v4.14.1 h1:71oo1KAGI6mXhLiTMn6iDFcp3e7+zon/capWjl2OEFU=
github.com/jackc/pgx/v4 v4.14.1/go.mod h1:RgDuE4Z34o7XE92RpLsvFiOEfrAUT0Xt2KxvX73W06M=
github.com/jackc/pgx/v4 v4.15.0 h1:B7dTkXsdILD3MF987WGGCcg+tvLW6bZJdEcqVFeU//w=
github.com/jackc/pgx/v4 v4.15.0/go.mod h1:D/zyOyXiaM1TmVWnOM18p0xdDtdakRBa0RsVGI3U3bw=
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.2.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/k0kubun/pp/v3 v3.1.0/go.mod h1:vIrP5CF0n78pKHm2Ku6GVerpZBJvscg48WepUYEk2gw=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.14.1 h1:hLQYb23E8/fO+1u53d02A97a8UnsddcvYzq4ERRU4ds=
github.com/klauspost/compress v1.14.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A=
github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
@ -196,36 +187,37 @@ github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb @@ -196,36 +187,37 @@ github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c=
github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/quasilyte/go-ruleguard/dsl v0.3.19/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
@ -233,16 +225,18 @@ github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThC @@ -233,16 +225,18 @@ github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThC
github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc=
github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sebdah/goldie/v2 v2.5.3/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI=
github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc=
github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA=
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
@ -250,9 +244,10 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf @@ -250,9 +244,10 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
@ -260,6 +255,7 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY @@ -260,6 +255,7 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
@ -274,16 +270,13 @@ go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/ @@ -274,16 +270,13 @@ go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/ratelimit v0.2.0/go.mod h1:YYBV4e4naJvhpitQrWJu1vCpgB7CboMe0qhltKt6mUg=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.20.0 h1:N4oPlghZwYG55MlU6LXk/Zp00FVNE9X9wrYO8CEs4lc=
go.uber.org/zap v1.20.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@ -296,16 +289,14 @@ golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWP @@ -296,16 +289,14 @@ golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWP
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e h1:1SzTfNOXwIS2oWiMF+6qu0OUDKb0dauo6MoDUQyu+yU=
golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 h1:tkVvjkPTB7pnW3jnid7kNyAMPVWllTNOf/qKDze4p9o=
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@ -317,10 +308,9 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v @@ -317,10 +308,9 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba h1:6u6sik+bn/y7vILcYkK3iwTBWN7WtBvB0+SZswQnbf8=
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3 h1:EN5+DfgmRMvRUrMGERW2gQl3Vc+Z7ZMnI/xdEpPSf0c=
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -339,6 +329,7 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w @@ -339,6 +329,7 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -352,10 +343,11 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc @@ -352,10 +343,11 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 h1:QyVthZKMsyaQwBTJE04jdNN0Pp5Fn9Qga0mrgxyERQM=
golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -378,6 +370,7 @@ golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapK @@ -378,6 +370,7 @@ golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -396,13 +389,14 @@ google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/l @@ -396,13 +389,14 @@ google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/l
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
gopkg.in/telebot.v3 v3.0.0 h1:UgHIiE/RdjoDi6nf4xACM7PU3TqiPVV9vvTydCEnrTo=
gopkg.in/telebot.v3 v3.0.0/go.mod h1:7rExV8/0mDDNu9epSrDm/8j22KLaActH1Tbee6YjzWg=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/tucnak/telebot.v3 v3.0.0-20211126232936-7f936709f3ee h1:0jS8G549Rie2L+BvXC+O+HPVyC+8gq3SpR/p2sJSfqg=
gopkg.in/tucnak/telebot.v3 v3.0.0-20211126232936-7f936709f3ee/go.mod h1:1XHg/CpPZtstsm3WY57h1T4X/EQquwOgllQl/TjjgqI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
@ -412,13 +406,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= @@ -412,13 +406,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/postgres v1.2.3 h1:f4t0TmNMy9gh3TU2PX+EppoA6YsgFnyq8Ojtddb42To=
gorm.io/driver/postgres v1.2.3/go.mod h1:pJV6RgYQPG47aM1f0QeOzFH9HxQc8JcmAgjRCgS0wjs=
gorm.io/driver/postgres v1.3.4 h1:evZ7plF+Bp+Lr1mO5NdPvd6M/N98XtwHixGB+y7fdEQ=
gorm.io/driver/postgres v1.3.4/go.mod h1:y0vEuInFKJtijuSGu9e5bs5hzzSzPK+LancpKpvbRBw=
gorm.io/gorm v1.22.3/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
gorm.io/gorm v1.22.5 h1:lYREBgc02Be/5lSCTuysZZDb6ffL2qrat6fg9CFbvXU=
gorm.io/gorm v1.22.5/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.23.1/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.23.4 h1:1BKWM67O6CflSLcwGQR7ccfmC4ebOxQrTfOQGRE9wjg=
gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=

14
main.go

@ -2,18 +2,18 @@ package main @@ -2,18 +2,18 @@ package main
import (
"context"
"gitea.russia9.dev/russia9/muskrat/bot"
"gitea.russia9.dev/russia9/muskrat/bot/handlers"
"gitea.russia9.dev/russia9/muskrat/storage"
"gitea.russia9.dev/russia9/muskrat/types"
"gitea.russia9.dev/russia9/muskrat/userbot"
"github.com/go-redis/redis/v8"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"gopkg.in/tucnak/telebot.v3"
"gopkg.in/tucnak/telebot.v3/layout"
"gopkg.in/telebot.v3"
"gopkg.in/telebot.v3/layout"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"muskrat/bot"
"muskrat/bot/handlers"
"muskrat/storage"
"muskrat/types"
"muskrat/userbot"
"os"
"strconv"
"time"

4
userbot/bot.go

@ -3,6 +3,8 @@ package userbot @@ -3,6 +3,8 @@ package userbot
import (
"context"
"fmt"
"gitea.russia9.dev/russia9/muskrat/storage"
"gitea.russia9.dev/russia9/muskrat/types"
"github.com/go-co-op/gocron"
"github.com/gotd/td/session"
"github.com/gotd/td/telegram"
@ -10,8 +12,6 @@ import ( @@ -10,8 +12,6 @@ import (
"github.com/gotd/td/tg"
"github.com/rs/zerolog/log"
"math/rand"
"muskrat/storage"
"muskrat/types"
"os"
"regexp"
"strconv"

25
vendor/github.com/cenkalti/backoff/v4/.gitignore generated vendored

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
# IDEs
.idea/

10
vendor/github.com/cenkalti/backoff/v4/.travis.yml generated vendored

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
language: go
go:
- 1.13
- 1.x
- tip
before_install:
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
script:
- $HOME/gopath/bin/goveralls -service=travis-ci

20
vendor/github.com/cenkalti/backoff/v4/LICENSE generated vendored

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 Cenk Altı
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

32
vendor/github.com/cenkalti/backoff/v4/README.md generated vendored

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
# Exponential Backoff [![GoDoc][godoc image]][godoc] [![Build Status][travis image]][travis] [![Coverage Status][coveralls image]][coveralls]
This is a Go port of the exponential backoff algorithm from [Google's HTTP Client Library for Java][google-http-java-client].
[Exponential backoff][exponential backoff wiki]
is an algorithm that uses feedback to multiplicatively decrease the rate of some process,
in order to gradually find an acceptable rate.
The retries exponentially increase and stop increasing when a certain threshold is met.
## Usage
Import path is `github.com/cenkalti/backoff/v4`. Please note the version part at the end.
Use https://pkg.go.dev/github.com/cenkalti/backoff/v4 to view the documentation.
## Contributing
* I would like to keep this library as small as possible.
* Please don't send a PR without opening an issue and discussing it first.
* If proposed change is not a common use case, I will probably not accept it.
[godoc]: https://pkg.go.dev/github.com/cenkalti/backoff/v4
[godoc image]: https://godoc.org/github.com/cenkalti/backoff?status.png
[travis]: https://travis-ci.org/cenkalti/backoff
[travis image]: https://travis-ci.org/cenkalti/backoff.png?branch=master
[coveralls]: https://coveralls.io/github/cenkalti/backoff?branch=master
[coveralls image]: https://coveralls.io/repos/github/cenkalti/backoff/badge.svg?branch=master
[google-http-java-client]: https://github.com/google/google-http-java-client/blob/da1aa993e90285ec18579f1553339b00e19b3ab5/google-http-client/src/main/java/com/google/api/client/util/ExponentialBackOff.java
[exponential backoff wiki]: http://en.wikipedia.org/wiki/Exponential_backoff
[advanced example]: https://pkg.go.dev/github.com/cenkalti/backoff/v4?tab=doc#pkg-examples

66
vendor/github.com/cenkalti/backoff/v4/backoff.go generated vendored

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
// Package backoff implements backoff algorithms for retrying operations.
//
// Use Retry function for retrying operations that may fail.
// If Retry does not meet your needs,
// copy/paste the function into your project and modify as you wish.
//
// There is also Ticker type similar to time.Ticker.
// You can use it if you need to work with channels.
//
// See Examples section below for usage examples.
package backoff
import "time"
// BackOff is a backoff policy for retrying an operation.
type BackOff interface {
// NextBackOff returns the duration to wait before retrying the operation,
// or backoff. Stop to indicate that no more retries should be made.
//
// Example usage:
//
// duration := backoff.NextBackOff();
// if (duration == backoff.Stop) {
// // Do not retry operation.
// } else {
// // Sleep for duration and retry operation.
// }
//
NextBackOff() time.Duration
// Reset to initial state.
Reset()
}
// Stop indicates that no more retries should be made for use in NextBackOff().
const Stop time.Duration = -1
// ZeroBackOff is a fixed backoff policy whose backoff time is always zero,
// meaning that the operation is retried immediately without waiting, indefinitely.
type ZeroBackOff struct{}
func (b *ZeroBackOff) Reset() {}
func (b *ZeroBackOff) NextBackOff() time.Duration { return 0 }
// StopBackOff is a fixed backoff policy that always returns backoff.Stop for
// NextBackOff(), meaning that the operation should never be retried.
type StopBackOff struct{}
func (b *StopBackOff) Reset() {}
func (b *StopBackOff) NextBackOff() time.Duration { return Stop }
// ConstantBackOff is a backoff policy that always returns the same backoff delay.
// This is in contrast to an exponential backoff policy,
// which returns a delay that grows longer as you call NextBackOff() over and over again.
type ConstantBackOff struct {
Interval time.Duration
}
func (b *ConstantBackOff) Reset() {}
func (b *ConstantBackOff) NextBackOff() time.Duration { return b.Interval }
func NewConstantBackOff(d time.Duration) *ConstantBackOff {
return &ConstantBackOff{Interval: d}
}

62
vendor/github.com/cenkalti/backoff/v4/context.go generated vendored

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
package backoff
import (
"context"
"time"
)
// BackOffContext is a backoff policy that stops retrying after the context
// is canceled.
type BackOffContext interface { // nolint: golint
BackOff
Context() context.Context
}
type backOffContext struct {
BackOff
ctx context.Context
}
// WithContext returns a BackOffContext with context ctx
//
// ctx must not be nil
func WithContext(b BackOff, ctx context.Context) BackOffContext { // nolint: golint
if ctx == nil {
panic("nil context")
}
if b, ok := b.(*backOffContext); ok {
return &backOffContext{
BackOff: b.BackOff,
ctx: ctx,
}
}
return &backOffContext{
BackOff: b,
ctx: ctx,
}
}
func getContext(b BackOff) context.Context {
if cb, ok := b.(BackOffContext); ok {
return cb.Context()
}
if tb, ok := b.(*backOffTries); ok {
return getContext(tb.delegate)
}
return context.Background()
}
func (b *backOffContext) Context() context.Context {
return b.ctx
}
func (b *backOffContext) NextBackOff() time.Duration {
select {
case <-b.ctx.Done():
return Stop
default:
return b.BackOff.NextBackOff()
}
}

158
vendor/github.com/cenkalti/backoff/v4/exponential.go generated vendored

@ -0,0 +1,158 @@ @@ -0,0 +1,158 @@
package backoff
import (
"math/rand"
"time"
)
/*
ExponentialBackOff is a backoff implementation that increases the backoff
period for each retry attempt using a randomization function that grows exponentially.
NextBackOff() is calculated using the following formula:
randomized interval =
RetryInterval * (random value in range [1 - RandomizationFactor, 1 + RandomizationFactor])
In other words NextBackOff() will range between the randomization factor
percentage below and above the retry interval.
For example, given the following parameters:
RetryInterval = 2
RandomizationFactor = 0.5
Multiplier = 2
the actual backoff period used in the next retry attempt will range between 1 and 3 seconds,
multiplied by the exponential, that is, between 2 and 6 seconds.
Note: MaxInterval caps the RetryInterval and not the randomized interval.
If the time elapsed since an ExponentialBackOff instance is created goes past the
MaxElapsedTime, then the method NextBackOff() starts returning backoff.Stop.
The elapsed time can be reset by calling Reset().
Example: Given the following default arguments, for 10 tries the sequence will be,
and assuming we go over the MaxElapsedTime on the 10th try:
Request # RetryInterval (seconds) Randomized Interval (seconds)
1 0.5 [0.25, 0.75]
2 0.75 [0.375, 1.125]
3 1.125 [0.562, 1.687]
4 1.687 [0.8435, 2.53]
5 2.53 [1.265, 3.795]
6 3.795 [1.897, 5.692]
7 5.692 [2.846, 8.538]
8 8.538 [4.269, 12.807]
9 12.807 [6.403, 19.210]
10 19.210 backoff.Stop
Note: Implementation is not thread-safe.
*/
type ExponentialBackOff struct {
InitialInterval time.Duration
RandomizationFactor float64
Multiplier float64
MaxInterval time.Duration
// After MaxElapsedTime the ExponentialBackOff returns Stop.
// It never stops if MaxElapsedTime == 0.
MaxElapsedTime time.Duration
Stop time.Duration
Clock Clock
currentInterval time.Duration
startTime time.Time
}
// Clock is an interface that returns current time for BackOff.
type Clock interface {
Now() time.Time
}
// Default values for ExponentialBackOff.
const (
DefaultInitialInterval = 500 * time.Millisecond
DefaultRandomizationFactor = 0.5
DefaultMultiplier = 1.5
DefaultMaxInterval = 60 * time.Second
DefaultMaxElapsedTime = 15 * time.Minute
)
// NewExponentialBackOff creates an instance of ExponentialBackOff using default values.
func NewExponentialBackOff() *ExponentialBackOff {
b := &ExponentialBackOff{
InitialInterval: DefaultInitialInterval,
RandomizationFactor: DefaultRandomizationFactor,
Multiplier: DefaultMultiplier,
MaxInterval: DefaultMaxInterval,
MaxElapsedTime: DefaultMaxElapsedTime,
Stop: Stop,
Clock: SystemClock,
}
b.Reset()
return b
}
type systemClock struct{}
func (t systemClock) Now() time.Time {
return time.Now()
}
// SystemClock implements Clock interface that uses time.Now().
var SystemClock = systemClock{}
// Reset the interval back to the initial retry interval and restarts the timer.
// Reset must be called before using b.
func (b *ExponentialBackOff) Reset() {
b.currentInterval = b.InitialInterval
b.startTime = b.Clock.Now()
}
// NextBackOff calculates the next backoff interval using the formula:
// Randomized interval = RetryInterval * (1 ± RandomizationFactor)
func (b *ExponentialBackOff) NextBackOff() time.Duration {
// Make sure we have not gone over the maximum elapsed time.
elapsed := b.GetElapsedTime()
next := getRandomValueFromInterval(b.RandomizationFactor, rand.Float64(), b.currentInterval)
b.incrementCurrentInterval()
if b.MaxElapsedTime != 0 && elapsed+next > b.MaxElapsedTime {
return b.Stop
}
return next
}
// GetElapsedTime returns the elapsed time since an ExponentialBackOff instance
// is created and is reset when Reset() is called.
//
// The elapsed time is computed using time.Now().UnixNano(). It is
// safe to call even while the backoff policy is used by a running
// ticker.
func (b *ExponentialBackOff) GetElapsedTime() time.Duration {
return b.Clock.Now().Sub(b.startTime)
}
// Increments the current interval by multiplying it with the multiplier.
func (b *ExponentialBackOff) incrementCurrentInterval() {
// Check for overflow, if overflow is detected set the current interval to the max interval.
if float64(b.currentInterval) >= float64(b.MaxInterval)/b.Multiplier {
b.currentInterval = b.MaxInterval
} else {
b.currentInterval = time.Duration(float64(b.currentInterval) * b.Multiplier)
}
}
// Returns a random value from the following interval:
// [currentInterval - randomizationFactor * currentInterval, currentInterval + randomizationFactor * currentInterval].
func getRandomValueFromInterval(randomizationFactor, random float64, currentInterval time.Duration) time.Duration {
var delta = randomizationFactor * float64(currentInterval)
var minInterval = float64(currentInterval) - delta
var maxInterval = float64(currentInterval) + delta
// Get a random value from the range [minInterval, maxInterval].
// The formula used below has a +1 because if the minInterval is 1 and the maxInterval is 3 then
// we want a 33% chance for selecting either 1, 2 or 3.
return time.Duration(minInterval + (random * (maxInterval - minInterval + 1)))
}

112
vendor/github.com/cenkalti/backoff/v4/retry.go generated vendored

@ -0,0 +1,112 @@ @@ -0,0 +1,112 @@
package backoff
import (
"errors"
"time"
)
// An Operation is executing by Retry() or RetryNotify().
// The operation will be retried using a backoff policy if it returns an error.
type Operation func() error
// Notify is a notify-on-error function. It receives an operation error and
// backoff delay if the operation failed (with an error).
//
// NOTE that if the backoff policy stated to stop retrying,
// the notify function isn't called.
type Notify func(error, time.Duration)
// Retry the operation o until it does not return error or BackOff stops.
// o is guaranteed to be run at least once.
//
// If o returns a *PermanentError, the operation is not retried, and the
// wrapped error is returned.
//
// Retry sleeps the goroutine for the duration returned by BackOff after a
// failed operation returns.
func Retry(o Operation, b BackOff) error {
return RetryNotify(o, b, nil)
}
// RetryNotify calls notify function with the error and wait duration
// for each failed attempt before sleep.
func RetryNotify(operation Operation, b BackOff, notify Notify) error {
return RetryNotifyWithTimer(operation, b, notify, nil)
}
// RetryNotifyWithTimer calls notify function with the error and wait duration using the given Timer
// for each failed attempt before sleep.
// A default timer that uses system timer is used when nil is passed.
func RetryNotifyWithTimer(operation Operation, b BackOff, notify Notify, t Timer) error {
var err error
var next time.Duration
if t == nil {
t = &defaultTimer{}
}
defer func() {
t.Stop()
}()
ctx := getContext(b)
b.Reset()
for {
if err = operation(); err == nil {
return nil
}
var permanent *PermanentError
if errors.As(err, &permanent) {
return permanent.Err
}
if next = b.NextBackOff(); next == Stop {
if cerr := ctx.Err(); cerr != nil {
return cerr
}
return err
}
if notify != nil {
notify(err, next)
}
t.Start(next)
select {
case <-ctx.Done():
return ctx.Err()
case <-t.C():
}
}
}
// PermanentError signals that the operation should not be retried.
type PermanentError struct {
Err error
}
func (e *PermanentError) Error() string {
return e.Err.Error()
}
func (e *PermanentError) Unwrap() error {
return e.Err
}
func (e *PermanentError) Is(target error) bool {
_, ok := target.(*PermanentError)
return ok
}
// Permanent wraps the given err in a *PermanentError.
func Permanent(err error) error {
if err == nil {
return nil
}
return &PermanentError{
Err: err,
}
}

97
vendor/github.com/cenkalti/backoff/v4/ticker.go generated vendored

@ -0,0 +1,97 @@ @@ -0,0 +1,97 @@
package backoff
import (
"context"
"sync"
"time"
)
// Ticker holds a channel that delivers `ticks' of a clock at times reported by a BackOff.
//
// Ticks will continue to arrive when the previous operation is still running,
// so operations that take a while to fail could run in quick succession.
type Ticker struct {
C <-chan time.Time
c chan time.Time
b BackOff
ctx context.Context
timer Timer
stop chan struct{}
stopOnce sync.Once
}
// NewTicker returns a new Ticker containing a channel that will send
// the time at times specified by the BackOff argument. Ticker is
// guaranteed to tick at least once. The channel is closed when Stop
// method is called or BackOff stops. It is not safe to manipulate the
// provided backoff policy (notably calling NextBackOff or Reset)
// while the ticker is running.
func NewTicker(b BackOff) *Ticker {
return NewTickerWithTimer(b, &defaultTimer{})
}
// NewTickerWithTimer returns a new Ticker with a custom timer.
// A default timer that uses system timer is used when nil is passed.
func NewTickerWithTimer(b BackOff, timer Timer) *Ticker {
if timer == nil {
timer = &defaultTimer{}
}
c := make(chan time.Time)
t := &Ticker{
C: c,
c: c,
b: b,
ctx: getContext(b),
timer: timer,
stop: make(chan struct{}),
}
t.b.Reset()
go t.run()
return t
}
// Stop turns off a ticker. After Stop, no more ticks will be sent.
func (t *Ticker) Stop() {
t.stopOnce.Do(func() { close(t.stop) })
}
func (t *Ticker) run() {
c := t.c
defer close(c)
// Ticker is guaranteed to tick at least once.
afterC := t.send(time.Now())
for {
if afterC == nil {
return
}
select {
case tick := <-afterC:
afterC = t.send(tick)
case <-t.stop:
t.c = nil // Prevent future ticks from being sent to the channel.
return
case <-t.ctx.Done():
return
}
}
}
func (t *Ticker) send(tick time.Time) <-chan time.Time {
select {
case t.c <- tick:
case <-t.stop:
return nil
}
next := t.b.NextBackOff()
if next == Stop {
t.Stop()
return nil
}
t.timer.Start(next)
return t.timer.C()
}

35
vendor/github.com/cenkalti/backoff/v4/timer.go generated vendored

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
package backoff
import "time"
type Timer interface {
Start(duration time.Duration)
Stop()
C() <-chan time.Time
}
// defaultTimer implements Timer interface using time.Timer
type defaultTimer struct {
timer *time.Timer
}
// C returns the timers channel which receives the current time when the timer fires.
func (t *defaultTimer) C() <-chan time.Time {
return t.timer.C
}
// Start starts the timer to fire after the given duration
func (t *defaultTimer) Start(duration time.Duration) {
if t.timer == nil {
t.timer = time.NewTimer(duration)
} else {
t.timer.Reset(duration)
}
}
// Stop is called when the timer is not used anymore and resources may be freed.
func (t *defaultTimer) Stop() {
if t.timer != nil {
t.timer.Stop()
}
}

38
vendor/github.com/cenkalti/backoff/v4/tries.go generated vendored

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
package backoff
import "time"
/*
WithMaxRetries creates a wrapper around another BackOff, which will
return Stop if NextBackOff() has been called too many times since
the last time Reset() was called
Note: Implementation is not thread-safe.
*/
func WithMaxRetries(b BackOff, max uint64) BackOff {
return &backOffTries{delegate: b, maxTries: max}
}
type backOffTries struct {
delegate BackOff
maxTries uint64
numTries uint64
}
func (b *backOffTries) NextBackOff() time.Duration {
if b.maxTries == 0 {
return Stop
}
if b.maxTries > 0 {
if b.maxTries <= b.numTries {
return Stop
}
b.numTries++
}
return b.delegate.NextBackOff()
}
func (b *backOffTries) Reset() {
b.numTries = 0
b.delegate.Reset()
}

22
vendor/github.com/cespare/xxhash/v2/LICENSE.txt generated vendored

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
Copyright (c) 2016 Caleb Spare
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

69
vendor/github.com/cespare/xxhash/v2/README.md generated vendored

@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
# xxhash
[![Go Reference](https://pkg.go.dev/badge/github.com/cespare/xxhash/v2.svg)](https://pkg.go.dev/github.com/cespare/xxhash/v2)
[![Test](https://github.com/cespare/xxhash/actions/workflows/test.yml/badge.svg)](https://github.com/cespare/xxhash/actions/workflows/test.yml)
xxhash is a Go implementation of the 64-bit
[xxHash](http://cyan4973.github.io/xxHash/) algorithm, XXH64. This is a
high-quality hashing algorithm that is much faster than anything in the Go
standard library.
This package provides a straightforward API:
```
func Sum64(b []byte) uint64
func Sum64String(s string) uint64
type Digest struct{ ... }
func New() *Digest
```
The `Digest` type implements hash.Hash64. Its key methods are:
```
func (*Digest) Write([]byte) (int, error)
func (*Digest) WriteString(string) (int, error)
func (*Digest) Sum64() uint64
```
This implementation provides a fast pure-Go implementation and an even faster
assembly implementation for amd64.
## Compatibility
This package is in a module and the latest code is in version 2 of the module.
You need a version of Go with at least "minimal module compatibility" to use
github.com/cespare/xxhash/v2:
* 1.9.7+ for Go 1.9
* 1.10.3+ for Go 1.10
* Go 1.11 or later
I recommend using the latest release of Go.
## Benchmarks
Here are some quick benchmarks comparing the pure-Go and assembly
implementations of Sum64.
| input size | purego | asm |
| --- | --- | --- |
| 5 B | 979.66 MB/s | 1291.17 MB/s |
| 100 B | 7475.26 MB/s | 7973.40 MB/s |
| 4 KB | 17573.46 MB/s | 17602.65 MB/s |
| 10 MB | 17131.46 MB/s | 17142.16 MB/s |
These numbers were generated on Ubuntu 18.04 with an Intel i7-8700K CPU using
the following commands under Go 1.11.2:
```
$ go test -tags purego -benchtime 10s -bench '/xxhash,direct,bytes'
$ go test -benchtime 10s -bench '/xxhash,direct,bytes'
```
## Projects using this package
- [InfluxDB](https://github.com/influxdata/influxdb)
- [Prometheus](https://github.com/prometheus/prometheus)
- [VictoriaMetrics](https://github.com/VictoriaMetrics/VictoriaMetrics)
- [FreeCache](https://github.com/coocood/freecache)
- [FastCache](https://github.com/VictoriaMetrics/fastcache)

235
vendor/github.com/cespare/xxhash/v2/xxhash.go generated vendored

@ -0,0 +1,235 @@ @@ -0,0 +1,235 @@
// Package xxhash implements the 64-bit variant of xxHash (XXH64) as described
// at http://cyan4973.github.io/xxHash/.
package xxhash
import (
"encoding/binary"
"errors"
"math/bits"
)
const (
prime1 uint64 = 11400714785074694791
prime2 uint64 = 14029467366897019727
prime3 uint64 = 1609587929392839161
prime4 uint64 = 9650029242287828579
prime5 uint64 = 2870177450012600261
)
// NOTE(caleb): I'm using both consts and vars of the primes. Using consts where
// possible in the Go code is worth a small (but measurable) performance boost
// by avoiding some MOVQs. Vars are needed for the asm and also are useful for
// convenience in the Go code in a few places where we need to intentionally
// avoid constant arithmetic (e.g., v1 := prime1 + prime2 fails because the
// result overflows a uint64).
var (
prime1v = prime1
prime2v = prime2
prime3v = prime3
prime4v = prime4
prime5v = prime5
)
// Digest implements hash.Hash64.
type Digest struct {
v1 uint64
v2 uint64
v3 uint64
v4 uint64
total uint64
mem [32]byte
n int // how much of mem is used
}
// New creates a new Digest that computes the 64-bit xxHash algorithm.
func New() *Digest {
var d Digest
d.Reset()
return &d
}
// Reset clears the Digest's state so that it can be reused.
func (d *Digest) Reset() {
d.v1 = prime1v + prime2
d.v2 = prime2
d.v3 = 0
d.v4 = -prime1v
d.total = 0
d.n = 0
}
// Size always returns 8 bytes.
func (d *Digest) Size() int { return 8 }
// BlockSize always returns 32 bytes.
func (d *Digest) BlockSize() int { return 32 }
// Write adds more data to d. It always returns len(b), nil.
func (d *Digest) Write(b []byte) (n int, err error) {
n = len(b)
d.total += uint64(n)
if d.n+n < 32 {
// This new data doesn't even fill the current block.
copy(d.mem[d.n:], b)
d.n += n
return
}
if d.n > 0 {
// Finish off the partial block.
copy(d.mem[d.n:], b)
d.v1 = round(d.v1, u64(d.mem[0:8]))
d.v2 = round(d.v2, u64(d.mem[8:16]))
d.v3 = round(d.v3, u64(d.mem[16:24]))
d.v4 = round(d.v4, u64(d.mem[24:32]))
b = b[32-d.n:]
d.n = 0
}
if len(b) >= 32 {
// One or more full blocks left.
nw := writeBlocks(d, b)
b = b[nw:]
}
// Store any remaining partial block.
copy(d.mem[:], b)
d.n = len(b)
return
}
// Sum appends the current hash to b and returns the resulting slice.
func (d *Digest) Sum(b []byte) []byte {
s := d.Sum64()
return append(
b,
byte(s>>56),
byte(s>>48),
byte(s>>40),
byte(s>>32),
byte(s>>24),
byte(s>>16),
byte(s>>8),
byte(s),
)
}
// Sum64 returns the current hash.
func (d *Digest) Sum64() uint64 {
var h uint64
if d.total >= 32 {
v1, v2, v3, v4 := d.v1, d.v2, d.v3, d.v4
h = rol1(v1) + rol7(v2) + rol12(v3) + rol18(v4)
h = mergeRound(h, v1)
h = mergeRound(h, v2)
h = mergeRound(h, v3)
h = mergeRound(h, v4)
} else {
h = d.v3 + prime5
}
h += d.total
i, end := 0, d.n
for ; i+8 <= end; i += 8 {
k1 := round(0, u64(d.mem[i:i+8]))
h ^= k1
h = rol27(h)*prime1 + prime4
}
if i+4 <= end {
h ^= uint64(u32(d.mem[i:i+4])) * prime1
h = rol23(h)*prime2 + prime3
i += 4
}
for i < end {
h ^= uint64(d.mem[i]) * prime5
h = rol11(h) * prime1
i++
}
h ^= h >> 33
h *= prime2
h ^= h >> 29
h *= prime3
h ^= h >> 32
return h
}
const (
magic = "xxh\x06"
marshaledSize = len(magic) + 8*5 + 32
)
// MarshalBinary implements the encoding.BinaryMarshaler interface.
func (d *Digest) MarshalBinary() ([]byte, error) {
b := make([]byte, 0, marshaledSize)
b = append(b, magic...)
b = appendUint64(b, d.v1)
b = appendUint64(b, d.v2)
b = appendUint64(b, d.v3)
b = appendUint64(b, d.v4)
b = appendUint64(b, d.total)
b = append(b, d.mem[:d.n]...)
b = b[:len(b)+len(d.mem)-d.n]
return b, nil
}
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (d *Digest) UnmarshalBinary(b []byte) error {
if len(b) < len(magic) || string(b[:len(magic)]) != magic {
return errors.New("xxhash: invalid hash state identifier")
}
if len(b) != marshaledSize {
return errors.New("xxhash: invalid hash state size")
}
b = b[len(magic):]
b, d.v1 = consumeUint64(b)
b, d.v2 = consumeUint64(b)
b, d.v3 = consumeUint64(b)
b, d.v4 = consumeUint64(b)
b, d.total = consumeUint64(b)
copy(d.mem[:], b)
d.n = int(d.total % uint64(len(d.mem)))
return nil
}
func appendUint64(b []byte, x uint64) []byte {
var a [8]byte
binary.LittleEndian.PutUint64(a[:], x)
return append(b, a[:]...)
}
func consumeUint64(b []byte) ([]byte, uint64) {
x := u64(b)
return b[8:], x
}
func u64(b []byte) uint64 { return binary.LittleEndian.Uint64(b) }
func u32(b []byte) uint32 { return binary.LittleEndian.Uint32(b) }
func round(acc, input uint64) uint64 {
acc += input * prime2
acc = rol31(acc)
acc *= prime1
return acc
}
func mergeRound(acc, val uint64) uint64 {
val = round(0, val)
acc ^= val
acc = acc*prime1 + prime4
return acc
}
func rol1(x uint64) uint64 { return bits.RotateLeft64(x, 1) }
func rol7(x uint64) uint64 { return bits.RotateLeft64(x, 7) }
func rol11(x uint64) uint64 { return bits.RotateLeft64(x, 11) }
func rol12(x uint64) uint64 { return bits.RotateLeft64(x, 12) }
func rol18(x uint64) uint64 { return bits.RotateLeft64(x, 18) }
func rol23(x uint64) uint64 { return bits.RotateLeft64(x, 23) }
func rol27(x uint64) uint64 { return bits.RotateLeft64(x, 27) }
func rol31(x uint64) uint64 { return bits.RotateLeft64(x, 31) }

13
vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go generated vendored

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
// +build !appengine
// +build gc
// +build !purego
package xxhash
// Sum64 computes the 64-bit xxHash digest of b.
//
//go:noescape
func Sum64(b []byte) uint64
//go:noescape
func writeBlocks(d *Digest, b []byte) int

215
vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s generated vendored

@ -0,0 +1,215 @@ @@ -0,0 +1,215 @@
// +build !appengine
// +build gc
// +build !purego
#include "textflag.h"
// Register allocation:
// AX h
// SI pointer to advance through b
// DX n
// BX loop end
// R8 v1, k1
// R9 v2
// R10 v3
// R11 v4
// R12 tmp
// R13 prime1v
// R14 prime2v
// DI prime4v
// round reads from and advances the buffer pointer in SI.
// It assumes that R13 has prime1v and R14 has prime2v.
#define round(r) \
MOVQ (SI), R12 \
ADDQ $8, SI \
IMULQ R14, R12 \
ADDQ R12, r \
ROLQ $31, r \
IMULQ R13, r
// mergeRound applies a merge round on the two registers acc and val.
// It assumes that R13 has prime1v, R14 has prime2v, and DI has prime4v.
#define mergeRound(acc, val) \
IMULQ R14, val \
ROLQ $31, val \
IMULQ R13, val \
XORQ val, acc \
IMULQ R13, acc \
ADDQ DI, acc
// func Sum64(b []byte) uint64
TEXT ·Sum64(SB), NOSPLIT, $0-32
// Load fixed primes.
MOVQ ·prime1v(SB), R13
MOVQ ·prime2v(SB), R14
MOVQ ·prime4v(SB), DI
// Load slice.
MOVQ b_base+0(FP), SI
MOVQ b_len+8(FP), DX
LEAQ (SI)(DX*1), BX
// The first loop limit will be len(b)-32.
SUBQ $32, BX
// Check whether we have at least one block.
CMPQ DX, $32
JLT noBlocks
// Set up initial state (v1, v2, v3, v4).
MOVQ R13, R8
ADDQ R14, R8
MOVQ R14, R9
XORQ R10, R10
XORQ R11, R11
SUBQ R13, R11
// Loop until SI > BX.
blockLoop:
round(R8)
round(R9)
round(R10)
round(R11)
CMPQ SI, BX
JLE blockLoop
MOVQ R8, AX
ROLQ $1, AX
MOVQ R9, R12
ROLQ $7, R12
ADDQ R12, AX
MOVQ R10, R12
ROLQ $12, R12
ADDQ R12, AX
MOVQ R11, R12
ROLQ $18, R12
ADDQ R12, AX
mergeRound(AX, R8)
mergeRound(AX, R9)
mergeRound(AX, R10)
mergeRound(AX, R11)
JMP afterBlocks
noBlocks:
MOVQ ·prime5v(SB), AX
afterBlocks:
ADDQ DX, AX
// Right now BX has len(b)-32, and we want to loop until SI > len(b)-8.
ADDQ $24, BX
CMPQ SI, BX
JG fourByte
wordLoop:
// Calculate k1.
MOVQ (SI), R8
ADDQ $8, SI
IMULQ R14, R8
ROLQ $31, R8
IMULQ R13, R8
XORQ R8, AX
ROLQ $27, AX
IMULQ R13, AX
ADDQ DI, AX
CMPQ SI, BX
JLE wordLoop
fourByte:
ADDQ $4, BX
CMPQ SI, BX
JG singles
MOVL (SI), R8
ADDQ $4, SI
IMULQ R13, R8
XORQ R8, AX
ROLQ $23, AX
IMULQ R14, AX
ADDQ ·prime3v(SB), AX
singles:
ADDQ $4, BX
CMPQ SI, BX
JGE finalize
singlesLoop:
MOVBQZX (SI), R12
ADDQ $1, SI
IMULQ ·prime5v(SB), R12
XORQ R12, AX
ROLQ $11, AX
IMULQ R13, AX
CMPQ SI, BX
JL singlesLoop
finalize:
MOVQ AX, R12
SHRQ $33, R12
XORQ R12, AX
IMULQ R14, AX
MOVQ AX, R12
SHRQ $29, R12
XORQ R12, AX
IMULQ ·prime3v(SB), AX
MOVQ AX, R12
SHRQ $32, R12
XORQ R12, AX
MOVQ AX, ret+24(FP)
RET
// writeBlocks uses the same registers as above except that it uses AX to store
// the d pointer.
// func writeBlocks(d *Digest, b []byte) int
TEXT ·writeBlocks(SB), NOSPLIT, $0-40
// Load fixed primes needed for round.
MOVQ ·prime1v(SB), R13
MOVQ ·prime2v(SB), R14
// Load slice.
MOVQ b_base+8(FP), SI
MOVQ b_len+16(FP), DX
LEAQ (SI)(DX*1), BX
SUBQ $32, BX
// Load vN from d.
MOVQ d+0(FP), AX
MOVQ 0(AX), R8 // v1
MOVQ 8(AX), R9 // v2
MOVQ 16(AX), R10 // v3
MOVQ 24(AX), R11 // v4
// We don't need to check the loop condition here; this function is
// always called with at least one block of data to process.
blockLoop:
round(R8)
round(R9)
round(R10)
round(R11)
CMPQ SI, BX
JLE blockLoop
// Copy vN back to d.
MOVQ R8, 0(AX)
MOVQ R9, 8(AX)
MOVQ R10, 16(AX)
MOVQ R11, 24(AX)
// The number of bytes written is SI minus the old base pointer.
SUBQ b_base+8(FP), SI
MOVQ SI, ret+32(FP)
RET

76
vendor/github.com/cespare/xxhash/v2/xxhash_other.go generated vendored

@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
// +build !amd64 appengine !gc purego
package xxhash
// Sum64 computes the 64-bit xxHash digest of b.
func Sum64(b []byte) uint64 {
// A simpler version would be
// d := New()
// d.Write(b)
// return d.Sum64()
// but this is faster, particularly for small inputs.
n := len(b)
var h uint64
if n >= 32 {
v1 := prime1v + prime2
v2 := prime2
v3 := uint64(0)
v4 := -prime1v
for len(b) >= 32 {
v1 = round(v1, u64(b[0:8:len(b)]))
v2 = round(v2, u64(b[8:16:len(b)]))
v3 = round(v3, u64(b[16:24:len(b)]))
v4 = round(v4, u64(b[24:32:len(b)]))
b = b[32:len(b):len(b)]
}
h = rol1(v1) + rol7(v2) + rol12(v3) + rol18(v4)
h = mergeRound(h, v1)
h = mergeRound(h, v2)
h = mergeRound(h, v3)
h = mergeRound(h, v4)
} else {
h = prime5
}
h += uint64(n)
i, end := 0, len(b)
for ; i+8 <= end; i += 8 {
k1 := round(0, u64(b[i:i+8:len(b)]))
h ^= k1
h = rol27(h)*prime1 + prime4
}
if i+4 <= end {
h ^= uint64(u32(b[i:i+4:len(b)])) * prime1
h = rol23(h)*prime2 + prime3
i += 4
}
for ; i < end; i++ {
h ^= uint64(b[i]) * prime5
h = rol11(h) * prime1
}
h ^= h >> 33
h *= prime2
h ^= h >> 29
h *= prime3
h ^= h >> 32
return h
}
func writeBlocks(d *Digest, b []byte) int {
v1, v2, v3, v4 := d.v1, d.v2, d.v3, d.v4
n := len(b)
for len(b) >= 32 {
v1 = round(v1, u64(b[0:8:len(b)]))
v2 = round(v2, u64(b[8:16:len(b)]))
v3 = round(v3, u64(b[16:24:len(b)]))
v4 = round(v4, u64(b[24:32:len(b)]))
b = b[32:len(b):len(b)]
}
d.v1, d.v2, d.v3, d.v4 = v1, v2, v3, v4
return n - len(b)
}

15
vendor/github.com/cespare/xxhash/v2/xxhash_safe.go generated vendored

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
// +build appengine
// This file contains the safe implementations of otherwise unsafe-using code.
package xxhash
// Sum64String computes the 64-bit xxHash digest of s.
func Sum64String(s string) uint64 {
return Sum64([]byte(s))
}
// WriteString adds more data to d. It always returns len(s), nil.
func (d *Digest) WriteString(s string) (n int, err error) {
return d.Write([]byte(s))
}

57
vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go generated vendored

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
// +build !appengine
// This file encapsulates usage of unsafe.
// xxhash_safe.go contains the safe implementations.
package xxhash
import (
"unsafe"
)
// In the future it's possible that compiler optimizations will make these
// XxxString functions unnecessary by realizing that calls such as
// Sum64([]byte(s)) don't need to copy s. See https://golang.org/issue/2205.
// If that happens, even if we keep these functions they can be replaced with
// the trivial safe code.
// NOTE: The usual way of doing an unsafe string-to-[]byte conversion is:
//
// var b []byte
// bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
// bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data
// bh.Len = len(s)
// bh.Cap = len(s)
//
// Unfortunately, as of Go 1.15.3 the inliner's cost model assigns a high enough
// weight to this sequence of expressions that any function that uses it will
// not be inlined. Instead, the functions below use a different unsafe
// conversion designed to minimize the inliner weight and allow both to be
// inlined. There is also a test (TestInlining) which verifies that these are
// inlined.
//
// See https://github.com/golang/go/issues/42739 for discussion.
// Sum64String computes the 64-bit xxHash digest of s.
// It may be faster than Sum64([]byte(s)) by avoiding a copy.
func Sum64String(s string) uint64 {
b := *(*[]byte)(unsafe.Pointer(&sliceHeader{s, len(s)}))
return Sum64(b)
}
// WriteString adds more data to d. It always returns len(s), nil.
// It may be faster than Write([]byte(s)) by avoiding a copy.
func (d *Digest) WriteString(s string) (n int, err error) {
d.Write(*(*[]byte)(unsafe.Pointer(&sliceHeader{s, len(s)})))
// d.Write always returns len(s), nil.
// Ignoring the return output and returning these fixed values buys a
// savings of 6 in the inliner's cost model.
return len(s), nil
}
// sliceHeader is similar to reflect.SliceHeader, but it assumes that the layout
// of the first two words is the same as the layout of a string.
type sliceHeader struct {
s string
cap int
}

21
vendor/github.com/dgryski/go-rendezvous/LICENSE generated vendored

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017-2020 Damian Gryski <damian@gryski.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

79
vendor/github.com/dgryski/go-rendezvous/rdv.go generated vendored

@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
package rendezvous
type Rendezvous struct {
nodes map[string]int
nstr []string
nhash []uint64
hash Hasher
}
type Hasher func(s string) uint64
func New(nodes []string, hash Hasher) *Rendezvous {
r := &Rendezvous{
nodes: make(map[string]int, len(nodes)),
nstr: make([]string, len(nodes)),
nhash: make([]uint64, len(nodes)),
hash: hash,
}
for i, n := range nodes {
r.nodes[n] = i
r.nstr[i] = n
r.nhash[i] = hash(n)
}
return r
}
func (r *Rendezvous) Lookup(k string) string {
// short-circuit if we're empty
if len(r.nodes) == 0 {
return ""
}
khash := r.hash(k)
var midx int
var mhash = xorshiftMult64(khash ^ r.nhash[0])
for i, nhash := range r.nhash[1:] {
if h := xorshiftMult64(khash ^ nhash); h > mhash {
midx = i + 1
mhash = h
}
}
return r.nstr[midx]
}
func (r *Rendezvous) Add(node string) {
r.nodes[node] = len(r.nstr)
r.nstr = append(r.nstr, node)
r.nhash = append(r.nhash, r.hash(node))
}
func (r *Rendezvous) Remove(node string) {
// find index of node to remove
nidx := r.nodes[node]
// remove from the slices
l := len(r.nstr)
r.nstr[nidx] = r.nstr[l]
r.nstr = r.nstr[:l]
r.nhash[nidx] = r.nhash[l]
r.nhash = r.nhash[:l]
// update the map
delete(r.nodes, node)
moved := r.nstr[nidx]
r.nodes[moved] = nidx
}
func xorshiftMult64(x uint64) uint64 {
x ^= x >> 12 // a
x ^= x << 25 // b
x ^= x >> 27 // c
return x * 2685821657736338717
}

20
vendor/github.com/fatih/color/LICENSE.md generated vendored

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Fatih Arslan
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

178
vendor/github.com/fatih/color/README.md generated vendored

@ -0,0 +1,178 @@ @@ -0,0 +1,178 @@
# color [![](https://github.com/fatih/color/workflows/build/badge.svg)](https://github.com/fatih/color/actions) [![PkgGoDev](https://pkg.go.dev/badge/github.com/fatih/color)](https://pkg.go.dev/github.com/fatih/color)
Color lets you use colorized outputs in terms of [ANSI Escape
Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It
has support for Windows too! The API can be used in several ways, pick one that
suits you.
![Color](https://user-images.githubusercontent.com/438920/96832689-03b3e000-13f4-11eb-9803-46f4c4de3406.jpg)
## Install
```bash
go get github.com/fatih/color
```
## Examples
### Standard colors
```go
// Print with default helper functions
color.Cyan("Prints text in cyan.")
// A newline will be appended automatically
color.Blue("Prints %s in blue.", "text")
// These are using the default foreground colors
color.Red("We have red")
color.Magenta("And many others ..")
```
### Mix and reuse colors
```go
// Create a new color object
c := color.New(color.FgCyan).Add(color.Underline)
c.Println("Prints cyan text with an underline.")
// Or just add them to New()
d := color.New(color.FgCyan, color.Bold)
d.Printf("This prints bold cyan %s\n", "too!.")
// Mix up foreground and background colors, create new mixes!
red := color.New(color.FgRed)
boldRed := red.Add(color.Bold)
boldRed.Println("This will print text in bold red.")
whiteBackground := red.Add(color.BgWhite)
whiteBackground.Println("Red text with white background.")
```
### Use your own output (io.Writer)
```go
// Use your own io.Writer output
color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
blue := color.New(color.FgBlue)
blue.Fprint(writer, "This will print text in blue.")
```
### Custom print functions (PrintFunc)
```go
// Create a custom print function for convenience
red := color.New(color.FgRed).PrintfFunc()
red("Warning")
red("Error: %s", err)
// Mix up multiple attributes
notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
notice("Don't forget this...")
```
### Custom fprint functions (FprintFunc)
```go
blue := color.New(color.FgBlue).FprintfFunc()
blue(myWriter, "important notice: %s", stars)
// Mix up with multiple attributes
success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
success(myWriter, "Don't forget this...")
```
### Insert into noncolor strings (SprintFunc)
```go
// Create SprintXxx functions to mix strings with other non-colorized strings:
yellow := color.New(color.FgYellow).SprintFunc()
red := color.New(color.FgRed).SprintFunc()
fmt.Printf("This is a %s and this is %s.\n", yellow("warning"), red("error"))
info := color.New(color.FgWhite, color.BgGreen).SprintFunc()
fmt.Printf("This %s rocks!\n", info("package"))
// Use helper functions
fmt.Println("This", color.RedString("warning"), "should be not neglected.")
fmt.Printf("%v %v\n", color.GreenString("Info:"), "an important message.")
// Windows supported too! Just don't forget to change the output to color.Output
fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
```
### Plug into existing code
```go
// Use handy standard colors
color.Set(color.FgYellow)
fmt.Println("Existing text will now be in yellow")
fmt.Printf("This one %s\n", "too")
color.Unset() // Don't forget to unset
// You can mix up parameters
color.Set(color.FgMagenta, color.Bold)
defer color.Unset() // Use it in your function
fmt.Println("All text will now be bold magenta.")
```
### Disable/Enable color
There might be a case where you want to explicitly disable/enable color output. the
`go-isatty` package will automatically disable color output for non-tty output streams
(for example if the output were piped directly to `less`).
The `color` package also disables color output if the [`NO_COLOR`](https://no-color.org) environment
variable is set (regardless of its value).
`Color` has support to disable/enable colors programatically both globally and
for single color definitions. For example suppose you have a CLI app and a
`--no-color` bool flag. You can easily disable the color output with:
```go
var flagNoColor = flag.Bool("no-color", false, "Disable color output")
if *flagNoColor {
color.NoColor = true // disables colorized output
}
```
It also has support for single color definitions (local). You can
disable/enable color output on the fly:
```go
c := color.New(color.FgCyan)
c.Println("Prints cyan text")
c.DisableColor()
c.Println("This is printed without any color")
c.EnableColor()
c.Println("This prints again cyan...")
```
## GitHub Actions
To output color in GitHub Actions (or other CI systems that support ANSI colors), make sure to set `color.NoColor = false` so that it bypasses the check for non-tty output streams.
## Todo
* Save/Return previous values
* Evaluate fmt.Formatter interface
## Credits
* [Fatih Arslan](https://github.com/fatih)
* Windows support via @mattn: [colorable](https://github.com/mattn/go-colorable)
## License
The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) for more details

618
vendor/github.com/fatih/color/color.go generated vendored

@ -0,0 +1,618 @@ @@ -0,0 +1,618 @@
package color
import (
"fmt"
"io"
"os"
"strconv"
"strings"
"sync"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
)
var (
// NoColor defines if the output is colorized or not. It's dynamically set to
// false or true based on the stdout's file descriptor referring to a terminal
// or not. It's also set to true if the NO_COLOR environment variable is
// set (regardless of its value). This is a global option and affects all
// colors. For more control over each color block use the methods
// DisableColor() individually.
NoColor = noColorExists() || os.Getenv("TERM") == "dumb" ||
(!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()))
// Output defines the standard output of the print functions. By default
// os.Stdout is used.
Output = colorable.NewColorableStdout()
// Error defines a color supporting writer for os.Stderr.
Error = colorable.NewColorableStderr()
// colorsCache is used to reduce the count of created Color objects and
// allows to reuse already created objects with required Attribute.
colorsCache = make(map[Attribute]*Color)
colorsCacheMu sync.Mutex // protects colorsCache
)
// noColorExists returns true if the environment variable NO_COLOR exists.
func noColorExists() bool {
_, exists := os.LookupEnv("NO_COLOR")
return exists
}
// Color defines a custom color object which is defined by SGR parameters.
type Color struct {
params []Attribute
noColor *bool
}
// Attribute defines a single SGR Code
type Attribute int
const escape = "\x1b"
// Base attributes
const (
Reset Attribute = iota
Bold
Faint
Italic
Underline
BlinkSlow
BlinkRapid
ReverseVideo
Concealed
CrossedOut
)
// Foreground text colors
const (
FgBlack Attribute = iota + 30
FgRed
FgGreen
FgYellow
FgBlue
FgMagenta
FgCyan
FgWhite
)
// Foreground Hi-Intensity text colors
const (
FgHiBlack Attribute = iota + 90
FgHiRed
FgHiGreen
FgHiYellow
FgHiBlue
FgHiMagenta
FgHiCyan
FgHiWhite
)
// Background text colors
const (
BgBlack Attribute = iota + 40
BgRed
BgGreen
BgYellow
BgBlue
BgMagenta
BgCyan
BgWhite
)
// Background Hi-Intensity text colors
const (
BgHiBlack Attribute = iota + 100
BgHiRed
BgHiGreen
BgHiYellow
BgHiBlue
BgHiMagenta
BgHiCyan
BgHiWhite
)
// New returns a newly created color object.
func New(value ...Attribute) *Color {
c := &Color{
params: make([]Attribute, 0),
}
if noColorExists() {
c.noColor = boolPtr(true)
}
c.Add(value...)
return c
}
// Set sets the given parameters immediately. It will change the color of
// output with the given SGR parameters until color.Unset() is called.
func Set(p ...Attribute) *Color {
c := New(p...)
c.Set()
return c
}
// Unset resets all escape attributes and clears the output. Usually should
// be called after Set().
func Unset() {
if NoColor {
return
}
fmt.Fprintf(Output, "%s[%dm", escape, Reset)
}
// Set sets the SGR sequence.
func (c *Color) Set() *Color {
if c.isNoColorSet() {
return c
}
fmt.Fprintf(Output, c.format())
return c
}
func (c *Color) unset() {
if c.isNoColorSet() {
return
}
Unset()
}
func (c *Color) setWriter(w io.Writer) *Color {
if c.isNoColorSet() {
return c
}
fmt.Fprintf(w, c.format())
return c
}
func (c *Color) unsetWriter(w io.Writer) {
if c.isNoColorSet() {
return
}
if NoColor {
return
}
fmt.Fprintf(w, "%s[%dm", escape, Reset)
}
// Add is used to chain SGR parameters. Use as many as parameters to combine
// and create custom color objects. Example: Add(color.FgRed, color.Underline).
func (c *Color) Add(value ...Attribute) *Color {
c.params = append(c.params, value...)
return c
}
func (c *Color) prepend(value Attribute) {
c.params = append(c.params, 0)
copy(c.params[1:], c.params[0:])
c.params[0] = value
}
// Fprint formats using the default formats for its operands and writes to w.
// Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
// On Windows, users should wrap w with colorable.NewColorable() if w is of
// type *os.File.
func (c *Color) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
c.setWriter(w)
defer c.unsetWriter(w)
return fmt.Fprint(w, a...)
}
// Print formats using the default formats for its operands and writes to
// standard output. Spaces are added between operands when neither is a
// string. It returns the number of bytes written and any write error
// encountered. This is the standard fmt.Print() method wrapped with the given
// color.
func (c *Color) Print(a ...interface{}) (n int, err error) {
c.Set()
defer c.unset()
return fmt.Fprint(Output, a...)
}
// Fprintf formats according to a format specifier and writes to w.
// It returns the number of bytes written and any write error encountered.
// On Windows, users should wrap w with colorable.NewColorable() if w is of
// type *os.File.
func (c *Color) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
c.setWriter(w)
defer c.unsetWriter(w)
return fmt.Fprintf(w, format, a...)
}
// Printf formats according to a format specifier and writes to standard output.
// It returns the number of bytes written and any write error encountered.
// This is the standard fmt.Printf() method wrapped with the given color.
func (c *Color) Printf(format string, a ...interface{}) (n int, err error) {
c.Set()
defer c.unset()
return fmt.Fprintf(Output, format, a...)
}
// Fprintln formats using the default formats for its operands and writes to w.
// Spaces are always added between operands and a newline is appended.
// On Windows, users should wrap w with colorable.NewColorable() if w is of
// type *os.File.
func (c *Color) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
c.setWriter(w)
defer c.unsetWriter(w)
return fmt.Fprintln(w, a...)
}
// Println formats using the default formats for its operands and writes to
// standard output. Spaces are always added between operands and a newline is
// appended. It returns the number of bytes written and any write error
// encountered. This is the standard fmt.Print() method wrapped with the given
// color.
func (c *Color) Println(a ...interface{}) (n int, err error) {
c.Set()
defer c.unset()
return fmt.Fprintln(Output, a...)
}
// Sprint is just like Print, but returns a string instead of printing it.
func (c *Color) Sprint(a ...interface{}) string {
return c.wrap(fmt.Sprint(a...))
}
// Sprintln is just like Println, but returns a string instead of printing it.
func (c *Color) Sprintln(a ...interface{}) string {
return c.wrap(fmt.Sprintln(a...))
}
// Sprintf is just like Printf, but returns a string instead of printing it.
func (c *Color) Sprintf(format string, a ...interface{}) string {
return c.wrap(fmt.Sprintf(format, a...))
}
// FprintFunc returns a new function that prints the passed arguments as
// colorized with color.Fprint().
func (c *Color) FprintFunc() func(w io.Writer, a ...interface{}) {
return func(w io.Writer, a ...interface{}) {
c.Fprint(w, a...)
}
}
// PrintFunc returns a new function that prints the passed arguments as
// colorized with color.Print().
func (c *Color) PrintFunc() func(a ...interface{}) {
return func(a ...interface{}) {
c.Print(a...)
}
}
// FprintfFunc returns a new function that prints the passed arguments as
// colorized with color.Fprintf().
func (c *Color) FprintfFunc() func(w io.Writer, format string, a ...interface{}) {
return func(w io.Writer, format string, a ...interface{}) {
c.Fprintf(w, format, a...)
}
}
// PrintfFunc returns a new function that prints the passed arguments as
// colorized with color.Printf().
func (c *Color) PrintfFunc() func(format string, a ...interface{}) {
return func(format string, a ...interface{}) {
c.Printf(format, a...)
}
}
// FprintlnFunc returns a new function that prints the passed arguments as
// colorized with color.Fprintln().
func (c *Color) FprintlnFunc() func(w io.Writer, a ...interface{}) {
return func(w io.Writer, a ...interface{}) {
c.Fprintln(w, a...)
}
}
// PrintlnFunc returns a new function that prints the passed arguments as
// colorized with color.Println().
func (c *Color) PrintlnFunc() func(a ...interface{}) {
return func(a ...interface{}) {
c.Println(a...)
}
}
// SprintFunc returns a new function that returns colorized strings for the
// given arguments with fmt.Sprint(). Useful to put into or mix into other
// string. Windows users should use this in conjunction with color.Output, example:
//
// put := New(FgYellow).SprintFunc()
// fmt.Fprintf(color.Output, "This is a %s", put("warning"))
func (c *Color) SprintFunc() func(a ...interface{}) string {
return func(a ...interface{}) string {
return c.wrap(fmt.Sprint(a...))
}
}
// SprintfFunc returns a new function that returns colorized strings for the
// given arguments with fmt.Sprintf(). Useful to put into or mix into other
// string. Windows users should use this in conjunction with color.Output.
func (c *Color) SprintfFunc() func(format string, a ...interface{}) string {
return func(format string, a ...interface{}) string {
return c.wrap(fmt.Sprintf(format, a...))
}
}
// SprintlnFunc returns a new function that returns colorized strings for the
// given arguments with fmt.Sprintln(). Useful to put into or mix into other
// string. Windows users should use this in conjunction with color.Output.
func (c *Color) SprintlnFunc() func(a ...interface{}) string {
return func(a ...interface{}) string {
return c.wrap(fmt.Sprintln(a...))
}
}
// sequence returns a formatted SGR sequence to be plugged into a "\x1b[...m"
// an example output might be: "1;36" -> bold cyan
func (c *Color) sequence() string {
format := make([]string, len(c.params))
for i, v := range c.params {
format[i] = strconv.Itoa(int(v))
}
return strings.Join(format, ";")
}
// wrap wraps the s string with the colors attributes. The string is ready to
// be printed.
func (c *Color) wrap(s string) string {
if c.isNoColorSet() {
return s
}
return c.format() + s + c.unformat()
}
func (c *Color) format() string {
return fmt.Sprintf("%s[%sm", escape, c.sequence())
}
func (c *Color) unformat() string {
return fmt.Sprintf("%s[%dm", escape, Reset)
}
// DisableColor disables the color output. Useful to not change any existing
// code and still being able to output. Can be used for flags like
// "--no-color". To enable back use EnableColor() method.
func (c *Color) DisableColor() {
c.noColor = boolPtr(true)
}
// EnableColor enables the color output. Use it in conjunction with
// DisableColor(). Otherwise this method has no side effects.
func (c *Color) EnableColor() {
c.noColor = boolPtr(false)
}
func (c *Color) isNoColorSet() bool {
// check first if we have user set action
if c.noColor != nil {
return *c.noColor
}
// if not return the global option, which is disabled by default
return NoColor
}
// Equals returns a boolean value indicating whether two colors are equal.
func (c *Color) Equals(c2 *Color) bool {
if len(c.params) != len(c2.params) {
return false
}
for _, attr := range c.params {
if !c2.attrExists(attr) {
return false
}
}
return true
}
func (c *Color) attrExists(a Attribute) bool {
for _, attr := range c.params {
if attr == a {
return true
}
}
return false
}
func boolPtr(v bool) *bool {
return &v
}
func getCachedColor(p Attribute) *Color {
colorsCacheMu.Lock()
defer colorsCacheMu.Unlock()
c, ok := colorsCache[p]
if !ok {
c = New(p)
colorsCache[p] = c
}
return c
}
func colorPrint(format string, p Attribute, a ...interface{}) {
c := getCachedColor(p)
if !strings.HasSuffix(format, "\n") {
format += "\n"
}
if len(a) == 0 {
c.Print(format)
} else {
c.Printf(format, a...)
}
}
func colorString(format string, p Attribute, a ...interface{}) string {
c := getCachedColor(p)
if len(a) == 0 {
return c.SprintFunc()(format)
}
return c.SprintfFunc()(format, a...)
}
// Black is a convenient helper function to print with black foreground. A
// newline is appended to format by default.
func Black(format string, a ...interface{}) { colorPrint(format, FgBlack, a...) }
// Red is a convenient helper function to print with red foreground. A
// newline is appended to format by default.
func Red(format string, a ...interface{}) { colorPrint(format, FgRed, a...) }
// Green is a convenient helper function to print with green foreground. A
// newline is appended to format by default.
func Green(format string, a ...interface{}) { colorPrint(format, FgGreen, a...) }
// Yellow is a convenient helper function to print with yellow foreground.
// A newline is appended to format by default.
func Yellow(format string, a ...interface{}) { colorPrint(format, FgYellow, a...) }
// Blue is a convenient helper function to print with blue foreground. A
// newline is appended to format by default.
func Blue(format string, a ...interface{}) { colorPrint(format, FgBlue, a...) }
// Magenta is a convenient helper function to print with magenta foreground.
// A newline is appended to format by default.
func Magenta(format string, a ...interface{}) { colorPrint(format, FgMagenta, a...) }
// Cyan is a convenient helper function to print with cyan foreground. A
// newline is appended to format by default.
func Cyan(format string, a ...interface{}) { colorPrint(format, FgCyan, a...) }
// White is a convenient helper function to print with white foreground. A
// newline is appended to format by default.
func White(format string, a ...interface{}) { colorPrint(format, FgWhite, a...) }
// BlackString is a convenient helper function to return a string with black
// foreground.
func BlackString(format string, a ...interface{}) string { return colorString(format, FgBlack, a...) }
// RedString is a convenient helper function to return a string with red
// foreground.
func RedString(format string, a ...interface{}) string { return colorString(format, FgRed, a...) }
// GreenString is a convenient helper function to return a string with green
// foreground.
func GreenString(format string, a ...interface{}) string { return colorString(format, FgGreen, a...) }
// YellowString is a convenient helper function to return a string with yellow
// foreground.
func YellowString(format string, a ...interface{}) string { return colorString(format, FgYellow, a...) }
// BlueString is a convenient helper function to return a string with blue
// foreground.
func BlueString(format string, a ...interface{}) string { return colorString(format, FgBlue, a...) }
// MagentaString is a convenient helper function to return a string with magenta
// foreground.
func MagentaString(format string, a ...interface{}) string {
return colorString(format, FgMagenta, a...)
}
// CyanString is a convenient helper function to return a string with cyan
// foreground.
func CyanString(format string, a ...interface{}) string { return colorString(format, FgCyan, a...) }
// WhiteString is a convenient helper function to return a string with white
// foreground.
func WhiteString(format string, a ...interface{}) string { return colorString(format, FgWhite, a...) }
// HiBlack is a convenient helper function to print with hi-intensity black foreground. A
// newline is appended to format by default.
func HiBlack(format string, a ...interface{}) { colorPrint(format, FgHiBlack, a...) }
// HiRed is a convenient helper function to print with hi-intensity red foreground. A
// newline is appended to format by default.
func HiRed(format string, a ...interface{}) { colorPrint(format, FgHiRed, a...) }
// HiGreen is a convenient helper function to print with hi-intensity green foreground. A
// newline is appended to format by default.
func HiGreen(format string, a ...interface{}) { colorPrint(format, FgHiGreen, a...) }
// HiYellow is a convenient helper function to print with hi-intensity yellow foreground.
// A newline is appended to format by default.
func HiYellow(format string, a ...interface{}) { colorPrint(format, FgHiYellow, a...) }
// HiBlue is a convenient helper function to print with hi-intensity blue foreground. A
// newline is appended to format by default.
func HiBlue(format string, a ...interface{}) { colorPrint(format, FgHiBlue, a...) }
// HiMagenta is a convenient helper function to print with hi-intensity magenta foreground.
// A newline is appended to format by default.
func HiMagenta(format string, a ...interface{}) { colorPrint(format, FgHiMagenta, a...) }
// HiCyan is a convenient helper function to print with hi-intensity cyan foreground. A
// newline is appended to format by default.
func HiCyan(format string, a ...interface{}) { colorPrint(format, FgHiCyan, a...) }
// HiWhite is a convenient helper function to print with hi-intensity white foreground. A
// newline is appended to format by default.
func HiWhite(format string, a ...interface{}) { colorPrint(format, FgHiWhite, a...) }
// HiBlackString is a convenient helper function to return a string with hi-intensity black
// foreground.
func HiBlackString(format string, a ...interface{}) string {
return colorString(format, FgHiBlack, a...)
}
// HiRedString is a convenient helper function to return a string with hi-intensity red
// foreground.
func HiRedString(format string, a ...interface{}) string { return colorString(format, FgHiRed, a...) }
// HiGreenString is a convenient helper function to return a string with hi-intensity green
// foreground.
func HiGreenString(format string, a ...interface{}) string {
return colorString(format, FgHiGreen, a...)
}
// HiYellowString is a convenient helper function to return a string with hi-intensity yellow
// foreground.
func HiYellowString(format string, a ...interface{}) string {
return colorString(format, FgHiYellow, a...)
}
// HiBlueString is a convenient helper function to return a string with hi-intensity blue
// foreground.
func HiBlueString(format string, a ...interface{}) string { return colorString(format, FgHiBlue, a...) }
// HiMagentaString is a convenient helper function to return a string with hi-intensity magenta
// foreground.
func HiMagentaString(format string, a ...interface{}) string {
return colorString(format, FgHiMagenta, a...)
}
// HiCyanString is a convenient helper function to return a string with hi-intensity cyan
// foreground.
func HiCyanString(format string, a ...interface{}) string { return colorString(format, FgHiCyan, a...) }
// HiWhiteString is a convenient helper function to return a string with hi-intensity white
// foreground.
func HiWhiteString(format string, a ...interface{}) string {
return colorString(format, FgHiWhite, a...)
}

135
vendor/github.com/fatih/color/doc.go generated vendored

@ -0,0 +1,135 @@ @@ -0,0 +1,135 @@
/*
Package color is an ANSI color package to output colorized or SGR defined
output to the standard output. The API can be used in several way, pick one
that suits you.
Use simple and default helper functions with predefined foreground colors:
color.Cyan("Prints text in cyan.")
// a newline will be appended automatically
color.Blue("Prints %s in blue.", "text")
// More default foreground colors..
color.Red("We have red")
color.Yellow("Yellow color too!")
color.Magenta("And many others ..")
// Hi-intensity colors
color.HiGreen("Bright green color.")
color.HiBlack("Bright black means gray..")
color.HiWhite("Shiny white color!")
However there are times where custom color mixes are required. Below are some
examples to create custom color objects and use the print functions of each
separate color object.
// Create a new color object
c := color.New(color.FgCyan).Add(color.Underline)
c.Println("Prints cyan text with an underline.")
// Or just add them to New()
d := color.New(color.FgCyan, color.Bold)
d.Printf("This prints bold cyan %s\n", "too!.")
// Mix up foreground and background colors, create new mixes!
red := color.New(color.FgRed)
boldRed := red.Add(color.Bold)
boldRed.Println("This will print text in bold red.")
whiteBackground := red.Add(color.BgWhite)
whiteBackground.Println("Red text with White background.")
// Use your own io.Writer output
color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
blue := color.New(color.FgBlue)
blue.Fprint(myWriter, "This will print text in blue.")
You can create PrintXxx functions to simplify even more:
// Create a custom print function for convenient
red := color.New(color.FgRed).PrintfFunc()
red("warning")
red("error: %s", err)
// Mix up multiple attributes
notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
notice("don't forget this...")
You can also FprintXxx functions to pass your own io.Writer:
blue := color.New(FgBlue).FprintfFunc()
blue(myWriter, "important notice: %s", stars)
// Mix up with multiple attributes
success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
success(myWriter, don't forget this...")
Or create SprintXxx functions to mix strings with other non-colorized strings:
yellow := New(FgYellow).SprintFunc()
red := New(FgRed).SprintFunc()
fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
info := New(FgWhite, BgGreen).SprintFunc()
fmt.Printf("this %s rocks!\n", info("package"))
Windows support is enabled by default. All Print functions work as intended.
However only for color.SprintXXX functions, user should use fmt.FprintXXX and
set the output to color.Output:
fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
info := New(FgWhite, BgGreen).SprintFunc()
fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
Using with existing code is possible. Just use the Set() method to set the
standard output to the given parameters. That way a rewrite of an existing
code is not required.
// Use handy standard colors.
color.Set(color.FgYellow)
fmt.Println("Existing text will be now in Yellow")
fmt.Printf("This one %s\n", "too")
color.Unset() // don't forget to unset
// You can mix up parameters
color.Set(color.FgMagenta, color.Bold)
defer color.Unset() // use it in your function
fmt.Println("All text will be now bold magenta.")
There might be a case where you want to disable color output (for example to
pipe the standard output of your app to somewhere else). `Color` has support to
disable colors both globally and for single color definition. For example
suppose you have a CLI app and a `--no-color` bool flag. You can easily disable
the color output with:
var flagNoColor = flag.Bool("no-color", false, "Disable color output")
if *flagNoColor {
color.NoColor = true // disables colorized output
}
You can also disable the color by setting the NO_COLOR environment variable to any value.
It also has support for single color definitions (local). You can
disable/enable color output on the fly:
c := color.New(color.FgCyan)
c.Println("Prints cyan text")
c.DisableColor()
c.Println("This is printed without any color")
c.EnableColor()
c.Println("This prints again cyan...")
*/
package color

19
vendor/github.com/go-co-op/gocron/.gitignore generated vendored

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
local_testing
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
vendor/
# IDE project files
.idea

49
vendor/github.com/go-co-op/gocron/.golangci.yaml generated vendored

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
run:
timeout: 2m
issues-exit-code: 1
tests: true
issues:
max-same-issues: 100
exclude-rules:
- path: _test\.go
linters:
- bodyclose
- errcheck
- gosec
linters:
enable:
- bodyclose
- deadcode
- errcheck
- gofmt
- revive
- gosec
- gosimple
- govet
- ineffassign
- misspell
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
# print lines of code with issue, default is true
print-issued-lines: true
# print linter name in the end of issue text, default is true
print-linter-name: true
# make issues output unique by line, default is true
uniq-by-line: true
# add a prefix to the output file references; default is no prefix
path-prefix: ""
# sorts results by: filepath, line and column
sort-results: true
linters-settings:
golint:
min-confidence: 0.8

73
vendor/github.com/go-co-op/gocron/CODE_OF_CONDUCT.md generated vendored

@ -0,0 +1,73 @@ @@ -0,0 +1,73 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone. And we mean everyone!
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and kind language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team initially on Slack to coordinate private communication. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

40
vendor/github.com/go-co-op/gocron/CONTRIBUTING.md generated vendored

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
# Contributing to gocron
Thank you for coming to contribute to gocron! We welcome new ideas, PRs and general feedback.
## Reporting Bugs
If you find a bug then please let the project know by opening an issue after doing the following:
- Do a quick search of the existing issues to make sure the bug isn't already reported
- Try and make a minimal list of steps that can reliably reproduce the bug you are experiencing
- Collect as much information as you can to help identify what the issue is (project version, configuration files, etc)
## Suggesting Enhancements
If you have a use case that you don't see a way to support yet, we would welcome the feedback in an issue. Before opening the issue, please consider:
- Is this a common use case?
- Is it simple to understand?
You can help us out by doing the following before raising a new issue:
- Check that the feature hasn't been requested already by searching existing issues
- Try and reduce your enhancement into a single, concise and deliverable request, rather than a general idea
- Explain your own use cases as the basis of the request
## Adding Features
Pull requests are always welcome. However, before going through the trouble of implementing a change it's worth creating a bug or feature request issue.
This allows us to discuss the changes and make sure they are a good fit for the project.
Please always make sure a pull request has been:
- Unit tested with `make test`
- Linted with `make lint`
- Vetted with `make vet`
- Formatted with `make fmt` or validated with `make check-fmt`
## Writing Tests
Tests should follow the [table driven test pattern](https://dave.cheney.net/2013/06/09/writing-table-driven-tests-in-go). See other tests in the code base for additional examples.

21
vendor/github.com/go-co-op/gocron/LICENSE generated vendored

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
MIT License
Copyright (c) 2014, 辣椒面
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

33
vendor/github.com/go-co-op/gocron/Makefile generated vendored

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
.PHONY: fmt check-fmt lint vet test
GO_PKGS := $(shell go list -f {{.Dir}} ./...)
fmt:
@go list -f {{.Dir}} ./... | xargs -I{} gofmt -w -s {}
check-fmt:
@echo "Checking formatting..."
@FMT="0"; \
for pkg in $(GO_PKGS); do \
OUTPUT=`gofmt -l $$pkg/*.go`; \
if [ -n "$$OUTPUT" ]; then \
echo "$$OUTPUT"; \
FMT="1"; \
fi; \
done ; \
if [ "$$FMT" -eq "1" ]; then \
echo "Problem with formatting in files above."; \
exit 1; \
else \
echo "Success - way to run gofmt!"; \
fi
lint:
# Add -set_exit_status=true when/if we want to enforce the linter rules
@golint -min_confidence 0.8 -set_exit_status $(GO_PKGS)
vet:
@go vet $(GO_FLAGS) $(GO_PKGS)
test:
@go test -race -v $(GO_FLAGS) -count=1 $(GO_PKGS)

132
vendor/github.com/go-co-op/gocron/README.md generated vendored

@ -0,0 +1,132 @@ @@ -0,0 +1,132 @@
# gocron: A Golang Job Scheduling Package.
[![CI State](https://github.com/go-co-op/gocron/workflows/Go%20Test/badge.svg)](https://github.com/go-co-op/gocron/actions?query=workflow%3A"lint") ![Go Report Card](https://goreportcard.com/badge/github.com/go-co-op/gocron) [![Go Doc](https://godoc.org/github.com/go-co-op/gocron?status.svg)](https://pkg.go.dev/github.com/go-co-op/gocron)
gocron is a job scheduling package which lets you run Go functions at pre-determined intervals using a simple, human-friendly syntax.
gocron is a Golang scheduler implementation similar to the Ruby module [clockwork](https://github.com/tomykaira/clockwork) and the Python job scheduling package [schedule](https://github.com/dbader/schedule).
See also these two great articles that were used for design input:
- [Rethinking Cron](http://adam.herokuapp.com/past/2010/4/13/rethinking_cron/)
- [Replace Cron with Clockwork](http://adam.herokuapp.com/past/2010/6/30/replace_cron_with_clockwork/)
If you want to chat, you can find us at Slack! [<img src="https://img.shields.io/badge/gophers-gocron-brightgreen?logo=slack">](https://gophers.slack.com/archives/CQ7T0T1FW)
## Concepts
- **Scheduler**: The scheduler tracks all the jobs assigned to it and makes sure they are passed to the executor when ready to be run. The scheduler is able to manage overall aspects of job behavior like limiting how many jobs are running at one time.
- **Job**: The job is simply aware of the task (go function) it's provided and is therefore only able to perform actions related to that task like preventing itself from overruning a previous task that is taking a long time.
- **Executor**: The executor, as it's name suggests, is simply responsible for calling the task (go function) that the job hands to it when sent by the scheduler.
## Examples
```golang
s := gocron.NewScheduler(time.UTC)
s.Every(5).Seconds().Do(func(){ ... })
// strings parse to duration
s.Every("5m").Do(func(){ ... })
s.Every(5).Days().Do(func(){ ... })
s.Every(1).Month(1, 2, 3).Do(func(){ ... })
// set time
s.Every(1).Day().At("10:30").Do(func(){ ... })
// set multiple times
s.Every(1).Day().At("10:30;08:00").Do(func(){ ... })
s.Every(1).Day().At("10:30").At("08:00").Do(func(){ ... })
// Schedule each last day of the month
s.Every(1).MonthLastDay().Do(func(){ ... })
// Or each last day of every other month
s.Every(2).MonthLastDay().Do(func(){ ... })
// cron expressions supported
s.Cron("*/1 * * * *").Do(task) // every minute
// you can start running the scheduler in two different ways:
// starts the scheduler asynchronously
s.StartAsync()
// starts the scheduler and blocks current execution path
s.StartBlocking()
```
For more examples, take a look in our [go docs](https://pkg.go.dev/github.com/go-co-op/gocron#pkg-examples)
## Options
| Interval | Supported schedule options |
| ------------ | ------------------------------------------------------------------- |
| sub-second | `StartAt()` |
| milliseconds | `StartAt()` |
| seconds | `StartAt()` |
| minutes | `StartAt()` |
| hours | `StartAt()` |
| days | `StartAt()`, `At()` |
| weeks | `StartAt()`, `At()`, `Weekday()` (and all week day named functions) |
| months | `StartAt()`, `At()` |
There are several options available to restrict how jobs run:
| Mode | Function | Behavior |
| --------------- | ------------------------ | ------------------------------------------------------------------------------- |
| Default | | jobs are rescheduled at every interval |
| Job singleton | `SingletonMode()` | a long running job will not be rescheduled until the current run is completed |
| Scheduler limit | `SetMaxConcurrentJobs()` | set a collective maximum number of concurrent jobs running across the scheduler |
## Tags
Jobs may have arbitrary tags added which can be useful when tracking many jobs.
The scheduler supports both enforcing tags to be unique and when not unique,
running all jobs with a given tag.
```golang
s := gocron.NewScheduler(time.UTC)
s.TagsUnique()
_, _ = s.Every(1).Week().Tag("foo").Do(task)
_, err := s.Every(1).Week().Tag("foo").Do(task)
// error!!!
s := gocron.NewScheduler(time.UTC)
s.Every(2).Day().Tag("tag").At("10:00").Do(task)
s.Every(1).Minute().Tag("tag").Do(task)
s.RunByTag("tag")
// both jobs will run
```
## FAQ
- Q: I'm running multiple pods on a distributed environment. How can I make a job not run once per pod causing duplication?
- A: We recommend using your own lock solution within the jobs themselves (you could use [Redis](https://redis.io/topics/distlock), for example)
- Q: I've removed my job from the scheduler, but how can I stop a long-running job that has already been triggered?
- A: We recommend using a means of canceling your job, e.g. a `context.WithCancel()`.
---
Looking to contribute? Try to follow these guidelines:
- Use issues for everything
- For a small change, just send a PR!
- For bigger changes, please open an issue for discussion before sending a PR.
- PRs should have: tests, documentation and examples (if it makes sense)
- You can also contribute by:
- Reporting issues
- Suggesting new features or enhancements
- Improving/fixing documentation
---
## Design
![design-diagram](https://user-images.githubusercontent.com/19351306/110375142-2ba88680-8017-11eb-80c3-554cc746b165.png)
[Jetbrains](https://www.jetbrains.com/?from=gocron) supports this project with GoLand licenses. We appreciate their support for free and open source software!

15
vendor/github.com/go-co-op/gocron/SECURITY.md generated vendored

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
# Security Policy
## Supported Versions
The current plan is to maintain version 1 as long as possible incorporating any necessary security patches.
| Version | Supported |
| ------- | ------------------ |
| 1.x.x | :white_check_mark: |
## Reporting a Vulnerability
Vulnerabilities can be reported by [opening an issue](https://github.com/go-co-op/gocron/issues/new/choose) or reaching out on Slack: [<img src="https://img.shields.io/badge/gophers-gocron-brightgreen?logo=slack">](https://gophers.slack.com/archives/CQ7T0T1FW)
We will do our best to addrerss any vulnerabilites in an expeditious manner.

111
vendor/github.com/go-co-op/gocron/executor.go generated vendored

@ -0,0 +1,111 @@ @@ -0,0 +1,111 @@
package gocron
import (
"context"
"sync"
"golang.org/x/sync/semaphore"
)
const (
// RescheduleMode - the default is that if a limit on maximum
// concurrent jobs is set and the limit is reached, a job will
// skip it's run and try again on the next occurrence in the schedule
RescheduleMode limitMode = iota
// WaitMode - if a limit on maximum concurrent jobs is set
// and the limit is reached, a job will wait to try and run
// until a spot in the limit is freed up.
//
// Note: this mode can produce unpredictable results as
// job execution order isn't guaranteed. For example, a job that
// executes frequently may pile up in the wait queue and be executed
// many times back to back when the queue opens.
WaitMode
)
type executor struct {
jobFunctions chan jobFunction
stopCh chan struct{}
limitMode limitMode
maxRunningJobs *semaphore.Weighted
}
func newExecutor() executor {
return executor{
jobFunctions: make(chan jobFunction, 1),
stopCh: make(chan struct{}, 1),
}
}
func (e *executor) start() {
stopCtx, cancel := context.WithCancel(context.Background())
runningJobsWg := sync.WaitGroup{}
for {
select {
case f := <-e.jobFunctions:
runningJobsWg.Add(1)
go func() {
defer runningJobsWg.Done()
if e.maxRunningJobs != nil {
if !e.maxRunningJobs.TryAcquire(1) {
switch e.limitMode {
case RescheduleMode:
return
case WaitMode:
for {
select {
case <-stopCtx.Done():
return
case <-f.ctx.Done():
return
default:
}
if e.maxRunningJobs.TryAcquire(1) {
break
}
}
}
}
defer e.maxRunningJobs.Release(1)
}
switch f.runConfig.mode {
case defaultMode:
f.incrementRunState()
callJobFuncWithParams(f.function, f.parameters)
f.decrementRunState()
case singletonMode:
_, _, _ = f.limiter.Do("main", func() (interface{}, error) {
select {
case <-stopCtx.Done():
return nil, nil
case <-f.ctx.Done():
return nil, nil
default:
}
f.incrementRunState()
callJobFuncWithParams(f.function, f.parameters)
f.decrementRunState()
return nil, nil
})
}
}()
case <-e.stopCh:
cancel()
runningJobsWg.Wait()
e.stopCh <- struct{}{}
return
}
}
}
func (e *executor) stop() {
e.stopCh <- struct{}{}
<-e.stopCh
}

101
vendor/github.com/go-co-op/gocron/gocron.go generated vendored

@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
// Package gocron : A Golang Job Scheduling Package.
//
// An in-process scheduler for periodic jobs that uses the builder pattern
// for configuration. gocron lets you run Golang functions periodically
// at pre-determined intervals using a simple, human-friendly syntax.
//
package gocron
import (
"errors"
"fmt"
"reflect"
"regexp"
"runtime"
"time"
)
// Error declarations for gocron related errors
var (
ErrNotAFunction = errors.New("only functions can be scheduled into the job queue")
ErrNotScheduledWeekday = errors.New("job not scheduled weekly on a weekday")
ErrJobNotFoundWithTag = errors.New("no jobs found with given tag")
ErrUnsupportedTimeFormat = errors.New("the given time format is not supported")
ErrInvalidInterval = errors.New(".Every() interval must be greater than 0")
ErrInvalidIntervalType = errors.New(".Every() interval must be int, time.Duration, or string")
ErrInvalidIntervalUnitsSelection = errors.New(".Every(time.Duration) and .Cron() cannot be used with units (e.g. .Seconds())")
ErrAtTimeNotSupported = errors.New("the At() method is not supported for this time unit")
ErrWeekdayNotSupported = errors.New("weekday is not supported for time unit")
ErrInvalidDayOfMonthEntry = errors.New("only days 1 through 28 are allowed for monthly schedules")
ErrTagsUnique = func(tag string) error { return fmt.Errorf("a non-unique tag was set on the job: %s", tag) }
ErrWrongParams = errors.New("wrong list of params")
ErrUpdateCalledWithoutJob = errors.New("a call to Scheduler.Update() requires a call to Scheduler.Job() first")
ErrCronParseFailure = errors.New("cron expression failed to be parsed")
ErrInvalidDaysOfMonthDuplicateValue = errors.New("duplicate days of month is not allowed in Month() and Months() methods")
)
func wrapOrError(toWrap error, err error) error {
var returnErr error
if toWrap != nil && !errors.Is(err, toWrap) {
returnErr = fmt.Errorf("%s: %w", err, toWrap)
} else {
returnErr = err
}
return returnErr
}
// regex patterns for supported time formats
var (
timeWithSeconds = regexp.MustCompile(`(?m)^\d{1,2}:\d\d:\d\d$`)
timeWithoutSeconds = regexp.MustCompile(`(?m)^\d{1,2}:\d\d$`)
)
type schedulingUnit int
const (
// default unit is seconds
milliseconds schedulingUnit = iota
seconds
minutes
hours
days
weeks
months
duration
crontab
)
func callJobFuncWithParams(jobFunc interface{}, params []interface{}) {
f := reflect.ValueOf(jobFunc)
if len(params) != f.Type().NumIn() {
return
}
in := make([]reflect.Value, len(params))
for k, param := range params {
in[k] = reflect.ValueOf(param)
}
f.Call(in)
}
func getFunctionName(fn interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
}
func parseTime(t string) (hour, min, sec int, err error) {
var timeLayout string
switch {
case timeWithSeconds.Match([]byte(t)):
timeLayout = "15:04:05"
case timeWithoutSeconds.Match([]byte(t)):
timeLayout = "15:04"
default:
return 0, 0, 0, ErrUnsupportedTimeFormat
}
parsedTime, err := time.Parse(timeLayout, t)
if err != nil {
return 0, 0, 0, ErrUnsupportedTimeFormat
}
return parsedTime.Hour(), parsedTime.Minute(), parsedTime.Second(), nil
}

381
vendor/github.com/go-co-op/gocron/job.go generated vendored

@ -0,0 +1,381 @@ @@ -0,0 +1,381 @@
package gocron
import (
"context"
"fmt"
"sort"
"sync"
"sync/atomic"
"time"
"github.com/robfig/cron/v3"
"golang.org/x/sync/singleflight"
)
// Job struct stores the information necessary to run a Job
type Job struct {
mu sync.RWMutex
jobFunction
interval int // pause interval * unit between runs
duration time.Duration // time duration between runs
unit schedulingUnit // time units, e.g. 'minutes', 'hours'...
startsImmediately bool // if the Job should run upon scheduler start
atTimes []time.Duration // optional time(s) at which this Job runs when interval is day
startAtTime time.Time // optional time at which the Job starts
error error // error related to Job
lastRun time.Time // datetime of last run
nextRun time.Time // datetime of next run
scheduledWeekdays []time.Weekday // Specific days of the week to start on
daysOfTheMonth []int // Specific days of the month to run the job
tags []string // allow the user to tag Jobs with certain labels
runCount int // number of times the job ran
timer *time.Timer // handles running tasks at specific time
cronSchedule cron.Schedule // stores the schedule when a task uses cron
}
type jobFunction struct {
function interface{} // task's function
parameters []interface{} // task's function parameters
name string //nolint the function name to run
runConfig runConfig // configuration for how many times to run the job
limiter *singleflight.Group // limits inflight runs of job to one
ctx context.Context // for cancellation
cancel context.CancelFunc // for cancellation
runState *int64 // will be non-zero when jobs are running
}
func (jf *jobFunction) incrementRunState() {
if jf.runState != nil {
atomic.AddInt64(jf.runState, 1)
}
}
func (jf *jobFunction) decrementRunState() {
if jf.runState != nil {
atomic.AddInt64(jf.runState, -1)
}
}
type runConfig struct {
finiteRuns bool
maxRuns int
mode mode
}
// mode is the Job's running mode
type mode int8
const (
// defaultMode disable any mode
defaultMode mode = iota
// singletonMode switch to single job mode
singletonMode
)
// newJob creates a new Job with the provided interval
func newJob(interval int, startImmediately bool, singletonMode bool) *Job {
ctx, cancel := context.WithCancel(context.Background())
var zero int64
job := &Job{
interval: interval,
unit: seconds,
lastRun: time.Time{},
nextRun: time.Time{},
jobFunction: jobFunction{
ctx: ctx,
cancel: cancel,
runState: &zero,
},
tags: []string{},
startsImmediately: startImmediately,
}
if singletonMode {
job.SingletonMode()
}
return job
}
func (j *Job) neverRan() bool {
return j.lastRun.IsZero()
}
func (j *Job) getStartsImmediately() bool {
return j.startsImmediately
}
func (j *Job) setStartsImmediately(b bool) {
j.startsImmediately = b
}
func (j *Job) setTimer(t *time.Timer) {
j.mu.Lock()
defer j.mu.Unlock()
j.timer = t
}
func (j *Job) getFirstAtTime() time.Duration {
var t time.Duration
if len(j.atTimes) > 0 {
t = j.atTimes[0]
}
return t
}
func (j *Job) getAtTime(lastRun time.Time) time.Duration {
var r time.Duration
if len(j.atTimes) == 0 {
return r
}
if len(j.atTimes) == 1 {
return j.atTimes[0]
}
if lastRun.IsZero() {
r = j.atTimes[0]
} else {
for _, d := range j.atTimes {
nt := time.Date(lastRun.Year(), lastRun.Month(), lastRun.Day(), 0, 0, 0, 0, lastRun.Location()).Add(d)
if nt.After(lastRun) {
r = d
break
}
}
}
return r
}
func (j *Job) addAtTime(t time.Duration) {
if len(j.atTimes) == 0 {
j.atTimes = append(j.atTimes, t)
return
}
exist := false
index := sort.Search(len(j.atTimes), func(i int) bool {
atTime := j.atTimes[i]
b := atTime >= t
if b {
exist = atTime == t
}
return b
})
// ignore if present
if exist {
return
}
j.atTimes = append(j.atTimes, time.Duration(0))
copy(j.atTimes[index+1:], j.atTimes[index:])
j.atTimes[index] = t
}
func (j *Job) getStartAtTime() time.Time {
return j.startAtTime
}
func (j *Job) setStartAtTime(t time.Time) {
j.startAtTime = t
}
func (j *Job) getUnit() schedulingUnit {
j.mu.RLock()
defer j.mu.RUnlock()
return j.unit
}
func (j *Job) setUnit(t schedulingUnit) {
j.mu.Lock()
defer j.mu.Unlock()
j.unit = t
}
func (j *Job) getDuration() time.Duration {
j.mu.RLock()
defer j.mu.RUnlock()
return j.duration
}
func (j *Job) setDuration(t time.Duration) {
j.mu.Lock()
defer j.mu.Unlock()
j.duration = t
}
// hasTags returns true if all tags are matched on this Job
func (j *Job) hasTags(tags ...string) bool {
// Build map of all Job tags for easy comparison
jobTags := map[string]int{}
for _, tag := range j.tags {
jobTags[tag] = 0
}
// Loop through required tags and if one doesn't exist, return false
for _, tag := range tags {
_, ok := jobTags[tag]
if !ok {
return false
}
}
return true
}
// Error returns an error if one occurred while creating the Job.
// If multiple errors occurred, they will be wrapped and can be
// checked using the standard unwrap options.
func (j *Job) Error() error {
return j.error
}
// Tag allows you to add arbitrary labels to a Job that do not
// impact the functionality of the Job
func (j *Job) Tag(tags ...string) {
j.tags = append(j.tags, tags...)
}
// Untag removes a tag from a Job
func (j *Job) Untag(t string) {
var newTags []string
for _, tag := range j.tags {
if t != tag {
newTags = append(newTags, tag)
}
}
j.tags = newTags
}
// Tags returns the tags attached to the Job
func (j *Job) Tags() []string {
return j.tags
}
// ScheduledTime returns the time of the Job's next scheduled run
func (j *Job) ScheduledTime() time.Time {
j.mu.RLock()
defer j.mu.RUnlock()
return j.nextRun
}
// ScheduledAtTime returns the specific time of day the Job will run at.
// If multiple times are set, the earliest time will be returned.
func (j *Job) ScheduledAtTime() string {
if len(j.atTimes) == 0 {
return "0:0"
}
return fmt.Sprintf("%d:%d", j.getFirstAtTime()/time.Hour, (j.getFirstAtTime()%time.Hour)/time.Minute)
}
// ScheduledAtTimes returns the specific times of day the Job will run at
func (j *Job) ScheduledAtTimes() []string {
r := make([]string, len(j.atTimes))
for i, t := range j.atTimes {
r[i] = fmt.Sprintf("%d:%d", t/time.Hour, (t%time.Hour)/time.Minute)
}
return r
}
// Weekday returns which day of the week the Job will run on and
// will return an error if the Job is not scheduled weekly
func (j *Job) Weekday() (time.Weekday, error) {
if len(j.scheduledWeekdays) == 0 {
return time.Sunday, ErrNotScheduledWeekday
}
return j.scheduledWeekdays[0], nil
}
// Weekdays returns a slice of time.Weekday that the Job will run in a week and
// will return an error if the Job is not scheduled weekly
func (j *Job) Weekdays() []time.Weekday {
// appending on j.scheduledWeekdays may cause a side effect
if len(j.scheduledWeekdays) == 0 {
return []time.Weekday{time.Sunday}
}
return j.scheduledWeekdays
}
// LimitRunsTo limits the number of executions of this job to n.
// Upon reaching the limit, the job is removed from the scheduler.
//
// Note: If a job is added to a running scheduler and this method is then used
// you may see the job run more than the set limit as job is scheduled immediately
// by default upon being added to the scheduler. It is recommended to use the
// LimitRunsTo() func on the scheduler chain when scheduling the job.
// For example: scheduler.LimitRunsTo(1).Do()
func (j *Job) LimitRunsTo(n int) {
j.mu.Lock()
defer j.mu.Unlock()
j.runConfig.finiteRuns = true
j.runConfig.maxRuns = n
}
// SingletonMode prevents a new job from starting if the prior job has not yet
// completed it's run
// Note: If a job is added to a running scheduler and this method is then used
// you may see the job run overrun itself as job is scheduled immediately
// by default upon being added to the scheduler. It is recommended to use the
// SingletonMode() func on the scheduler chain when scheduling the job.
func (j *Job) SingletonMode() {
j.mu.Lock()
defer j.mu.Unlock()
j.runConfig.mode = singletonMode
j.jobFunction.limiter = &singleflight.Group{}
}
// shouldRun evaluates if this job should run again
// based on the runConfig
func (j *Job) shouldRun() bool {
j.mu.RLock()
defer j.mu.RUnlock()
return !j.runConfig.finiteRuns || j.runCount < j.runConfig.maxRuns
}
// LastRun returns the time the job was run last
func (j *Job) LastRun() time.Time {
return j.lastRun
}
func (j *Job) setLastRun(t time.Time) {
j.lastRun = t
}
// NextRun returns the time the job will run next
func (j *Job) NextRun() time.Time {
j.mu.RLock()
defer j.mu.RUnlock()
return j.nextRun
}
func (j *Job) setNextRun(t time.Time) {
j.mu.Lock()
defer j.mu.Unlock()
j.nextRun = t
}
// RunCount returns the number of time the job ran so far
func (j *Job) RunCount() int {
return j.runCount
}
func (j *Job) stop() {
j.mu.Lock()
defer j.mu.Unlock()
if j.timer != nil {
j.timer.Stop()
}
if j.cancel != nil {
j.cancel()
}
}
// IsRunning reports whether any instances of the job function are currently running
func (j *Job) IsRunning() bool {
return atomic.LoadInt64(j.runState) != 0
}

1205
vendor/github.com/go-co-op/gocron/scheduler.go generated vendored

File diff suppressed because it is too large Load Diff

25
vendor/github.com/go-co-op/gocron/timeHelper.go generated vendored

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
package gocron
import "time"
var _ timeWrapper = (*trueTime)(nil)
type timeWrapper interface {
Now(*time.Location) time.Time
Unix(int64, int64) time.Time
Sleep(time.Duration)
}
type trueTime struct{}
func (t *trueTime) Now(location *time.Location) time.Time {
return time.Now().In(location)
}
func (t *trueTime) Unix(sec int64, nsec int64) time.Time {
return time.Unix(sec, nsec)
}
func (t *trueTime) Sleep(d time.Duration) {
time.Sleep(d)
}

8
vendor/github.com/go-faster/errors/.codecov.yml generated vendored

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
ignore:
- cmd/**/*.go
coverage:
status:
patch: false
project:
default:
threshold: 0.5%

25
vendor/github.com/go-faster/errors/.editorconfig generated vendored

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
# http://editorconfig.org/
root = true
[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
[{*.go, go.mod}]
indent_style = tab
indent_size = 4
[{*.yml,*.yaml}]
indent_style = space
indent_size = 2
[*.py]
indent_style = space
indent_size = 4
# Makefiles always use tabs for indentation
[Makefile]
indent_style = tab

8
vendor/github.com/go-faster/errors/.gitignore generated vendored

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
.idea
_bin/*
./examples
*-fuzz.zip
*.out
*.dump

108
vendor/github.com/go-faster/errors/.golangci.yml generated vendored

@ -0,0 +1,108 @@ @@ -0,0 +1,108 @@
linters-settings:
govet:
check-shadowing: true
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
dupl:
threshold: 120
goconst:
min-len: 2
min-occurrences: 3
misspell:
locale: US
lll:
line-length: 140
goimports:
local-prefixes: github.com/ogen/
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- hugeParam
- rangeValCopy
- exitAfterDefer
- whyNoLint
- singleCaseSwitch
- commentedOutCode
- appendAssign
- unnecessaryBlock
- redundantSprint
linters:
disable-all: true
enable:
- deadcode
- depguard
- dogsled
- errcheck
- goconst
- gocritic
- gofmt
- goimports
- revive
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
# Do not enable:
# - wsl (too opinionated about newlines)
# - godox (todos are OK)
# - bodyclose (false positives on helper functions)
# - prealloc (not worth it in scope of this project)
# - maligned (same as prealloc)
# - funlen (gocyclo is enough)
# - gochecknoglobals (we know when it is ok to use globals)
issues:
exclude-use-default: false
exclude-rules:
# Disable linters that are annoying in tests.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- funlen
- goconst
- gocognit
- scopelint
- lll
- path: _test\.go
text: "Combine"
linters: [gocritic]
# Ignore shadowing of err.
- linters: [ govet ]
text: 'declaration of "(err|ctx|log|c)"'
# Ignore linters in main packages.
- path: main\.go
linters: [ goconst, funlen, gocognit, gocyclo ]
- path: _test\.go
text: "suspicious identical"
linters: [gocritic]
- path: _test\.go
text: "identical expressions"
linters: [staticcheck]

27
vendor/github.com/go-faster/errors/LICENSE generated vendored

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

10
vendor/github.com/go-faster/errors/Makefile generated vendored

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
test:
@./go.test.sh
.PHONY: test
coverage:
@./go.coverage.sh
.PHONY: coverage
tidy:
go mod tidy

22
vendor/github.com/go-faster/errors/PATENTS generated vendored

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
Additional IP Rights Grant (Patents)
"This implementation" means the copyrightable works distributed by
Google as part of the Go project.
Google hereby grants to You a perpetual, worldwide, non-exclusive,
no-charge, royalty-free, irrevocable (except as stated in this section)
patent license to make, have made, use, offer to sell, sell, import,
transfer and otherwise run, modify and propagate the contents of this
implementation of Go, where such license applies only to those patent
claims, both currently owned or controlled by Google and acquired in
the future, licensable by Google that are necessarily infringed by this
implementation of Go. This grant does not include claims that would be
infringed only as a consequence of further modification of this
implementation. If you or your agent or exclusive licensee institute or
order or agree to the institution of patent litigation against any
entity (including a cross-claim or counterclaim in a lawsuit) alleging
that this implementation of Go or any code incorporated within this
implementation of Go constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any patent
rights granted to you under this License for this implementation of Go
shall terminate as of the date such litigation is filed.

36
vendor/github.com/go-faster/errors/README.md generated vendored

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
# errors [![Go Reference](https://img.shields.io/badge/go-pkg-00ADD8)](https://pkg.go.dev/github.com/go-faster/errors#section-documentation) [![codecov](https://img.shields.io/codecov/c/github/go-faster/errors?label=cover)](https://codecov.io/gh/go-faster/errors)
Fork of [xerrors](https://pkg.go.dev/golang.org/x/xerrors) with explicit [Wrap](https://pkg.go.dev/github.com/go-faster/errors#Wrap) instead of `%w`.
> Clear is better than clever.
```
go get github.com/go-faster/errors
```
```go
if err != nil {
return errors.Wrap(err, "something went wrong")
}
```
## Why
* Using `Wrap` is the most explicit way to wrap errors
* Wrapping with `fmt.Errorf("foo: %w", err)` is implicit, redundant and error-prone
* Parsing `"foo: %w"` is implicit, redundant and slow
* The [pkg/errors](https://github.com/pkg/errors) and [xerrrors](https://pkg.go.dev/golang.org/x/xerrors) are not maintainted
* The [cockroachdb/errors](https://github.com/cockroachdb/errors) is too big
* The `errors` has no caller stack trace
## Don't need traces?
Call `errors.DisableTrace` or use build tag `noerrtrace`.
## Migration
```
go get github.com/go-faster/errors/cmd/gowrapper@latest
gowrapper ./...
```
## License
BSD-3-Clause, same as Go sources

193
vendor/github.com/go-faster/errors/adaptor.go generated vendored

@ -0,0 +1,193 @@ @@ -0,0 +1,193 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package errors
import (
"bytes"
"fmt"
"io"
"reflect"
"strconv"
)
// FormatError calls the FormatError method of f with an errors.Printer
// configured according to s and verb, and writes the result to s.
func FormatError(f Formatter, s fmt.State, verb rune) {
// Assuming this function is only called from the Format method, and given
// that FormatError takes precedence over Format, it cannot be called from
// any package that supports errors.Formatter. It is therefore safe to
// disregard that State may be a specific printer implementation and use one
// of our choice instead.
// limitations: does not support printing error as Go struct.
var (
sep = " " // separator before next error
p = &state{State: s}
direct = true
)
var err error = f
switch verb {
// Note that this switch must match the preference order
// for ordinary string printing (%#v before %+v, and so on).
case 'v':
if s.Flag('#') {
if stringer, ok := err.(fmt.GoStringer); ok {
p.buf.WriteString(stringer.GoString())
goto exit
}
// proceed as if it were %v
} else if s.Flag('+') {
p.printDetail = true
sep = "\n - "
}
case 's':
case 'q', 'x', 'X':
// Use an intermediate buffer in the rare cases that precision,
// truncation, or one of the alternative verbs (q, x, and X) are
// specified.
direct = false
default:
p.buf.WriteString("%!")
p.buf.WriteRune(verb)
p.buf.WriteByte('(')
switch {
case err != nil:
p.buf.WriteString(reflect.TypeOf(f).String())
default:
p.buf.WriteString("<nil>")
}
p.buf.WriteByte(')')
_, _ = io.Copy(s, &p.buf)
return
}
loop:
for {
switch v := err.(type) {
case Formatter:
err = v.FormatError((*printer)(p))
case fmt.Formatter:
v.Format(p, 'v')
break loop
default:
_, _ = p.buf.WriteString(v.Error())
break loop
}
if err == nil {
break
}
if p.needColon || !p.printDetail {
p.buf.WriteByte(':')
p.needColon = false
}
p.buf.WriteString(sep)
p.inDetail = false
p.needNewline = false
}
exit:
width, okW := s.Width()
prec, okP := s.Precision()
if !direct || (okW && width > 0) || okP {
// Construct format string from State s.
format := []byte{'%'}
if s.Flag('-') {
format = append(format, '-')
}
if s.Flag('+') {
format = append(format, '+')
}
if s.Flag(' ') {
format = append(format, ' ')
}
if okW {
format = strconv.AppendInt(format, int64(width), 10)
}
if okP {
format = append(format, '.')
format = strconv.AppendInt(format, int64(prec), 10)
}
format = append(format, string(verb)...)
_, _ = fmt.Fprintf(s, string(format), p.buf.String())
} else {
_, _ = io.Copy(s, &p.buf)
}
}
var detailSep = []byte("\n ")
// state tracks error printing state. It implements fmt.State.
type state struct {
fmt.State
buf bytes.Buffer
printDetail bool
inDetail bool
needColon bool
needNewline bool
}
func (s *state) Write(b []byte) (n int, err error) {
if s.printDetail {
if len(b) == 0 {
return 0, nil
}
if s.inDetail && s.needColon {
s.needNewline = true
if b[0] == '\n' {
b = b[1:]
}
}
k := 0
for i, c := range b {
if s.needNewline {
if s.inDetail && s.needColon {
s.buf.WriteByte(':')
s.needColon = false
}
s.buf.Write(detailSep)
s.needNewline = false
}
if c == '\n' {
s.buf.Write(b[k:i])
k = i + 1
s.needNewline = true
}
}
s.buf.Write(b[k:])
if !s.inDetail {
s.needColon = true
}
} else if !s.inDetail {
s.buf.Write(b)
}
return len(b), nil
}
// printer wraps a state to implement an xerrors.Printer.
type printer state
func (s *printer) Print(args ...interface{}) {
if !s.inDetail || s.printDetail {
_, _ = fmt.Fprint((*state)(s), args...)
}
}
func (s *printer) Printf(format string, args ...interface{}) {
if !s.inDetail || s.printDetail {
_, _ = fmt.Fprintf((*state)(s), format, args...)
}
}
func (s *printer) Detail() bool {
s.inDetail = true
return s.printDetail
}

9
vendor/github.com/go-faster/errors/doc.go generated vendored

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package errors implements functions to manipulate errors.
//
// This package expands "errors" with stack traces and explicit error
// wrapping.
package errors

37
vendor/github.com/go-faster/errors/errors.go generated vendored

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package errors
import (
"errors"
"fmt"
)
// errorString is a trivial implementation of error.
type errorString struct {
s string
frame Frame
}
// New returns an error that formats as the given text.
//
// The returned error contains a Frame set to the caller's location and
// implements Formatter to show this information when printed with details.
func New(text string) error {
if !Trace() {
return errors.New(text)
}
return &errorString{text, Caller(1)}
}
func (e *errorString) Error() string { return e.s }
func (e *errorString) Format(s fmt.State, v rune) { FormatError(e, s, v) }
func (e *errorString) FormatError(p Printer) (next error) {
p.Print(e.s)
e.frame.Format(p)
return nil
}

47
vendor/github.com/go-faster/errors/format.go generated vendored

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package errors
import (
"fmt"
"strings"
)
// A Formatter formats error messages.
type Formatter interface {
error
// FormatError prints the receiver's first error and returns the next error in
// the error chain, if any.
FormatError(p Printer) (next error)
}
// A Printer formats error messages.
//
// The most common implementation of Printer is the one provided by package fmt
// during Printf (as of Go 1.13). Localization packages such as golang.org/x/text/message
// typically provide their own implementations.
type Printer interface {
// Print appends args to the message output.
Print(args ...interface{})
// Printf writes a formatted string.
Printf(format string, args ...interface{})
// Detail reports whether error detail is requested.
// After the first call to Detail, all text written to the Printer
// is formatted as additional detail, or ignored when
// detail has not been requested.
// If Detail returns false, the caller can avoid printing the detail at all.
Detail() bool
}
// Errorf creates new error with format.
func Errorf(format string, a ...interface{}) error {
if !Trace() || strings.Contains(format, "%w") {
return fmt.Errorf(format, a...)
}
return &errorString{fmt.Sprintf(format, a...), Caller(1)}
}

56
vendor/github.com/go-faster/errors/frame.go generated vendored

@ -0,0 +1,56 @@ @@ -0,0 +1,56 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package errors
import (
"runtime"
)
// A Frame contains part of a call stack.
type Frame struct {
// Make room for three PCs: the one we were asked for, what it called,
// and possibly a PC for skipPleaseUseCallersFrames. See:
// https://go.googlesource.com/go/+/032678e0fb/src/runtime/extern.go#169
frames [3]uintptr
}
// Caller returns a Frame that describes a frame on the caller's stack.
// The argument skip is the number of frames to skip over.
// Caller(0) returns the frame for the caller of Caller.
func Caller(skip int) Frame {
var s Frame
runtime.Callers(skip+1, s.frames[:])
return s
}
// location reports the file, line, and function of a frame.
//
// The returned function may be "" even if file and line are not.
func (f Frame) location() (function, file string, line int) {
frames := runtime.CallersFrames(f.frames[:])
if _, ok := frames.Next(); !ok {
return "", "", 0
}
fr, ok := frames.Next()
if !ok {
return "", "", 0
}
return fr.Function, fr.File, fr.Line
}
// Format prints the stack as error detail.
// It should be called from an error's Format implementation
// after printing any other error detail.
func (f Frame) Format(p Printer) {
if p.Detail() {
function, file, line := f.location()
if function != "" {
p.Printf("%s\n ", function)
}
if file != "" {
p.Printf("%s:%d\n", file, line)
}
}
}

6
vendor/github.com/go-faster/errors/go.coverage.sh generated vendored

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e
go test -v -coverpkg=./... -coverprofile=profile.out ./...
go tool cover -func profile.out

12
vendor/github.com/go-faster/errors/go.test.sh generated vendored

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e
# test with -race
echo "with race:"
go test --timeout 5m -race ./...
# test with noerrtrace build tag
tag=noerrtrace
echo "with ${tag} build tag:"
go test -tags "${tag}" --timeout 5m -race ./...

13
vendor/github.com/go-faster/errors/noerrtrace.go generated vendored

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
//go:build noerrtrace
// +build noerrtrace
package errors
// enableTrace does nothing.
func enableTrace() {}
// DisableTrace does nothing.
func DisableTrace() {}
// Trace always returns false.
func Trace() bool { return false }

37
vendor/github.com/go-faster/errors/trace.go generated vendored

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
//go:build !noerrtrace
// +build !noerrtrace
package errors
import (
"sync/atomic"
)
var traceFlag int64
const (
traceEnabled = 0 // enabled by default
traceDisabled = 1
)
// setTrace sets tracing flag that controls capturing caller frames.
func setTrace(trace bool) {
if trace {
atomic.StoreInt64(&traceFlag, traceEnabled)
} else {
atomic.StoreInt64(&traceFlag, traceDisabled)
}
}
// enableTrace enables capturing caller frames.
//
// Intentionally left unexported.
func enableTrace() { setTrace(true) }
// DisableTrace disables capturing caller frames.
func DisableTrace() { setTrace(false) }
// Trace reports whether caller stack capture is enabled.
func Trace() bool {
return atomic.LoadInt64(&traceFlag) == traceEnabled
}

120
vendor/github.com/go-faster/errors/wrap.go generated vendored

@ -0,0 +1,120 @@ @@ -0,0 +1,120 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package errors
import (
"errors"
"fmt"
)
// A Wrapper provides context around another error.
type Wrapper interface {
// Unwrap returns the next error in the error chain.
// If there is no next error, Unwrap returns nil.
Unwrap() error
}
// Opaque returns an error with the same error formatting as err
// but that does not match err and cannot be unwrapped.
func Opaque(err error) error {
return noWrapper{err}
}
type noWrapper struct {
error
}
func (e noWrapper) FormatError(p Printer) (next error) {
if f, ok := e.error.(Formatter); ok {
return f.FormatError(p)
}
p.Print(e.error)
return nil
}
// Unwrap returns the result of calling the Unwrap method on err, if err's
// type contains an Unwrap method returning error.
// Otherwise, Unwrap returns nil.
func Unwrap(err error) error {
return errors.Unwrap(err)
}
type wrapError struct {
msg string
err error
frame Frame
}
func (e *wrapError) Error() string {
return fmt.Sprint(e)
}
func (e *wrapError) Format(s fmt.State, v rune) { FormatError(e, s, v) }
func (e *wrapError) FormatError(p Printer) (next error) {
p.Print(e.msg)
e.frame.Format(p)
return e.err
}
func (e *wrapError) Unwrap() error {
return e.err
}
// Wrap error with message and caller.
func Wrap(err error, message string) error {
frame := Frame{}
if Trace() {
frame = Caller(1)
}
return &wrapError{msg: message, err: err, frame: frame}
}
// Wrapf wraps error with formatted message and caller.
func Wrapf(err error, format string, a ...interface{}) error {
frame := Frame{}
if Trace() {
frame = Caller(1)
}
msg := fmt.Sprintf(format, a...)
return &wrapError{msg: msg, err: err, frame: frame}
}
// Is reports whether any error in err's chain matches target.
//
// The chain consists of err itself followed by the sequence of errors obtained by
// repeatedly calling Unwrap.
//
// An error is considered to match a target if it is equal to that target or if
// it implements a method Is(error) bool such that Is(target) returns true.
//
// An error type might provide an Is method so it can be treated as equivalent
// to an existing error. For example, if MyError defines
//
// func (m MyError) Is(target error) bool { return target == fs.ErrExist }
//
// then Is(MyError{}, fs.ErrExist) returns true. See syscall.Errno.Is for
// an example in the standard library.
func Is(err, target error) bool {
return errors.Is(err, target)
}
// As finds the first error in err's chain that matches target, and if so, sets
// target to that error value and returns true. Otherwise, it returns false.
//
// The chain consists of err itself followed by the sequence of errors obtained by
// repeatedly calling Unwrap.
//
// An error matches target if the error's concrete value is assignable to the value
// pointed to by target, or if the error has a method As(interface{}) bool such that
// As(target) returns true. In the latter case, the As method is responsible for
// setting target.
//
// An error type might provide an As method so it can be treated as if it were a
// different error type.
//
// As panics if target is not a non-nil pointer to either a type that implements
// error, or to any interface type.
func As(err error, target interface{}) bool { return errors.As(err, target) }

8
vendor/github.com/go-faster/jx/.codecov.yml generated vendored

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
ignore:
- tools/**
coverage:
status:
patch: false
project:
default:
threshold: 0.5%

25
vendor/github.com/go-faster/jx/.editorconfig generated vendored

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
# http://editorconfig.org/
root = true
[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
[{*.go, go.mod}]
indent_style = tab
indent_size = 4
[{*.yml,*.yaml}]
indent_style = space
indent_size = 2
[*.py]
indent_style = space
indent_size = 4
# Makefiles always use tabs for indentation
[Makefile]
indent_style = tab

15
vendor/github.com/go-faster/jx/.gitignore generated vendored

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
/vendor
/bug_test.go
/coverage.txt
/.idea
.idea
_bin/*
./examples
*-fuzz.zip
*.out
*.dump
*.test
corpus

108
vendor/github.com/go-faster/jx/.golangci.yml generated vendored

@ -0,0 +1,108 @@ @@ -0,0 +1,108 @@
linters-settings:
govet:
check-shadowing: true
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
dupl:
threshold: 120
goconst:
min-len: 2
min-occurrences: 3
misspell:
locale: US
lll:
line-length: 140
goimports:
local-prefixes: github.com/ogen/
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- hugeParam
- rangeValCopy
- exitAfterDefer
- whyNoLint
- singleCaseSwitch
- commentedOutCode
- appendAssign
- unnecessaryBlock
- redundantSprint
linters:
disable-all: true
enable:
- deadcode
- depguard
- dogsled
- errcheck
- goconst
- gocritic
- gofmt
- goimports
- revive
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
# Do not enable:
# - wsl (too opinionated about newlines)
# - godox (todos are OK)
# - bodyclose (false positives on helper functions)
# - prealloc (not worth it in scope of this project)
# - maligned (same as prealloc)
# - funlen (gocyclo is enough)
# - gochecknoglobals (we know when it is ok to use globals)
issues:
exclude-use-default: false
exclude-rules:
# Disable linters that are annoying in tests.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- funlen
- goconst
- gocognit
- scopelint
- lll
- path: _test\.go
text: "Combine"
linters:
- gocritic
# Check that equal to self is true
- linters: [gocritic]
source: '(assert|require).+Equal'
text: 'dupArg'
path: _test\.go
# Ignore shadowing of err.
- linters: [ govet ]
text: 'declaration of "(err|ctx|log|c)"'
# Ignore linters in main packages.
- path: main\.go
linters: [ goconst, funlen, gocognit, gocyclo ]

21
vendor/github.com/go-faster/jx/LICENSE generated vendored

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 json-iterator
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

13
vendor/github.com/go-faster/jx/Makefile generated vendored

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
test:
@./go.test.sh
.PHONY: test
coverage:
@./go.coverage.sh
.PHONY: coverage
test_fast:
go test ./...
tidy:
go mod tidy

306
vendor/github.com/go-faster/jx/README.md generated vendored

@ -0,0 +1,306 @@ @@ -0,0 +1,306 @@
# jx [![](https://img.shields.io/badge/go-pkg-00ADD8)](https://pkg.go.dev/github.com/go-faster/jx#section-documentation) [![](https://img.shields.io/codecov/c/github/go-faster/jx?label=cover)](https://codecov.io/gh/go-faster/jx) [![experimental](https://img.shields.io/badge/-experimental-blueviolet)](https://go-faster.org/docs/projects/status#experimental)
Package jx implements encoding and decoding of json [[RFC 7159](https://www.rfc-editor.org/rfc/rfc7159.html)].
Lightweight fork of [jsoniter](https://github.com/json-iterator/go).
```console
go get github.com/go-faster/jx
```
* [Usage and examples](#usage)
* [Roadmap](#roadmap)
* [Non-goals](#non-goals)
## Features
* Directly encode and decode json values
* No reflect or `interface{}`
* Pools and direct buffer access for less (or none) allocations
* Multi-pass decoding
* Validation
See [usage](#Usage) for examples. Mostly suitable for fast low-level json manipulation
with high control. Used in [ogen](https://github.com/ogen-go/ogen) project for
json (un)marshaling code generation based on json and OpenAPI schemas.
For example, we have following OpenTelemetry log entry:
```json
{
"Timestamp": "1586960586000000000",
"Attributes": {
"http.status_code": 500,
"http.url": "http://example.com",
"my.custom.application.tag": "hello"
},
"Resource": {
"service.name": "donut_shop",
"service.version": "2.0.0",
"k8s.pod.uid": "1138528c-c36e-11e9-a1a7-42010a800198"
},
"TraceId": "13e2a0921288b3ff80df0a0482d4fc46",
"SpanId": "43222c2d51a7abe3",
"SeverityText": "INFO",
"SeverityNumber": 9,
"Body": "20200415T072306-0700 INFO I like donuts"
}
```
Flexibility of `jx` enables highly efficient semantic-aware encoding and decoding,
e.g. using `[16]byte` for `TraceId` with zero-allocation `hex` encoding in json:
| Name | Speed | Allocations |
|----------|-----------|-------------|
| Decode | 970 MB/s | 0 allocs/op |
| Validate | 1535 MB/s | 0 allocs/op |
| Encode | 1104 MB/s | 0 allocs/op |
| Write | 2146 MB/s | 0 allocs/op |
See [otel_test.go](./otel_test.go) for example.
## Why
Most of [jsoniter](https://github.com/json-iterator/go) issues are caused by necessity
to be drop-in replacement for standard `encoding/json`. Removing such constrains greatly
simplified implementation and reduced scope, allowing to focus on json stream processing.
* Commas are handled automatically while encoding
* Raw json, Number and Base64 support
* Reduced scope
* No reflection
* No `encoding/json` adapter
* 3.5x less code (8.5K to 2.4K SLOC)
* Fuzzing, improved test coverage
* Drastically refactored and simplified
* Explicit error returns
* No `Config` or `API`
## Usage
* [Decoding](#decode)
* [Encoding](#encode)
* [Writer](#writer)
* [Raw message](#raw)
* [Number](#number)
* [Base64](#base64)
* [Validation](#validate)
* [Multi pass decoding](#capture)
### Decode
Use [jx.Decoder](https://pkg.go.dev/github.com/go-faster/jx#Decoder). Zero value is valid,
but constructors are available for convenience:
* [jx.Decode(reader io.Reader, bufSize int)](https://pkg.go.dev/github.com/go-faster/jx#Decode) for `io.Reader`
* [jx.DecodeBytes([]byte)](https://pkg.go.dev/github.com/go-faster/jx#Decode) for byte slices
* [jx.DecodeStr(string)](https://pkg.go.dev/github.com/go-faster/jx#Decode) for strings
To reuse decoders and their buffers, use [jx.GetDecoder](https://pkg.go.dev/github.com/go-faster/jx#GetDecoder)
and [jx.PutDecoder](https://pkg.go.dev/github.com/go-faster/jx#PutDecoder) alongside with reset functions:
* [jx.Decoder.Reset(io.Reader)](https://pkg.go.dev/github.com/go-faster/jx#Decoder.Reset) to reset to new `io.Reader`
* [jx.Decoder.ResetBytes([]byte)](https://pkg.go.dev/github.com/go-faster/jx#Decoder.ResetBytes) to decode another byte slice
Decoder is reset on `PutDecoder`.
```go
d := jx.DecodeStr(`{"values":[4,8,15,16,23,42]}`)
// Save all integers from "values" array to slice.
var values []int
// Iterate over each object field.
if err := d.Obj(func(d *jx.Decoder, key string) error {
switch key {
case "values":
// Iterate over each array element.
return d.Arr(func(d *jx.Decoder) error {
v, err := d.Int()
if err != nil {
return err
}
values = append(values, v)
return nil
})
default:
// Skip unknown fields if any.
return d.Skip()
}
}); err != nil {
panic(err)
}
fmt.Println(values)
// Output: [4 8 15 16 23 42]
```
### Encode
Use [jx.Encoder](https://pkg.go.dev/github.com/go-faster/jx#Encoder). Zero value is valid, reuse with
[jx.GetEncoder](https://pkg.go.dev/github.com/go-faster/jx#GetEncoder),
[jx.PutEncoder](https://pkg.go.dev/github.com/go-faster/jx#PutEncoder) and
[jx.Encoder.Reset()](https://pkg.go.dev/github.com/go-faster/jx#Encoder.Reset). Encoder is reset on `PutEncoder`.
```go
var e jx.Encoder
e.ObjStart() // {
e.FieldStart("values") // "values":
e.ArrStart() // [
for _, v := range []int{4, 8, 15, 16, 23, 42} {
e.Int(v)
}
e.ArrEnd() // ]
e.ObjEnd() // }
fmt.Println(e)
fmt.Println("Buffer len:", len(e.Bytes()))
// Output: {"values":[4,8,15,16,23,42]}
// Buffer len: 28
```
### Writer
Use [jx.Writer](https://pkg.go.dev/github.com/go-faster/jx#Writer) for low level json writing.
No automatic commas or indentation for lowest possible overhead, useful for code generated json encoding.
### Raw
Use [jx.Decoder.Raw](https://pkg.go.dev/github.com/go-faster/jx#Decoder.Raw) to read raw json values, similar to `json.RawMessage`.
```go
d := jx.DecodeStr(`{"foo": [1, 2, 3]}`)
var raw jx.Raw
if err := d.Obj(func(d *jx.Decoder, key string) error {
v, err := d.Raw()
if err != nil {
return err
}
raw = v
return nil
}); err != nil {
panic(err)
}
fmt.Println(raw.Type(), raw)
// Output:
// array [1, 2, 3]
```
### Number
Use [jx.Decoder.Num](https://pkg.go.dev/github.com/go-faster/jx#Decoder.Num) to read numbers, similar to `json.Number`.
Also supports number strings, like `"12345"`, which is common compatible way to represent `uint64`.
```go
d := jx.DecodeStr(`{"foo": "10531.0"}`)
var n jx.Num
if err := d.Obj(func(d *jx.Decoder, key string) error {
v, err := d.Num()
if err != nil {
return err
}
n = v
return nil
}); err != nil {
panic(err)
}
fmt.Println(n)
fmt.Println("positive:", n.Positive())
// Can decode floats with zero fractional part as integers:
v, err := n.Int64()
if err != nil {
panic(err)
}
fmt.Println("int64:", v)
// Output:
// "10531.0"
// positive: true
// int64: 10531
```
### Base64
Use [jx.Encoder.Base64](https://pkg.go.dev/github.com/go-faster/jx#Encoder.Base64) and
[jx.Decoder.Base64](https://pkg.go.dev/github.com/go-faster/jx#Decoder.Base64) or
[jx.Decoder.Base64Append](https://pkg.go.dev/github.com/go-faster/jx#Decoder.Base64Append).
Same as encoding/json, base64.StdEncoding or [[RFC 4648](https://www.rfc-editor.org/rfc/rfc4648.html)].
```go
var e jx.Encoder
e.Base64([]byte("Hello"))
fmt.Println(e)
data, _ := jx.DecodeBytes(e.Bytes()).Base64()
fmt.Printf("%s", data)
// Output:
// "SGVsbG8="
// Hello
```
### Validate
Check that byte slice is valid json with [jx.Valid](https://pkg.go.dev/github.com/go-faster/jx#Valid):
```go
fmt.Println(jx.Valid([]byte(`{"field": "value"}`))) // true
fmt.Println(jx.Valid([]byte(`"Hello, world!"`))) // true
fmt.Println(jx.Valid([]byte(`["foo"}`))) // false
```
### Capture
The [jx.Decoder.Capture](https://pkg.go.dev/github.com/go-faster/jx#Decoder.Capture) method allows to unread everything is read in callback.
Useful for multi-pass parsing:
```go
d := jx.DecodeStr(`["foo", "bar", "baz"]`)
var elems int
// NB: Currently Capture does not support io.Reader, only buffers.
if err := d.Capture(func(d *jx.Decoder) error {
// Everything decoded in this callback will be rolled back.
return d.Arr(func(d *jx.Decoder) error {
elems++
return d.Skip()
})
}); err != nil {
panic(err)
}
// Decoder is rolled back to state before "Capture" call.
fmt.Println("Read", elems, "elements on first pass")
fmt.Println("Next element is", d.Next(), "again")
// Output:
// Read 3 elements on first pass
// Next element is array again
```
### ObjBytes
The `Decoder.ObjBytes` method tries not to allocate memory for keys, reusing existing buffer.
```go
d := DecodeStr(`{"id":1,"randomNumber":10}`)
d.ObjBytes(func(d *Decoder, key []byte) error {
switch string(key) {
case "id":
case "randomNumber":
}
return d.Skip()
})
```
## Roadmap
- [ ] Rework and export `Any`
- [ ] Support `Raw` for io.Reader
- [x] Support `Capture` for io.Reader
- [ ] Improve Num
- Better validation on decoding
- Support BigFloat and BigInt
- Support equivalence check, like `eq(1.0, 1) == true`
- [ ] Add non-callback decoding of objects
## Non-goals
* Code generation for decoding or encoding
* Replacement for `encoding/json`
* Reflection or `interface{}` based encoding or decoding
* Support for json path or similar
This package should be kept as simple as possible and be used as
low-level foundation for high-level projects like code generator.
## License
MIT, same as jsoniter

143
vendor/github.com/go-faster/jx/dec.go generated vendored

@ -0,0 +1,143 @@ @@ -0,0 +1,143 @@
package jx
import (
"io"
)
// Type of json value.
type Type int
func (t Type) String() string {
switch t {
case Invalid:
return "invalid"
case String:
return "string"
case Number:
return "number"
case Null:
return "null"
case Bool:
return "bool"
case Array:
return "array"
case Object:
return "object"
default:
return "unknown"
}
}
const (
// Invalid json value.
Invalid Type = iota
// String json value, like "foo".
String
// Number json value, like 100 or 1.01.
Number
// Null json value.
Null
// Bool json value, true or false.
Bool
// Array json value, like [1, 2, 3].
Array
// Object json value, like {"foo": 1}.
Object
)
var types []Type
func init() {
types = make([]Type, 256)
for i := range types {
types[i] = Invalid
}
types['"'] = String
types['-'] = Number
types['0'] = Number
types['1'] = Number
types['2'] = Number
types['3'] = Number
types['4'] = Number
types['5'] = Number
types['6'] = Number
types['7'] = Number
types['8'] = Number
types['9'] = Number
types['t'] = Bool
types['f'] = Bool
types['n'] = Null
types['['] = Array
types['{'] = Object
}
// Decoder decodes json.
//
// Can decode from io.Reader or byte slice directly.
type Decoder struct {
reader io.Reader
// buf is current buffer.
//
// Contains full json if reader is nil or used as a read buffer
// otherwise.
buf []byte
head int // offset in buf to start of current json stream
tail int // offset in buf to end of current json stream
depth int
}
const defaultBuf = 512
// Decode creates a Decoder that reads json from io.Reader.
func Decode(reader io.Reader, bufSize int) *Decoder {
if bufSize <= 0 {
bufSize = defaultBuf
}
return &Decoder{
reader: reader,
buf: make([]byte, bufSize),
}
}
// DecodeBytes creates a Decoder that reads json from byte slice.
func DecodeBytes(input []byte) *Decoder {
return &Decoder{
buf: input,
tail: len(input),
}
}
// DecodeStr creates a Decoder that reads string as json.
func DecodeStr(input string) *Decoder {
return DecodeBytes([]byte(input))
}
// Reset resets reader and underlying state, next reads will use provided io.Reader.
func (d *Decoder) Reset(reader io.Reader) {
d.reader = reader
d.head = 0
d.tail = 0
d.depth = 0
// Reads from reader need buffer.
if cap(d.buf) == 0 {
// Allocate new buffer if none.
d.buf = make([]byte, defaultBuf)
}
if len(d.buf) == 0 {
// Set buffer to full capacity if needed.
d.buf = d.buf[:cap(d.buf)]
}
}
// ResetBytes resets underlying state, next reads will use provided buffer.
func (d *Decoder) ResetBytes(input []byte) {
d.reader = nil
d.head = 0
d.tail = len(input)
d.depth = 0
d.buf = input
}

80
vendor/github.com/go-faster/jx/dec_arr.go generated vendored

@ -0,0 +1,80 @@ @@ -0,0 +1,80 @@
package jx
import (
"github.com/go-faster/errors"
)
// Elem skips to the start of next array element, returning true boolean
// if element exists.
//
// Can be called before or in Array.
func (d *Decoder) Elem() (ok bool, err error) {
c, err := d.next()
if err != nil {
return false, err
}
switch c {
case '[':
c, err := d.more()
if err != nil {
return false, errors.Wrap(err, "next")
}
if c != ']' {
d.unread()
return true, nil
}
return false, nil
case ']':
return false, nil
case ',':
return true, nil
default:
return false, errors.Wrap(badToken(c), `"[" or "," or "]" expected`)
}
}
// Arr decodes array and invokes callback on each array element.
func (d *Decoder) Arr(f func(d *Decoder) error) error {
if err := d.consume('['); err != nil {
return errors.Wrap(err, "start")
}
if f == nil {
return d.skipArr()
}
if err := d.incDepth(); err != nil {
return errors.Wrap(err, "inc")
}
c, err := d.more()
if err != nil {
return err
}
if c == ']' {
return d.decDepth()
}
d.unread()
if err := f(d); err != nil {
return errors.Wrap(err, "callback")
}
c, err = d.more()
if err != nil {
return errors.Wrap(err, "next")
}
for c == ',' {
// Skip whitespace before reading element.
if _, err := d.next(); err != nil {
return errors.Wrap(err, "next")
}
d.unread()
if err := f(d); err != nil {
return errors.Wrap(err, "callback")
}
if c, err = d.next(); err != nil {
return errors.Wrap(err, "next")
}
}
if c != ']' {
return errors.Wrap(badToken(c), "end")
}
return d.decDepth()
}

46
vendor/github.com/go-faster/jx/dec_b64.go generated vendored

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
package jx
import (
"github.com/go-faster/errors"
"github.com/segmentio/asm/base64"
)
// Base64 decodes base64 encoded data from string.
//
// Same as encoding/json, base64.StdEncoding or RFC 4648.
func (d *Decoder) Base64() ([]byte, error) {
if d.Next() == Null {
if err := d.Null(); err != nil {
return nil, errors.Wrap(err, "read null")
}
return nil, nil
}
return d.Base64Append([]byte{})
}
// Base64Append appends base64 encoded data from string.
//
// Same as encoding/json, base64.StdEncoding or RFC 4648.
func (d *Decoder) Base64Append(b []byte) ([]byte, error) {
if d.Next() == Null {
if err := d.Null(); err != nil {
return nil, errors.Wrap(err, "read null")
}
return b, nil
}
buf, err := d.StrBytes()
if err != nil {
return nil, errors.Wrap(err, "bytes")
}
decodedLen := base64.StdEncoding.DecodedLen(len(buf))
start := len(b)
b = append(b, make([]byte, decodedLen)...)
n, err := base64.StdEncoding.Decode(b[start:], buf)
if err != nil {
return nil, errors.Wrap(err, "decode")
}
return b[:start+n], nil
}

38
vendor/github.com/go-faster/jx/dec_bool.go generated vendored

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
package jx
// Bool reads a json object as Bool
func (d *Decoder) Bool() (bool, error) {
if err := d.skipSpace(); err != nil {
return false, err
}
var buf [4]byte
if err := d.readExact4(&buf); err != nil {
return false, err
}
switch string(buf[:]) {
case "true":
return true, nil
case "fals":
c, err := d.byte()
if err != nil {
return false, err
}
if c != 'e' {
return false, badToken(c)
}
return false, nil
default:
switch c := buf[0]; c {
case 't':
const encodedTrue = 't' | 'r'<<8 | 'u'<<16 | 'e'<<24
return false, findInvalidToken4(buf, encodedTrue)
case 'f':
const encodedAlse = 'a' | 'l'<<8 | 's'<<16 | 'e'<<24
return false, findInvalidToken4(buf, encodedAlse)
default:
return false, badToken(c)
}
}
}

27
vendor/github.com/go-faster/jx/dec_capture.go generated vendored

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
package jx
import (
"bytes"
"io"
)
// Capture calls f and then rolls back to state before call.
func (d *Decoder) Capture(f func(d *Decoder) error) error {
if f == nil {
return nil
}
if d.reader != nil {
// TODO(tdakkota): May it be more efficient?
var buf bytes.Buffer
reader := io.TeeReader(d.reader, &buf)
defer func() {
d.reader = io.MultiReader(&buf, d.reader)
}()
d.reader = reader
}
head, tail, depth := d.head, d.tail, d.depth
err := f(d)
d.head, d.tail, d.depth = head, tail, depth
return err
}

26
vendor/github.com/go-faster/jx/dec_depth.go generated vendored

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
package jx
import "github.com/go-faster/errors"
// limit maximum depth of nesting, as allowed by https://tools.ietf.org/html/rfc7159#section-9
const maxDepth = 10000
var errMaxDepth = errors.New("depth: maximum")
func (d *Decoder) incDepth() error {
d.depth++
if d.depth > maxDepth {
return errMaxDepth
}
return nil
}
var errNegativeDepth = errors.New("depth: negative")
func (d *Decoder) decDepth() error {
d.depth--
if d.depth < 0 {
return errNegativeDepth
}
return nil
}

360
vendor/github.com/go-faster/jx/dec_float.go generated vendored

@ -0,0 +1,360 @@ @@ -0,0 +1,360 @@
package jx
import (
"bytes"
"io"
"math/big"
"strconv"
"github.com/go-faster/errors"
)
var pow10 = []uint64{1, 10, 100, 1000, 10000, 100000, 1000000}
var floatDigits []int8
const invalidCharForNumber = int8(-1)
const endOfNumber = int8(-2)
const dotInNumber = int8(-3)
const maxFloat64 = 1<<63 - 1
func init() {
floatDigits = make([]int8, 256)
for i := 0; i < len(floatDigits); i++ {
floatDigits[i] = invalidCharForNumber
}
for i := int8('0'); i <= int8('9'); i++ {
floatDigits[i] = i - int8('0')
}
floatDigits[','] = endOfNumber
floatDigits[']'] = endOfNumber
floatDigits['}'] = endOfNumber
floatDigits[' '] = endOfNumber
floatDigits['\t'] = endOfNumber
floatDigits['\n'] = endOfNumber
floatDigits['.'] = dotInNumber
}
// BigFloat read big.Float
func (d *Decoder) BigFloat() (*big.Float, error) {
str, err := d.numberAppend(nil)
if err != nil {
return nil, errors.Wrap(err, "number")
}
prec := 64
if len(str) > prec {
prec = len(str)
}
val, _, err := big.ParseFloat(string(str), 10, uint(prec), big.ToZero)
if err != nil {
return nil, errors.Wrap(err, "float")
}
return val, nil
}
// BigInt read big.Int
func (d *Decoder) BigInt() (*big.Int, error) {
str, err := d.numberAppend(nil)
if err != nil {
return nil, errors.Wrap(err, "number")
}
v := big.NewInt(0)
var ok bool
if v, ok = v.SetString(string(str), 10); !ok {
return nil, errors.New("invalid")
}
return v, nil
}
// Float32 reads float32 value.
func (d *Decoder) Float32() (float32, error) {
c, err := d.more()
if err != nil {
return 0, errors.Wrap(err, "byte")
}
if c != '-' {
d.unread()
}
v, err := d.positiveFloat32()
if err != nil {
return 0, err
}
if c == '-' {
v *= -1
}
return v, nil
}
func (d *Decoder) positiveFloat32() (float32, error) {
i := d.head
// First char.
if i == d.tail {
return d.f32Slow()
}
c := d.buf[i]
i++
ind := floatDigits[c]
switch ind {
case invalidCharForNumber:
return d.f32Slow()
case endOfNumber:
return 0, errors.New("empty")
case dotInNumber:
return 0, errors.New("leading dot")
case 0:
if i == d.tail {
return d.f32Slow()
}
c = d.buf[i]
switch c {
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
return 0, errors.New("leading zero")
}
}
value := uint64(ind)
// Chars before dot.
NonDecimalLoop:
for ; i < d.tail; i++ {
c = d.buf[i]
ind := floatDigits[c]
switch ind {
case invalidCharForNumber:
return d.f32Slow()
case endOfNumber:
d.head = i
return float32(value), nil
case dotInNumber:
break NonDecimalLoop
}
if value > uint64SafeToMultiple10 {
return d.f32Slow()
}
value = (value << 3) + (value << 1) + uint64(ind) // value = value * 10 + ind;
}
// Chars after dot.
if c == '.' {
i++
decimalPlaces := 0
if i == d.tail {
return d.f32Slow()
}
for ; i < d.tail; i++ {
c = d.buf[i]
ind := floatDigits[c]
switch ind {
case endOfNumber:
if decimalPlaces > 0 && decimalPlaces < len(pow10) {
d.head = i
return float32(float64(value) / float64(pow10[decimalPlaces])), nil
}
// too many decimal places
return d.f32Slow()
case invalidCharForNumber, dotInNumber:
return d.f32Slow()
}
decimalPlaces++
if value > uint64SafeToMultiple10 {
return d.f32Slow()
}
value = (value << 3) + (value << 1) + uint64(ind)
}
}
return d.f32Slow()
}
func (d *Decoder) number() []byte {
start := d.head
buf := d.buf[d.head:d.tail]
for i, c := range buf {
switch c {
case '+', '-', '.', 'e', 'E', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
continue
default:
// End of number.
d.head += i
return d.buf[start:d.head]
}
}
// Buffer is number within head:tail.
d.head = d.tail
return d.buf[start:d.tail]
}
func (d *Decoder) numberAppend(b []byte) ([]byte, error) {
for {
b = append(b, d.number()...)
if d.head != d.tail {
return b, nil
}
if err := d.read(); err != nil {
if err == io.EOF {
return b, nil
}
return b, err
}
}
}
const (
size32 = 32
size64 = 64
)
func (d *Decoder) f32Slow() (float32, error) {
v, err := d.floatSlow(size32)
if err != nil {
return 0, err
}
return float32(v), err
}
// Float64 read float64
func (d *Decoder) Float64() (float64, error) {
c, err := d.more()
if err != nil {
return 0, errors.Wrap(err, "byte")
}
switch c {
case '-':
v, err := d.positiveFloat64()
if err != nil {
return 0, err
}
return -v, err
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
d.unread()
return d.positiveFloat64()
default:
return 0, badToken(c)
}
}
func (d *Decoder) positiveFloat64() (float64, error) {
i := d.head
// First char.
if i == d.tail {
return d.float64Slow()
}
c := d.buf[i]
i++
ind := floatDigits[c]
switch ind {
case invalidCharForNumber:
return d.float64Slow()
case endOfNumber:
return 0, errors.New("empty")
case dotInNumber:
return 0, errors.New("leading dot")
case 0:
if i == d.tail {
return d.float64Slow()
}
c = d.buf[i]
switch c {
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
return 0, errors.New("leading zero")
}
}
value := uint64(ind)
// Chars before dot.
NonDecimal:
for ; i < d.tail; i++ {
c = d.buf[i]
ind := floatDigits[c]
switch ind {
case invalidCharForNumber:
return d.float64Slow()
case endOfNumber:
d.head = i
return float64(value), nil
case dotInNumber:
break NonDecimal
}
if value > uint64SafeToMultiple10 {
return d.float64Slow()
}
value = (value << 3) + (value << 1) + uint64(ind) // value = value * 10 + ind;
}
// chars after dot
if c == '.' {
i++
decimalPlaces := 0
if i == d.tail {
return d.float64Slow()
}
for ; i < d.tail; i++ {
c = d.buf[i]
ind := floatDigits[c]
switch ind {
case endOfNumber:
if decimalPlaces > 0 && decimalPlaces < len(pow10) {
d.head = i
return float64(value) / float64(pow10[decimalPlaces]), nil
}
// too many decimal places
return d.float64Slow()
case invalidCharForNumber, dotInNumber:
return d.float64Slow()
}
decimalPlaces++
// Not checking for uint64SafeToMultiple10 here because
// if condition is positive value multiplied by 10 is
// guaranteed to be bigger than maxFloat64.
value = (value << 3) + (value << 1) + uint64(ind)
if value > maxFloat64 {
return d.float64Slow()
}
}
}
return d.float64Slow()
}
func (d *Decoder) floatSlow(size int) (float64, error) {
var buf [32]byte
str, err := d.numberAppend(buf[:0])
if err != nil {
return 0, errors.Wrap(err, "number")
}
if err := validateFloat(str); err != nil {
return 0, errors.Wrap(err, "invalid")
}
val, err := strconv.ParseFloat(string(str), size)
if err != nil {
return 0, err
}
return val, nil
}
func (d *Decoder) float64Slow() (float64, error) { return d.floatSlow(size64) }
func validateFloat(str []byte) error {
// strconv.ParseFloat is not validating `1.` or `1.e1`
if len(str) == 0 {
return errors.New("empty")
}
if str[0] == '-' {
return errors.New("double minus")
}
if len(str) >= 2 && str[0] == '0' {
switch str[1] {
case 'e', 'E', '.':
default:
return errors.New("leading zero")
}
}
dotPos := bytes.IndexByte(str, '.')
if dotPos != -1 {
if dotPos == len(str)-1 {
return errors.New("dot as last char")
}
switch str[dotPos+1] {
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
default:
return errors.New("no digit after dot")
}
}
return nil
}

303
vendor/github.com/go-faster/jx/dec_int.go generated vendored

@ -0,0 +1,303 @@ @@ -0,0 +1,303 @@
package jx
import (
"io"
"math"
"strconv"
"github.com/go-faster/errors"
)
var intDigits []int8
const uint32SafeToMultiply10 = uint32(0xffffffff)/10 - 1
const uint64SafeToMultiple10 = uint64(0xffffffffffffffff)/10 - 1
func init() {
intDigits = make([]int8, 256)
for i := 0; i < len(intDigits); i++ {
intDigits[i] = invalidCharForNumber
}
for i := int8('0'); i <= int8('9'); i++ {
intDigits[i] = i - int8('0')
}
}
func (d *Decoder) uint(size int) (uint, error) {
if size == 32 {
v, err := d.UInt32()
return uint(v), err
}
v, err := d.UInt64()
return uint(v), err
}
// UInt read uint.
func (d *Decoder) UInt() (uint, error) {
return d.uint(strconv.IntSize)
}
func (d *Decoder) int(size int) (int, error) {
if size == 32 {
v, err := d.Int32()
return int(v), err
}
v, err := d.Int64()
return int(v), err
}
// Int reads integer.
func (d *Decoder) Int() (int, error) {
return d.int(strconv.IntSize)
}
// Int32 reads int32 value.
func (d *Decoder) Int32() (int32, error) {
c, err := d.byte()
if err != nil {
return 0, errors.Wrap(err, "byte")
}
if c == '-' {
val, err := d.readUInt32()
if err != nil {
return 0, err
}
if val > math.MaxInt32+1 {
return 0, errors.New("overflow")
}
return -int32(val), nil
}
d.unread()
val, err := d.readUInt32()
if err != nil {
return 0, err
}
if val > math.MaxInt32 {
return 0, errors.New("overflow")
}
return int32(val), nil
}
// UInt32 read uint32
func (d *Decoder) UInt32() (uint32, error) {
return d.readUInt32()
}
func (d *Decoder) readUInt32() (uint32, error) {
c, err := d.byte()
if err != nil {
return 0, errors.Wrap(err, "byte")
}
ind := intDigits[c]
if ind == 0 {
return 0, nil
}
if ind == invalidCharForNumber {
return 0, errors.Wrap(err, "bad token")
}
value := uint32(ind)
if d.tail-d.head > 10 {
i := d.head
ind2 := intDigits[d.buf[i]]
if ind2 == invalidCharForNumber {
d.head = i
return value, nil
}
i++
ind3 := intDigits[d.buf[i]]
if ind3 == invalidCharForNumber {
d.head = i
return value*10 + uint32(ind2), nil
}
i++
ind4 := intDigits[d.buf[i]]
if ind4 == invalidCharForNumber {
d.head = i
return value*100 + uint32(ind2)*10 + uint32(ind3), nil
}
i++
ind5 := intDigits[d.buf[i]]
if ind5 == invalidCharForNumber {
d.head = i
return value*1000 + uint32(ind2)*100 + uint32(ind3)*10 + uint32(ind4), nil
}
i++
ind6 := intDigits[d.buf[i]]
if ind6 == invalidCharForNumber {
d.head = i
return value*10000 + uint32(ind2)*1000 + uint32(ind3)*100 + uint32(ind4)*10 + uint32(ind5), nil
}
i++
ind7 := intDigits[d.buf[i]]
if ind7 == invalidCharForNumber {
d.head = i
return value*100000 + uint32(ind2)*10000 + uint32(ind3)*1000 + uint32(ind4)*100 + uint32(ind5)*10 + uint32(ind6), nil
}
i++
ind8 := intDigits[d.buf[i]]
if ind8 == invalidCharForNumber {
d.head = i
return value*1000000 + uint32(ind2)*100000 + uint32(ind3)*10000 + uint32(ind4)*1000 + uint32(ind5)*100 + uint32(ind6)*10 + uint32(ind7), nil
}
i++
ind9 := intDigits[d.buf[i]]
value = value*10000000 + uint32(ind2)*1000000 + uint32(ind3)*100000 + uint32(ind4)*10000 + uint32(ind5)*1000 + uint32(ind6)*100 + uint32(ind7)*10 + uint32(ind8)
d.head = i
if ind9 == invalidCharForNumber {
return value, nil
}
}
for {
buf := d.buf[d.head:d.tail]
for i, c := range buf {
ind = intDigits[c]
if ind == invalidCharForNumber {
d.head += i
return value, nil
}
if value > uint32SafeToMultiply10 {
value2 := (value << 3) + (value << 1) + uint32(ind)
if value2 < value {
return 0, errors.New("overflow")
}
value = value2
continue
}
value = (value << 3) + (value << 1) + uint32(ind)
}
err := d.read()
if err == io.EOF {
return value, nil
}
if err != nil {
return 0, err
}
}
}
// Int64 read int64
func (d *Decoder) Int64() (int64, error) {
c, err := d.byte()
if err != nil {
return 0, errors.Wrap(err, "byte")
}
if c == '-' {
c, err := d.next()
if err != nil {
return 0, err
}
val, err := d.readUInt64(c)
if err != nil {
return 0, err
}
if val > math.MaxInt64+1 {
return 0, errors.Errorf("%d overflows", val)
}
return -int64(val), nil
}
val, err := d.readUInt64(c)
if err != nil {
return 0, err
}
if val > math.MaxInt64 {
return 0, errors.Errorf("%d overflows", val)
}
return int64(val), nil
}
// UInt64 read uint64
func (d *Decoder) UInt64() (uint64, error) {
c, err := d.byte()
if err != nil {
return 0, errors.Wrap(err, "byte")
}
return d.readUInt64(c)
}
func (d *Decoder) readUInt64(c byte) (uint64, error) {
ind := intDigits[c]
if ind == 0 {
return 0, nil // single zero
}
if ind == invalidCharForNumber {
return 0, errors.Wrap(badToken(c), "invalid number")
}
value := uint64(ind)
if d.tail-d.head > 10 {
i := d.head
ind2 := intDigits[d.buf[i]]
if ind2 == invalidCharForNumber {
d.head = i
return value, nil
}
i++
ind3 := intDigits[d.buf[i]]
if ind3 == invalidCharForNumber {
d.head = i
return value*10 + uint64(ind2), nil
}
i++
ind4 := intDigits[d.buf[i]]
if ind4 == invalidCharForNumber {
d.head = i
return value*100 + uint64(ind2)*10 + uint64(ind3), nil
}
i++
ind5 := intDigits[d.buf[i]]
if ind5 == invalidCharForNumber {
d.head = i
return value*1000 + uint64(ind2)*100 + uint64(ind3)*10 + uint64(ind4), nil
}
i++
ind6 := intDigits[d.buf[i]]
if ind6 == invalidCharForNumber {
d.head = i
return value*10000 + uint64(ind2)*1000 + uint64(ind3)*100 + uint64(ind4)*10 + uint64(ind5), nil
}
i++
ind7 := intDigits[d.buf[i]]
if ind7 == invalidCharForNumber {
d.head = i
return value*100000 + uint64(ind2)*10000 + uint64(ind3)*1000 + uint64(ind4)*100 + uint64(ind5)*10 + uint64(ind6), nil
}
i++
ind8 := intDigits[d.buf[i]]
if ind8 == invalidCharForNumber {
d.head = i
return value*1000000 + uint64(ind2)*100000 + uint64(ind3)*10000 + uint64(ind4)*1000 + uint64(ind5)*100 + uint64(ind6)*10 + uint64(ind7), nil
}
i++
ind9 := intDigits[d.buf[i]]
value = value*10000000 + uint64(ind2)*1000000 + uint64(ind3)*100000 + uint64(ind4)*10000 + uint64(ind5)*1000 + uint64(ind6)*100 + uint64(ind7)*10 + uint64(ind8)
d.head = i
if ind9 == invalidCharForNumber {
return value, nil
}
}
for {
buf := d.buf[d.head:d.tail]
for i, c := range buf {
ind = intDigits[c]
if ind == invalidCharForNumber {
d.head += i
return value, nil
}
if value > uint64SafeToMultiple10 {
value2 := (value << 3) + (value << 1) + uint64(ind)
if value2 < value {
return 0, errors.New("overflow")
}
value = value2
continue
}
value = (value << 3) + (value << 1) + uint64(ind)
}
err := d.read()
if err == io.EOF {
return value, nil
}
if err != nil {
return 0, errors.Wrap(err, "read")
}
}
}

20
vendor/github.com/go-faster/jx/dec_null.go generated vendored

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
package jx
// Null reads a json object as null and
// returns whether it's a null or not.
func (d *Decoder) Null() error {
if err := d.skipSpace(); err != nil {
return err
}
var buf [4]byte
if err := d.readExact4(&buf); err != nil {
return err
}
if string(buf[:]) != "null" {
const encodedNull = 'n' | 'u'<<8 | 'l'<<16 | 'l'<<24
return findInvalidToken4(buf, encodedNull)
}
return nil
}

75
vendor/github.com/go-faster/jx/dec_num.go generated vendored

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
package jx
import (
"github.com/go-faster/errors"
)
// Num decodes number.
//
// Do not retain returned value, it references underlying buffer.
func (d *Decoder) Num() (Num, error) {
return d.num(nil, false)
}
// NumAppend appends number.
func (d *Decoder) NumAppend(v Num) (Num, error) {
return d.num(v, true)
}
// num decodes number.
func (d *Decoder) num(v Num, forceAppend bool) (Num, error) {
var str bool
switch d.Next() {
case String:
str = true
case Number: // float or integer
default:
return v, errors.Errorf("unexpected %s", d.Next())
}
if d.reader == nil && !forceAppend {
// Can use underlying buffer directly.
start := d.head
d.head++
d.number()
if str {
if err := d.consume('"'); err != nil {
return nil, errors.Wrap(err, "end of string")
}
}
v = d.buf[start:d.head]
} else {
if str {
d.head++ // '"'
v = append(v, '"')
}
buf, err := d.numberAppend(v)
if err != nil {
return v, errors.Wrap(err, "decode")
}
if str {
if err := d.consume('"'); err != nil {
return nil, errors.Wrap(err, "end of string")
}
buf = append(buf, '"')
}
v = buf
}
var dot bool
for _, c := range v {
if c != '.' {
continue
}
if dot {
return v, errors.New("multiple dots in number")
}
dot = true
}
// TODO(ernado): Additional validity checks
// Current invariants:
// 1) Zero or one dot
// 2) Only: +, -, ., e, E, 0-9
return v, nil
}

86
vendor/github.com/go-faster/jx/dec_obj.go generated vendored

@ -0,0 +1,86 @@ @@ -0,0 +1,86 @@
package jx
import (
"github.com/go-faster/errors"
)
// ObjBytes calls f for every key in object, using byte slice as key.
//
// The key value is valid only until f is not returned.
func (d *Decoder) ObjBytes(f func(d *Decoder, key []byte) error) error {
if err := d.consume('{'); err != nil {
return errors.Wrap(err, "start")
}
if f == nil {
return d.skipObj()
}
if err := d.incDepth(); err != nil {
return errors.Wrap(err, "inc")
}
c, err := d.more()
if err != nil {
return errors.Wrap(err, "next")
}
if c == '}' {
return d.decDepth()
}
d.unread()
k, err := d.str(value{raw: true})
if err != nil {
return errors.Wrap(err, "str")
}
if err := d.consume(':'); err != nil {
return errors.Wrap(err, "field")
}
// Skip whitespace.
if _, err = d.more(); err != nil {
return errors.Wrap(err, "more")
}
d.unread()
if err := f(d, k.buf); err != nil {
return errors.Wrap(err, "callback")
}
c, err = d.more()
if err != nil {
return errors.Wrap(err, "next")
}
for c == ',' {
k, err := d.str(value{raw: true})
if err != nil {
return errors.Wrap(err, "str")
}
if err := d.consume(':'); err != nil {
return errors.Wrap(err, "field")
}
// Check that value exists.
if _, err = d.more(); err != nil {
return errors.Wrap(err, "more")
}
d.unread()
if err := f(d, k.buf); err != nil {
return errors.Wrap(err, "callback")
}
if c, err = d.more(); err != nil {
return errors.Wrap(err, "next")
}
}
if c != '}' {
return errors.Wrap(badToken(c), "err")
}
return d.decDepth()
}
// Obj reads json object, calling f on each field.
//
// Use ObjBytes to reduce heap allocations for keys.
func (d *Decoder) Obj(f func(d *Decoder, key string) error) error {
if f == nil {
// Skipping object.
return d.ObjBytes(nil)
}
return d.ObjBytes(func(d *Decoder, key []byte) error {
return f(d, string(key))
})
}

39
vendor/github.com/go-faster/jx/dec_raw.go generated vendored

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
package jx
import "github.com/go-faster/errors"
// Raw is like Skip(), but saves and returns skipped value as raw json.
//
// Do not retain returned value, it references underlying buffer.
func (d *Decoder) Raw() (Raw, error) {
if d.reader != nil {
return nil, errors.New("not implemented for io.Reader")
}
start := d.head
if err := d.Skip(); err != nil {
return nil, errors.Wrap(err, "skip")
}
return d.buf[start:d.head], nil
}
// RawAppend is Raw that appends saved raw json value to buf.
func (d *Decoder) RawAppend(buf Raw) (Raw, error) {
raw, err := d.Raw()
if err != nil {
return nil, err
}
return append(buf, raw...), err
}
// Raw json value.
type Raw []byte
// Type of Raw json value.
func (r Raw) Type() Type {
d := Decoder{buf: r, tail: len(r)}
return d.Next()
}
func (r Raw) String() string { return string(r) }

146
vendor/github.com/go-faster/jx/dec_read.go generated vendored

@ -0,0 +1,146 @@ @@ -0,0 +1,146 @@
package jx
import (
"io"
"math/bits"
)
// Next gets Type of relatively next json element
func (d *Decoder) Next() Type {
v, err := d.next()
if err == nil {
d.unread()
}
return types[v]
}
var spaceSet = [256]byte{
' ': 1, '\n': 1, '\t': 1, '\r': 1,
}
func (d *Decoder) consume(c byte) (err error) {
for {
buf := d.buf[d.head:d.tail]
for i, got := range buf {
switch spaceSet[got] {
default:
d.head += i + 1
if c != got {
return badToken(got)
}
return nil
case 1:
continue
}
}
if err = d.read(); err != nil {
if err == io.EOF {
return io.ErrUnexpectedEOF
}
return err
}
}
}
// more is next but io.EOF is unexpected.
func (d *Decoder) more() (byte, error) {
c, err := d.next()
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return c, err
}
// next reads next non-whitespace token or error.
func (d *Decoder) next() (byte, error) {
for {
buf := d.buf[d.head:d.tail]
for i, c := range buf {
switch spaceSet[c] {
default:
d.head += i + 1
return c, nil
case 1:
continue
}
}
if err := d.read(); err != nil {
return 0, err
}
}
}
func (d *Decoder) byte() (byte, error) {
if d.head == d.tail {
err := d.read()
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
if err != nil {
return 0, err
}
}
c := d.buf[d.head]
d.head++
return c, nil
}
func (d *Decoder) read() error {
if d.reader == nil {
d.head = d.tail
return io.EOF
}
n, err := d.reader.Read(d.buf)
if err != nil {
return err
}
d.head = 0
d.tail = n
return nil
}
func (d *Decoder) readAtLeast(min int) error {
if d.reader == nil {
d.head = d.tail
return io.ErrUnexpectedEOF
}
if need := min - len(d.buf); need > 0 {
d.buf = append(d.buf, make([]byte, need)...)
}
n, err := io.ReadAtLeast(d.reader, d.buf, min)
if err != nil {
if err == io.EOF && n == 0 {
return io.ErrUnexpectedEOF
}
return err
}
d.head = 0
d.tail = n
return nil
}
func (d *Decoder) unread() { d.head-- }
func (d *Decoder) readExact4(b *[4]byte) error {
if buf := d.buf[d.head:d.tail]; len(buf) >= len(b) {
d.head += copy(b[:], buf[:4])
return nil
}
n := copy(b[:], d.buf[d.head:d.tail])
if err := d.readAtLeast(len(b) - n); err != nil {
return err
}
d.head += copy(b[n:], d.buf[d.head:d.tail])
return nil
}
func findInvalidToken4(buf [4]byte, mask uint32) error {
c := uint32(buf[0]) | uint32(buf[1])<<8 | uint32(buf[2])<<16 | uint32(buf[3])<<24
idx := bits.TrailingZeros32(c^mask) / 8
return badToken(buf[idx])
}

472
vendor/github.com/go-faster/jx/dec_skip.go generated vendored

@ -0,0 +1,472 @@ @@ -0,0 +1,472 @@
package jx
import (
"io"
"github.com/go-faster/errors"
)
// Skip skips a json object and positions to relatively the next json object.
func (d *Decoder) Skip() error {
c, err := d.next()
if err != nil {
return err
}
switch c {
case '"':
if err := d.skipStr(); err != nil {
return errors.Wrap(err, "str")
}
return nil
case 'n':
d.unread()
return d.Null()
case 't', 'f':
d.unread()
_, err := d.Bool()
return err
case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
d.unread()
return d.skipNumber()
case '[':
if err := d.skipArr(); err != nil {
return errors.Wrap(err, "array")
}
return nil
case '{':
if err := d.skipObj(); err != nil {
return errors.Wrap(err, "object")
}
return nil
default:
return badToken(c)
}
}
var (
skipNumberSet = [256]byte{
'0': 1,
'1': 1,
'2': 1,
'3': 1,
'4': 1,
'5': 1,
'6': 1,
'7': 1,
'8': 1,
'9': 1,
',': 2,
']': 2,
'}': 2,
' ': 2,
'\t': 2,
'\n': 2,
'\r': 2,
}
)
// skipNumber reads one JSON number.
//
// Assumes d.buf is not empty.
func (d *Decoder) skipNumber() error {
const (
digitTag byte = 1
closerTag byte = 2
)
c := d.buf[d.head]
d.head++
switch c {
case '-':
c, err := d.byte()
if err != nil {
return err
}
// Character after '-' must be a digit.
if skipNumberSet[c] != digitTag {
return badToken(c)
}
if c != '0' {
break
}
fallthrough
case '0':
// If buffer is empty, try to read more.
if d.head == d.tail {
err := d.read()
if err != nil {
// There is no data anymore.
if err == io.EOF {
return nil
}
return err
}
}
c = d.buf[d.head]
if skipNumberSet[c] == closerTag {
return nil
}
switch c {
case '.':
goto stateDot
case 'e', 'E':
goto stateExp
default:
return badToken(c)
}
}
for {
for i, c := range d.buf[d.head:d.tail] {
switch skipNumberSet[c] {
case closerTag:
d.head += i
return nil
case digitTag:
continue
}
switch c {
case '.':
d.head += i
goto stateDot
case 'e', 'E':
d.head += i
goto stateExp
default:
return badToken(c)
}
}
if err := d.read(); err != nil {
// There is no data anymore.
if err == io.EOF {
d.head = d.tail
return nil
}
return err
}
}
stateDot:
d.head++
{
var last byte = '.'
for {
for i, c := range d.buf[d.head:d.tail] {
switch skipNumberSet[c] {
case closerTag:
d.head += i
// Check that dot is not last character.
if last == '.' {
return io.ErrUnexpectedEOF
}
return nil
case digitTag:
last = c
continue
}
switch c {
case 'e', 'E':
if last == '.' {
return badToken(c)
}
d.head += i
goto stateExp
default:
return badToken(c)
}
}
if err := d.read(); err != nil {
// There is no data anymore.
if err == io.EOF {
d.head = d.tail
// Check that dot is not last character.
if last == '.' {
return io.ErrUnexpectedEOF
}
return nil
}
return err
}
}
}
stateExp:
d.head++
// There must be a number or sign after e.
{
numOrSign, err := d.byte()
if err != nil {
return err
}
if skipNumberSet[numOrSign] != digitTag { // If next character is not a digit, check for sign.
if numOrSign == '-' || numOrSign == '+' {
num, err := d.byte()
if err != nil {
return err
}
// There must be a number after sign.
if skipNumberSet[num] != digitTag {
return badToken(num)
}
} else {
return badToken(numOrSign)
}
}
}
for {
for i, c := range d.buf[d.head:d.tail] {
if skipNumberSet[c] == closerTag {
d.head += i
return nil
}
if skipNumberSet[c] == 0 {
return badToken(c)
}
}
if err := d.read(); err != nil {
// There is no data anymore.
if err == io.EOF {
d.head = d.tail
return nil
}
return err
}
}
}
var (
escapedStrSet = [256]byte{
'"': '"',
'\\': '\\',
'/': '/',
'b': '\b',
'f': '\f',
'n': '\n',
'r': '\r',
't': '\t',
'u': 'u',
}
hexSet = [256]byte{
'0': 0x0 + 1, '1': 0x1 + 1, '2': 0x2 + 1, '3': 0x3 + 1,
'4': 0x4 + 1, '5': 0x5 + 1, '6': 0x6 + 1, '7': 0x7 + 1,
'8': 0x8 + 1, '9': 0x9 + 1,
'A': 0xA + 1, 'B': 0xB + 1, 'C': 0xC + 1, 'D': 0xD + 1,
'E': 0xE + 1, 'F': 0xF + 1,
'a': 0xa + 1, 'b': 0xb + 1, 'c': 0xc + 1, 'd': 0xd + 1,
'e': 0xe + 1, 'f': 0xf + 1,
}
)
// skipStr reads one JSON string.
//
// Assumes first quote was consumed.
func (d *Decoder) skipStr() error {
var (
c byte
i int
)
readStr:
for {
i = 0
buf := d.buf[d.head:d.tail]
for len(buf) >= 8 {
c = buf[0]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[1]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[2]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[3]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[4]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[5]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[6]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[7]
if safeSet[c] != 0 {
goto readTok
}
i++
buf = buf[8:]
}
var n int
for n, c = range buf {
if safeSet[c] != 0 {
i += n
goto readTok
}
}
if err := d.read(); err != nil {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return err
}
}
readTok:
; // Bug in cover tool, see https://github.com/golang/go/issues/28319.
switch {
case c == '"':
d.head += i + 1
return nil
case c == '\\':
d.head += i + 1
v, err := d.byte()
if err != nil {
return err
}
switch escapedStrSet[v] {
case 'u':
for i := 0; i < 4; i++ {
h, err := d.byte()
if err != nil {
return err
}
if hexSet[h] == 0 {
return badToken(h)
}
}
case 0:
return badToken(v)
}
case c < ' ':
return badToken(c)
}
goto readStr
}
// skipObj reads JSON object.
//
// Assumes first bracket was consumed.
func (d *Decoder) skipObj() error {
if err := d.incDepth(); err != nil {
return errors.Wrap(err, "inc")
}
c, err := d.more()
if err != nil {
return errors.Wrap(err, "next")
}
switch c {
case '}':
return d.decDepth()
case '"':
d.unread()
default:
return badToken(c)
}
for {
if err := d.consume('"'); err != nil {
return err
}
if err := d.skipStr(); err != nil {
return errors.Wrap(err, "read field name")
}
if err := d.consume(':'); err != nil {
return errors.Wrap(err, "field")
}
if err := d.Skip(); err != nil {
return err
}
c, err := d.more()
if err != nil {
return errors.Wrap(err, "read comma")
}
switch c {
case ',':
continue
case '}':
return d.decDepth()
default:
return badToken(c)
}
}
}
// skipArr reads JSON array.
//
// Assumes first bracket was consumed.
func (d *Decoder) skipArr() error {
if err := d.incDepth(); err != nil {
return errors.Wrap(err, "inc")
}
c, err := d.more()
if err != nil {
return errors.Wrap(err, "next")
}
if c == ']' {
return d.decDepth()
}
d.unread()
for {
if err := d.Skip(); err != nil {
return err
}
c, err := d.more()
if err != nil {
return errors.Wrap(err, "read comma")
}
switch c {
case ',':
continue
case ']':
return d.decDepth()
default:
return badToken(c)
}
}
}
// skipSpace skips space characters.
//
// Returns io.ErrUnexpectedEOF if got io.EOF.
func (d *Decoder) skipSpace() error {
// Skip space.
if _, err := d.more(); err != nil {
return err
}
d.unread()
return nil
}

324
vendor/github.com/go-faster/jx/dec_str.go generated vendored

@ -0,0 +1,324 @@ @@ -0,0 +1,324 @@
package jx
import (
"fmt"
"io"
"unicode/utf16"
"unicode/utf8"
"github.com/go-faster/errors"
)
// StrAppend reads string and appends it to byte slice.
func (d *Decoder) StrAppend(b []byte) ([]byte, error) {
v := value{
buf: b,
raw: false,
}
var err error
if v, err = d.str(v); err != nil {
return b, err
}
return v.buf, nil
}
type value struct {
buf []byte
raw bool // false forces buf reuse
}
func (v value) rune(r rune) value {
return value{
buf: appendRune(v.buf, r),
raw: v.raw,
}
}
// badTokenErr means that Token was unexpected while decoding.
type badTokenErr struct {
Token byte
}
func (e badTokenErr) Error() string {
return fmt.Sprintf("unexpected byte %d '%s'", e.Token, []byte{e.Token})
}
func badToken(c byte) error {
return badTokenErr{Token: c}
}
func (d *Decoder) str(v value) (value, error) {
if err := d.consume('"'); err != nil {
return value{}, errors.Wrap(err, "start")
}
var (
c byte
i int
)
for {
buf := d.buf[d.head:d.tail]
for len(buf) >= 8 {
c = buf[0]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[1]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[2]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[3]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[4]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[5]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[6]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[7]
if safeSet[c] != 0 {
goto readTok
}
i++
buf = buf[8:]
}
var n int
for n, c = range buf {
if safeSet[c] != 0 {
i += n
goto readTok
}
}
return d.strSlow(v)
}
readTok:
buf := d.buf[d.head:d.tail]
str := buf[:i]
switch {
case c == '"':
// Skip string + last quote.
d.head += i + 1
if v.raw {
return value{buf: str}, nil
}
return value{buf: append(v.buf, str...)}, nil
case c == '\\':
// Skip only string, keep quote in buffer.
d.head += i
// We need a copy anyway, because string is escaped.
return d.strSlow(value{buf: append(v.buf, str...)})
default:
return v, badToken(c)
}
}
func (d *Decoder) strSlow(v value) (value, error) {
var (
c byte
i int
)
readStr:
for {
i = 0
buf := d.buf[d.head:d.tail]
for len(buf) >= 8 {
c = buf[0]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[1]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[2]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[3]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[4]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[5]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[6]
if safeSet[c] != 0 {
goto readTok
}
i++
c = buf[7]
if safeSet[c] != 0 {
goto readTok
}
i++
buf = buf[8:]
}
for _, c = range buf {
if safeSet[c] != 0 {
goto readTok
}
i++
}
v.buf = append(v.buf, d.buf[d.head:d.head+i]...)
if err := d.read(); err != nil {
if err == io.EOF {
return value{}, io.ErrUnexpectedEOF
}
return value{}, err
}
}
readTok:
buf := d.buf[d.head:d.tail]
str := buf[:i]
d.head += i + 1
switch {
case c == '"':
return value{buf: append(v.buf, str...)}, nil
case c == '\\':
v.buf = append(v.buf, str...)
c, err := d.byte()
if err != nil {
return value{}, errors.Wrap(err, "next")
}
v, err = d.escapedChar(v, c)
if err != nil {
return v, errors.Wrap(err, "escape")
}
default:
return v, badToken(c)
}
goto readStr
}
// StrBytes returns string value as sub-slice of internal buffer.
//
// Bytes are valid only until next call to any Decoder method.
func (d *Decoder) StrBytes() ([]byte, error) {
v, err := d.str(value{raw: true})
if err != nil {
return nil, err
}
return v.buf, nil
}
// Str reads string.
func (d *Decoder) Str() (string, error) {
s, err := d.StrBytes()
if err != nil {
return "", err
}
return string(s), nil
}
func (d *Decoder) escapedChar(v value, c byte) (value, error) {
switch val := escapedStrSet[c]; val {
default:
v.buf = append(v.buf, val)
case 'u':
r1, err := d.readU4()
if err != nil {
return value{}, errors.Wrap(err, "read u4")
}
if utf16.IsSurrogate(r1) {
c, err := d.byte()
if err != nil {
return value{}, err
}
if c != '\\' {
d.unread()
return v.rune(r1), nil
}
c, err = d.byte()
if err != nil {
return value{}, err
}
if c != 'u' {
return d.escapedChar(v.rune(r1), c)
}
r2, err := d.readU4()
if err != nil {
return value{}, err
}
combined := utf16.DecodeRune(r1, r2)
if combined == '\uFFFD' {
v = v.rune(r1).rune(r2)
} else {
v = v.rune(combined)
}
} else {
v = v.rune(r1)
}
case 0:
return v, errors.Wrap(badToken(c), "bad escape: %w")
}
return v, nil
}
func (d *Decoder) readU4() (v rune, _ error) {
var b [4]byte
if err := d.readExact4(&b); err != nil {
return 0, err
}
for _, c := range b {
val := hexSet[c]
if val == 0 {
return 0, badToken(c)
}
v = v*16 + rune(val-1)
}
return v, nil
}
func appendRune(p []byte, r rune) []byte {
buf := make([]byte, 4)
n := utf8.EncodeRune(buf, r)
return append(p, buf[:n]...)
}

22
vendor/github.com/go-faster/jx/dec_validate.go generated vendored

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
package jx
import (
"io"
"github.com/go-faster/errors"
)
// Validate consumes all input, validating that input is a json object
// without any trialing data.
func (d *Decoder) Validate() error {
// First encountered value skip should consume all buffer.
if err := d.Skip(); err != nil {
return errors.Wrap(err, "consume")
}
// Check for any trialing json.
if err := d.Skip(); err != io.EOF {
return errors.Wrap(err, "unexpected trialing data")
}
return nil
}

199
vendor/github.com/go-faster/jx/enc.go generated vendored

@ -0,0 +1,199 @@ @@ -0,0 +1,199 @@
package jx
import "io"
// Encoder encodes json to underlying buffer.
//
// Zero value is valid.
type Encoder struct {
w Writer // underlying writer
indent int // count of spaces for single indentation level
// first handles state for comma and indentation writing.
//
// New Object or Array appends new level to this slice, and
// last element of this slice denotes whether first element was written.
//
// We write commas only before non-first element of Array or Object.
//
// See comma, begin, end and FieldStart for implementation details.
//
// Note: probably, this can be optimized as bit set to ease memory
// consumption.
//
// See https://yourbasic.org/algorithms/your-basic-int/#simple-sets
first []bool
}
// Write implements io.Writer.
func (e *Encoder) Write(p []byte) (n int, err error) {
return e.w.Write(p)
}
// WriteTo implements io.WriterTo.
func (e *Encoder) WriteTo(w io.Writer) (n int64, err error) {
return e.w.WriteTo(w)
}
// SetIdent sets length of single indentation step.
func (e *Encoder) SetIdent(n int) {
e.indent = n
}
// String returns string of underlying buffer.
func (e Encoder) String() string {
return string(e.Bytes())
}
// Reset resets underlying buffer.
func (e *Encoder) Reset() {
e.w.Buf = e.w.Buf[:0]
e.first = e.first[:0]
}
// Bytes returns underlying buffer.
func (e Encoder) Bytes() []byte { return e.w.Buf }
// SetBytes sets underlying buffer.
func (e *Encoder) SetBytes(buf []byte) { e.w.Buf = buf }
// byte writes a single byte.
func (e *Encoder) byte(c byte) {
e.w.Buf = append(e.w.Buf, c)
}
// RawStr writes string as raw json.
func (e *Encoder) RawStr(v string) {
e.comma()
e.w.RawStr(v)
}
// Raw writes byte slice as raw json.
func (e *Encoder) Raw(b []byte) {
e.comma()
e.w.Raw(b)
}
// Null writes null.
func (e *Encoder) Null() {
e.comma()
e.w.Null()
}
// Bool encodes boolean.
func (e *Encoder) Bool(v bool) {
e.comma()
e.w.Bool(v)
}
// ObjStart writes object start, performing indentation if needed.
//
// Use Obj as convenience helper for writing objects.
func (e *Encoder) ObjStart() {
e.comma()
e.w.ObjStart()
e.begin()
e.writeIndent()
}
// FieldStart encodes field name and writes colon.
//
// For non-zero indentation also writes single space after colon.
//
// Use Field as convenience helper for encoding fields.
func (e *Encoder) FieldStart(field string) {
e.comma()
e.w.FieldStart(field)
if e.indent > 0 {
e.byte(' ')
}
if len(e.first) > 0 {
e.first[e.current()] = true
}
}
// Field encodes field start and then invokes callback.
//
// Has ~5ns overhead over FieldStart.
func (e *Encoder) Field(name string, f func(e *Encoder)) {
e.FieldStart(name)
f(e)
}
// ObjEnd writes end of object token, performing indentation if needed.
//
// Use Obj as convenience helper for writing objects.
func (e *Encoder) ObjEnd() {
e.end()
e.writeIndent()
e.w.ObjEnd()
}
// ObjEmpty writes empty object.
func (e *Encoder) ObjEmpty() {
e.comma()
e.w.ObjStart()
e.w.ObjEnd()
}
// Obj writes start of object, invokes callback and writes end of object.
//
// If callback is nil, writes empty object.
func (e *Encoder) Obj(f func(e *Encoder)) {
if f == nil {
e.ObjEmpty()
return
}
e.ObjStart()
f(e)
e.ObjEnd()
}
// ArrStart writes start of array, performing indentation if needed.
//
// Use Arr as convenience helper for writing arrays.
func (e *Encoder) ArrStart() {
e.comma()
e.w.ArrStart()
e.begin()
e.writeIndent()
}
// ArrEmpty writes empty array.
func (e *Encoder) ArrEmpty() {
e.comma()
e.w.ArrStart()
e.w.ArrEnd()
}
// ArrEnd writes end of array, performing indentation if needed.
//
// Use Arr as convenience helper for writing arrays.
func (e *Encoder) ArrEnd() {
e.end()
e.writeIndent()
e.w.ArrEnd()
}
// Arr writes start of array, invokes callback and writes end of array.
//
// If callback is nil, writes empty array.
func (e *Encoder) Arr(f func(e *Encoder)) {
if f == nil {
e.ArrEmpty()
return
}
e.ArrStart()
f(e)
e.ArrEnd()
}
func (e *Encoder) writeIndent() {
if e.indent == 0 {
return
}
e.byte('\n')
for i := 0; i < len(e.first)*e.indent; i++ {
e.w.Buf = append(e.w.Buf, ' ')
}
}

9
vendor/github.com/go-faster/jx/enc_b64.go generated vendored

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
package jx
// Base64 encodes data as standard base64 encoded string.
//
// Same as encoding/json, base64.StdEncoding or RFC 4648.
func (e *Encoder) Base64(data []byte) {
e.comma()
e.w.Base64(data)
}

34
vendor/github.com/go-faster/jx/enc_comma.go generated vendored

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
package jx
// begin should be called before new Array or Object.
func (e *Encoder) begin() {
e.first = append(e.first, true)
}
// end should be called after Array or Object.
func (e *Encoder) end() {
if len(e.first) == 0 {
return
}
e.first = e.first[:e.current()]
}
func (e *Encoder) current() int { return len(e.first) - 1 }
// comma should be called before any new value.
func (e *Encoder) comma() {
// Writing commas.
// 1. Before every field expect first.
// 2. Before every array element except first.
if len(e.first) == 0 {
return
}
current := e.current()
_ = e.first[current]
if e.first[current] {
e.first[current] = false
return
}
e.byte(',')
e.writeIndent()
}

17
vendor/github.com/go-faster/jx/enc_float.go generated vendored

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
package jx
// Float32 encodes float32.
//
// NB: Infinities and NaN are represented as null.
func (e *Encoder) Float32(v float32) {
e.comma()
e.w.Float32(v)
}
// Float64 encodes float64.
//
// NB: Infinities and NaN are represented as null.
func (e *Encoder) Float64(v float64) {
e.comma()
e.w.Float64(v)
}

25
vendor/github.com/go-faster/jx/enc_int.go generated vendored

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
package jx
// Int encodes int.
func (e *Encoder) Int(v int) {
e.comma()
e.w.Int(v)
}
// UInt encodes uint.
func (e *Encoder) UInt(v uint) {
e.comma()
e.w.UInt(v)
}
// UInt8 encodes uint8.
func (e *Encoder) UInt8(v uint8) {
e.comma()
e.w.UInt8(v)
}
// Int8 encodes int8.
func (e *Encoder) Int8(v int8) {
e.comma()
e.w.Int8(v)
}

7
vendor/github.com/go-faster/jx/enc_num.go generated vendored

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
package jx
// Num encodes number.
func (e *Encoder) Num(v Num) {
e.comma()
e.w.Num(v)
}

16
vendor/github.com/go-faster/jx/enc_str.go generated vendored

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
package jx
// StrEscape encodes string with html special characters escaping.
func (e *Encoder) StrEscape(v string) {
e.comma()
e.w.StrEscape(v)
}
// Str encodes string without html escaping.
//
// Use StrEscape to escape html, this is default for encoding/json and
// should be used by default for untrusted strings.
func (e *Encoder) Str(v string) {
e.comma()
e.w.Str(v)
}

19
vendor/github.com/go-faster/jx/fuzz.go generated vendored

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
//go:build gofuzz
// +build gofuzz
package jx
import (
"encoding/json"
"fmt"
)
func Fuzz(data []byte) int {
got := Valid(data)
exp := json.Valid(data)
if !exp && got {
fmt.Printf("jx: %v\nencoding/json:%v\n", got, exp)
panic("mismatch")
}
return 1
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save