Compare commits

...

112 Commits

Author SHA1 Message Date
Kevin Wan
731b3ebf6f Update readme-cn.md 2022-08-07 16:11:43 +08:00
Kevin Wan
1e0f94ba86 Update readme.md 2022-08-07 16:11:27 +08:00
Kevin Wan
a987512c7b feat: more meaningful error messages, close body on httpc requests (#2238)
* feat: more meaningful error messages, close body on httpc requests

* fix: test failure
2022-08-07 16:09:54 +08:00
Kevin Wan
c1c7584de1 Update readme.md 2022-08-07 16:08:16 +08:00
Kevin Wan
98b9a25cc7 Update readme.md 2022-08-07 11:13:34 +08:00
Kevin Wan
a8305def3d docs: update docs for gateway (#2236) 2022-08-07 11:11:46 +08:00
Kevin Wan
d20d8324e7 fix: #2216 (#2235) 2022-08-06 17:48:59 +08:00
Kevin Wan
c638fce31c chore: renaming configs (#2234) 2022-08-06 16:32:12 +08:00
dependabot[bot]
34294702b0 chore(deps): bump go.mongodb.org/mongo-driver from 1.10.0 to 1.10.1 (#2225) 2022-08-04 20:25:56 +08:00
chen quan
4fad067a0e fix(logx): need to wait for the first caller to complete the execution. (#2213) 2022-08-03 23:59:39 +08:00
safeoy
3f3c811e08 fix: fix comment typo (#2220)
Use an instead of 'a' if the following word starts with a vowel sound, e.g. 'an in-memory cache'.
2022-08-03 23:57:49 +08:00
dependabot[bot]
dbdbb68676 chore(deps): bump go.opentelemetry.io/otel/exporters/zipkin (#2222)
Bumps [go.opentelemetry.io/otel/exporters/zipkin](https://github.com/open-telemetry/opentelemetry-go) from 1.8.0 to 1.9.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.8.0...v1.9.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/zipkin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
2022-08-03 23:56:22 +08:00
dependabot[bot]
83772344b0 chore(deps): bump go.opentelemetry.io/otel/exporters/jaeger (#2223)
Bumps [go.opentelemetry.io/otel/exporters/jaeger](https://github.com/open-telemetry/opentelemetry-go) from 1.8.0 to 1.9.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.8.0...v1.9.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/jaeger
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-03 23:41:46 +08:00
Kevin Wan
49367f1713 fix: handling rpc error on gateway (#2212) 2022-08-01 00:01:24 +08:00
Kevin Wan
91b8effb24 chore: refactor redislock (#2210)
* chore: refactor redislock

* chore: add more tests
2022-07-30 19:46:10 +08:00
cong
4879d4dfcd feat(redislock): support set context (#2208)
* feat(redislock): support set context

* chore: fix test
2022-07-30 18:38:36 +08:00
dependabot[bot]
b18479dd43 chore(deps): bump google.golang.org/protobuf from 1.28.0 to 1.28.1 (#2205)
Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.28.0 to 1.28.1.
- [Release notes](https://github.com/protocolbuffers/protobuf-go/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash)
- [Commits](https://github.com/protocolbuffers/protobuf-go/compare/v1.28.0...v1.28.1)

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-29 23:53:35 +08:00
Kevin Wan
5cd9229986 fix: only setup logx once (#2188)
* fix: only setup logx once

* fix: test failure

* chore: not reset logging level in reset

* chore: refactoring
2022-07-28 22:08:48 +08:00
施国鹏
3d38d36605 fix: logx test foo (#2144)
constant testlog "Stay hungry, stay foolish." contains foo(foolish), changed to foo1
2022-07-28 21:29:56 +08:00
chen quan
003adae51f fix(httpc): fix typo errors (#2189) 2022-07-27 09:11:15 +08:00
马守越
5348375b99 support mulitple protoset files (#2190) 2022-07-27 09:10:23 +08:00
benqi
5d7919a9f5 fix: remove invalid log fields in notLoggingContentMethods (#2187) 2022-07-24 22:18:04 +08:00
Kevin Wan
9b334b5428 chore: let logx.SetWriter can be called anytime (#2186) 2022-07-24 14:15:57 +08:00
fisnone
685d14e662 fix:duplicate route check (#2154)
Co-authored-by: 黄志荣 <huangzhirong@shuinfo.com>
2022-07-24 10:48:50 +08:00
benqi
edbf1a3b63 fix: fix switch doesn't work bug (#2183) 2022-07-23 12:15:37 +08:00
Kevin Wan
92145b56dc chore: refactoring (#2182) 2022-07-22 23:16:38 +08:00
Kevin Wan
34eb3fc12e chore: refactoring logx (#2181) 2022-07-22 22:28:01 +08:00
SgtDaJim
101304be53 feat: logx support logs rotation based on size limitation. (#1652) (#2167)
* feat: logx support logs rotation based on size limitation. (#1652)

implementation of #1652

Totally compatible with the old logx.LogConf. No effect if users do not change their options.

* feat: logx support logs rotation based on size limitation. (#1652)

implementation of #1652

Totally compatible with the old logx.LogConf. No effect if users do not change their options.

* feat: logx support logs rotation based on size limitation. (#1652)

implementation of #1652

Totally compatible with the old logx.LogConf. No effect if users do not change their options.

* feat: logx support logs rotation based on size limitation. (#1652)

implementation of #1652

Totally compatible with the old logx.LogConf. No effect if users do not change their options.
2022-07-22 21:13:10 +08:00
anqiansong
f630bc735b Update goctl version (#2178) 2022-07-21 15:29:50 +08:00
anqiansong
ca3c687f1c feat: Support for multiple rpc service generation and rpc grouping (#1972)
* Add group & compatible flag

* Add group & compatible flag

* Support for multiple rpc service generation and rpc grouping

* Support for multiple rpc service generation and rpc grouping

* Format code

* Format code

* Add comments

* Fix unit test

* Refactor function name

* Add example & Update grpc readme

* go mod tidy

* update mod

* update mod
2022-07-21 12:47:46 +08:00
anqiansong
1b51d0ce82 fix: fix #2102, #2108 (#2131)
* g4 code generation

* Update grammar

* g4 code generation

* fix #2108

* fix #2102

* Remove comments
2022-07-20 22:49:41 +08:00
Kevin Wan
d9218e1551 Update readme-cn.md
add go-zero users.
2022-07-20 09:40:32 +08:00
anqiansong
9c448c64ef Update api template (#2172) 2022-07-19 23:49:20 +08:00
杨圆建
bc85eaa9b1 fix: goctl genhandler duplicate rest/httpx & goctl genhandler template support custom import httpx package (#2152) 2022-07-19 23:24:47 +08:00
Kevin Wan
2a6f801978 chore: refactoring mapping name (#2168) 2022-07-19 09:58:46 +08:00
Kevin Wan
8d567b5508 feat: support customized header to metadata processor (#2162)
* chore: add more tests

* feat: support customized header processor
2022-07-17 23:21:19 +08:00
Kevin Wan
0dd2768d09 feat: support google.api.http in gateway (#2161) 2022-07-17 14:57:25 +08:00
Kevin Wan
4324ddc024 feat: set content-type to application/json (#2160) 2022-07-17 13:52:46 +08:00
Kevin Wan
557383fbbf feat: verify RpcPath on startup (#2159)
* feat: verify RpcPath on startup

* feat: support http header Grpc-Timeout
2022-07-17 12:37:23 +08:00
Kevin Wan
b206dd28a3 feat: support form values in gateway (#2158) 2022-07-16 23:40:53 +08:00
Kevin Wan
453fa309b1 feat: export gateway.Server to let users add middlewares (#2157) 2022-07-16 22:59:25 +08:00
Kevin Wan
4d7dae9cea Update readme-cn.md 2022-07-16 14:53:00 +08:00
Kevin Wan
d228b9038d Update readme.md 2022-07-16 14:52:45 +08:00
Kevin Wan
13477238a3 feat: restful -> grpc gateway (#2155)
* Revert "chore: remove unimplemented gateway (#2139)"

This reverts commit d70e73ec66.

* feat: working gateway

* feat: use mr to make it faster

* feat: working gateway

* chore: add comments

* feat: support protoset besides reflection

* feat: support zrpc client conf

* docs: update readme

* feat: support grpc-metadata- header to gateway- header conversion

* chore: add docs
2022-07-16 14:11:34 +08:00
dependabot[bot]
95a574e9e9 chore(deps): bump google.golang.org/grpc from 1.47.0 to 1.48.0 (#2147)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.47.0 to 1.48.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.47.0...v1.48.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-15 10:02:25 +08:00
dependabot[bot]
453100e0e2 chore(deps): bump go.mongodb.org/mongo-driver from 1.9.1 to 1.10.0 (#2150)
Bumps [go.mongodb.org/mongo-driver](https://github.com/mongodb/mongo-go-driver) from 1.9.1 to 1.10.0.
- [Release notes](https://github.com/mongodb/mongo-go-driver/releases)
- [Commits](https://github.com/mongodb/mongo-go-driver/compare/v1.9.1...v1.10.0)

---
updated-dependencies:
- dependency-name: go.mongodb.org/mongo-driver
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-15 10:02:08 +08:00
Kevin Wan
d70e73ec66 chore: remove unimplemented gateway (#2139) 2022-07-13 21:55:19 +08:00
Kevin Wan
300b124e42 docs: update goctl readme (#2136) 2022-07-12 23:16:40 +08:00
Kevin Wan
3bad043413 chore: refactor (#2130) 2022-07-11 23:50:50 +08:00
Kevin Wan
23f34234d0 chore: add more tests (#2129) 2022-07-11 23:32:57 +08:00
虫子樱桃
d71b3c841f feat:Add Routes method for server (#2125)
Co-authored-by: czyt <czyt@w.cn>
2022-07-11 23:23:38 +08:00
Kevin Wan
24787a946b feat: support logx.WithFields (#2128) 2022-07-11 23:19:26 +08:00
Richard Yi
6e50c87dca fix: generated sql query fields do not match template (#2004)
* Fix typo

* Match generated sql query fields with template
2022-07-11 23:06:00 +08:00
Kevin Wan
e672b3f8e1 feat: add Wrap and Wrapf in errorx (#2126) 2022-07-11 23:04:38 +08:00
Kevin Wan
1c09db6d5d chore: coding style (#2120) 2022-07-10 11:05:21 +08:00
LeeDF
96acf1f5a6 fix goctl rpc protoc strings.EqualFold Service.Name GoPackage (#2046) 2022-07-09 23:40:32 +08:00
Kevin Wan
97a171441d chore: remove blank lines (#2117)
* chore: remove blank lines

* chore: refactor
2022-07-09 15:59:25 +08:00
虫子樱桃
725e6056e1 feat:goctl model mongo add easy flag for easy declare. (#2073)
* fix:typo in readme.md

* feat:`goctl model mongo ` add `easy` flag to generate code with Auto generated CollectionName for easy declare.

* fix:`goctl api doc ` when referenced api file contains no route,will generate an empty markdown file.

* code: adjust code.

Co-authored-by: 虫子樱桃 <czyt@w.cn>
2022-07-09 15:34:01 +08:00
Kevin Wan
1410f7dc20 fix #2109 (#2116) 2022-07-09 15:05:59 +08:00
warrior
8afe68f3f1 refactor:remove duplicate codes (#2101)
Co-authored-by: 沈四胜 <sisheng.shen@71360.com>
2022-07-09 14:56:49 +08:00
dependabot[bot]
74c41e8c5e chore(deps): bump go.opentelemetry.io/otel/exporters/jaeger (#2115)
Bumps [go.opentelemetry.io/otel/exporters/jaeger](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/jaeger
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
2022-07-09 14:42:16 +08:00
Minghong Fang
48f7e01158 feat: add method to jsonx (#2049) 2022-07-09 14:20:53 +08:00
dependabot[bot]
f6f6ee5c8c chore(deps): bump go.opentelemetry.io/otel/exporters/zipkin (#2112)
Bumps [go.opentelemetry.io/otel/exporters/zipkin](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/zipkin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-09 14:16:08 +08:00
Kevin Wan
b364c54940 chore: update goctl version to 1.3.9 (#2111) 2022-07-08 22:31:50 +08:00
Kevin Wan
e0e3f97c7c chore: refactor (#2087) 2022-07-02 14:03:11 +08:00
taobig
6a2d6786c6 remove legacy code (#2086) 2022-07-02 00:22:42 +08:00
Kevin Wan
18035bd4d4 chore: refactor (#2085) 2022-07-02 00:15:38 +08:00
家福
f3b8fef34f fix: type matching supports string to int (#2038)
* fix: type matching supports string to int

* feat: type matching supports string to int

Co-authored-by: 程家福 <chengjiafu@uniontech.com>
2022-07-01 23:21:31 +08:00
givemeafish
6a4885ba64 fix concurrent map writes (#2079)
Co-authored-by: wero <wero@werodeMacBook-Pro.local>
2022-07-01 23:07:25 +08:00
Kevin Wan
f2cef2b963 Update readme-cn.md 2022-07-01 23:00:19 +08:00
taobig
bfd0869ee2 remove legacy code (#2084) 2022-07-01 22:41:16 +08:00
Kevin Wan
4e26e0407e Update readme.md 2022-07-01 22:17:05 +08:00
wxc
d200ba4a7b feat: CompareAndSwapInt32 may be better than AddInt32 (#2077) 2022-07-01 12:41:32 +08:00
dependabot[bot]
ce7e2a2a9a chore(deps): bump github.com/pelletier/go-toml/v2 from 2.0.1 to 2.0.2 (#2072)
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.1 to 2.0.2.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.1...v2.0.2)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-30 23:27:53 +08:00
taobig
c92400ead2 fix 当表有唯一键时,update()的形参和实参不一致 (#2010) 2022-06-30 23:25:54 +08:00
dependabot[bot]
0b109c1954 chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.4.1 to 4.4.2 (#2066)
Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.4.1 to 4.4.2.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v4.4.1...v4.4.2)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-30 00:21:08 +08:00
dependabot[bot]
d42979f705 chore(deps): bump github.com/stretchr/testify from 1.7.2 to 1.8.0 (#2068)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.2 to 1.8.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.2...v1.8.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-29 22:08:01 +08:00
dependabot[bot]
29d81381c1 chore(deps): bump github.com/alicebob/miniredis/v2 from 2.21.0 to 2.22.0 (#2067)
Bumps [github.com/alicebob/miniredis/v2](https://github.com/alicebob/miniredis) from 2.21.0 to 2.22.0.
- [Release notes](https://github.com/alicebob/miniredis/releases)
- [Changelog](https://github.com/alicebob/miniredis/blob/master/CHANGELOG.md)
- [Commits](https://github.com/alicebob/miniredis/compare/v2.21.0...v2.22.0)

---
updated-dependencies:
- dependency-name: github.com/alicebob/miniredis/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-29 21:53:02 +08:00
dependabot[bot]
89f6c97097 chore(deps): bump github.com/ClickHouse/clickhouse-go/v2 (#2064)
Bumps [github.com/ClickHouse/clickhouse-go/v2](https://github.com/ClickHouse/clickhouse-go) from 2.0.15 to 2.2.0.
- [Release notes](https://github.com/ClickHouse/clickhouse-go/releases)
- [Commits](https://github.com/ClickHouse/clickhouse-go/compare/v2.0.15...v2.2.0)

---
updated-dependencies:
- dependency-name: github.com/ClickHouse/clickhouse-go/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-29 21:52:07 +08:00
Kevin Wan
ff6f109065 Create dependabot.yml
add dependabot.
2022-06-29 21:38:47 +08:00
Zhang.Y
7da77302f4 fix: \u003cnil\u003e log output when http server shutdown. (#2055) 2022-06-29 21:35:01 +08:00
虫子樱桃
76086fc717 fix:typo in readme.md (#2061)
Co-authored-by: 虫子樱桃 <czyt@w.cn>
2022-06-29 19:38:23 +08:00
Kevin Wan
555c4ecd1a fix: quickstart wrong package when go.mod exists in parent dir (#2048)
* chore: fix typo

* fix: quickstart in dir with go.mod

* fix: runner failed

* chore: refine code

* chore: simplify quickstart mono
2022-06-26 22:37:15 +08:00
lord63
630dfa0887 [ci skip] Fix dead doc link (#2047) 2022-06-25 11:18:47 +08:00
Kevin Wan
38cd7b7df0 chore: remove lifecycle preStop because sh not exist in scratch (#2042) 2022-06-24 21:30:07 +08:00
Kevin Wan
9148f8df2a Update readme-cn.md 2022-06-24 20:22:35 +08:00
Kevin Wan
13f051d0e5 Update readme-cn.md 2022-06-22 22:01:00 +08:00
anqiansong
93b3f5030f chore: Add command desc & color commands (#2013)
* Add link & Color sub-commands

* Color sub-commands for unix-like OS

* Remove useless code

* Remove redundant dependency
2022-06-21 20:21:38 +08:00
anqiansong
b44e8f5c75 fix #1977 (#2034) 2022-06-21 20:01:42 +08:00
Kevin Wan
b9eb03e9a9 Update readme.md 2022-06-19 20:50:55 +08:00
Kevin Wan
86b531406b Update readme.md 2022-06-19 20:48:21 +08:00
Kevin Wan
47c49de94e feat: rest.WithChain to replace builtin middlewares (#2033)
* feat: rest.WithChain to replace builtin middlewares

* chore: add comments

* chore: refine code
2022-06-19 17:41:33 +08:00
Kevin Wan
50f16e2892 Update readme-cn.md 2022-06-19 14:22:29 +08:00
Kevin Wan
018ca82048 chore: refactor to simplify disabling builtin middlewares (#2031)
* chore: refactor to simplify disabling builtin middlewares

* chore: rename methods
2022-06-18 20:16:34 +08:00
magickeha
6976ba7e13 add user middleware chain function (#1913)
* add user middleware chain function

* fix staticcheck SA4006

* chang code Implementation style

Co-authored-by: kemq1 <kemq1@spdb.com.cn>
2022-06-18 18:45:47 +08:00
anqiansong
9b6e4c440c Add fig (#2008)
Co-authored-by: SH00414ml <sh00414ml@SH00414mldeMacBook-Pro.local>
2022-06-18 18:34:48 +08:00
Kevin Wan
9eea311a4d feat: support build Dockerfile from current dir (#2021) 2022-06-18 18:32:07 +08:00
chen quan
86d70317bf chore: upgrade action version (#2027) 2022-06-17 19:55:19 +08:00
chen quan
6518eb10b3 feat: add trace in httpc (#2011) 2022-06-17 15:01:14 +08:00
Kevin Wan
0147d7a9d1 Update readme-cn.md 2022-06-14 08:23:46 +08:00
Kevin Wan
1b2b7647d6 chore: coding style (#2012) 2022-06-14 07:25:54 +08:00
Atlan
af6d37c33d fix: 修复 clientinterceptors/tracinginterceptor.go 显示接受消息字节为0 (#2003) 2022-06-14 00:11:10 +08:00
Kevin Wan
3da5c5f530 Update readme.md 2022-06-13 19:39:59 +08:00
Kevin Wan
1694a92db0 Update readme.md 2022-06-13 19:35:51 +08:00
anqiansong
c27e00b45c feat: Replace mongo package with monc & mon (#2002)
* Replace mongo package with monc & mon

* Add terminal whitespace

* format code
2022-06-12 23:02:34 +08:00
Kevin Wan
ed1c937998 feat: convert grpc errors to http status codes (#1997)
* feat: convert grpc errors to http status codes

* chore: circuit break include unimplemented grpc error

* chore: add reference link in comments
2022-06-11 23:07:26 +08:00
Kevin Wan
db9a1f3e27 chore: rename methods (#1998) 2022-06-11 12:34:10 +08:00
马守越
392a390a3f periodlimit new function TakeWithContext (#1983)
Co-authored-by: mashouyue's m1max <mashouyue@toowow.cn>
2022-06-11 12:07:57 +08:00
Gaffey
2a900e1795 typo: add type keyword (#1992) 2022-06-11 11:46:50 +08:00
swliao425
0f5d8c6be3 feat: add 'imagePullPolicy' parameter for 'goctl kube deploy' (#1996) 2022-06-11 09:49:14 +08:00
MarkJoyMa
f2caf9237a fix goctl api clone template fail (#1990) 2022-06-09 23:35:03 +08:00
Kevin Wan
2f0e4e3ebf chore: update dependencies (#1985) 2022-06-09 23:34:06 +08:00
201 changed files with 8762 additions and 3555 deletions

11
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"

View File

@@ -35,11 +35,11 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v2
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file. # If you wish to specify custom queries, you can do so here or in a config file.
@@ -50,7 +50,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below) # If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v1 uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell. # Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl # 📚 https://git.io/JvXDl
@@ -64,4 +64,4 @@ jobs:
# make release # make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 uses: github/codeql-action/analyze@v2

View File

@@ -18,7 +18,7 @@ jobs:
id: go id: go
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Get dependencies - name: Get dependencies
run: | run: |
@@ -46,7 +46,7 @@ jobs:
go-version: ^1.15 go-version: ^1.15
- name: Checkout codebase - name: Checkout codebase
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Test - name: Test
run: | run: |

View File

@@ -16,7 +16,7 @@ jobs:
- goarch: "386" - goarch: "386"
goos: darwin goos: darwin
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: zeromicro/go-zero-release-action@master - uses: zeromicro/go-zero-release-action@master
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -5,7 +5,7 @@ jobs:
name: runner / staticcheck name: runner / staticcheck
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: reviewdog/action-staticcheck@v1 - uses: reviewdog/action-staticcheck@v1
with: with:
github_token: ${{ secrets.github_token }} github_token: ${{ secrets.github_token }}

View File

@@ -26,7 +26,7 @@ type (
// CacheOption defines the method to customize a Cache. // CacheOption defines the method to customize a Cache.
CacheOption func(cache *Cache) CacheOption func(cache *Cache)
// A Cache object is a in-memory cache. // A Cache object is an in-memory cache.
Cache struct { Cache struct {
name string name string
lock sync.Mutex lock sync.Mutex

View File

@@ -3,10 +3,10 @@
1. Define a config structure, like below: 1. Define a config structure, like below:
```go ```go
RestfulConf struct { type RestfulConf struct {
Host string `json:",default=0.0.0.0"` Host string `json:",default=0.0.0.0"`
Port int Port int
LogMode string `json:",options=[file,console]" LogMode string `json:",options=[file,console]"`
Verbose bool `json:",optional"` Verbose bool `json:",optional"`
MaxConns int `json:",default=10000"` MaxConns int `json:",default=10000"`
MaxBytes int64 `json:",default=1048576"` MaxBytes int64 `json:",default=1048576"`
@@ -15,7 +15,9 @@ RestfulConf struct {
} }
``` ```
2. Write the yaml or json config file: 2. Write the yaml, toml or json config file:
- yaml example
```yaml ```yaml
# most fields are optional or have default values # most fields are optional or have default values
@@ -25,6 +27,16 @@ LogMode: console
MaxBytes: ${MAX_BYTES} MaxBytes: ${MAX_BYTES}
``` ```
- toml example
```toml
# most fields are optional or have default values
Port = 8_080
LogMode = "console"
# you can use env settings
MaxBytes = "${MAX_BYTES}"
```
3. Load the config from a file: 3. Load the config from a file:
```go ```go

View File

@@ -191,9 +191,11 @@ func (c *cluster) handleWatchEvents(key string, events []*clientv3.Event) {
}) })
} }
case clientv3.EventTypeDelete: case clientv3.EventTypeDelete:
c.lock.Lock()
if vals, ok := c.values[key]; ok { if vals, ok := c.values[key]; ok {
delete(vals, string(ev.Kv.Key)) delete(vals, string(ev.Kv.Key))
} }
c.lock.Unlock()
for _, l := range listeners { for _, l := range listeners {
l.OnDelete(KV{ l.OnDelete(KV{
Key: string(ev.Kv.Key), Key: string(ev.Kv.Key),

21
core/errorx/wrap.go Normal file
View File

@@ -0,0 +1,21 @@
package errorx
import "fmt"
// Wrap returns an error that wraps err with given message.
func Wrap(err error, message string) error {
if err == nil {
return nil
}
return fmt.Errorf("%s: %w", message, err)
}
// Wrapf returns an error that wraps err with given format and args.
func Wrapf(err error, format string, args ...interface{}) error {
if err == nil {
return nil
}
return fmt.Errorf("%s: %w", fmt.Sprintf(format, args...), err)
}

24
core/errorx/wrap_test.go Normal file
View File

@@ -0,0 +1,24 @@
package errorx
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestWrap(t *testing.T) {
assert.Nil(t, Wrap(nil, "test"))
assert.Equal(t, "foo: bar", Wrap(errors.New("bar"), "foo").Error())
err := errors.New("foo")
assert.True(t, errors.Is(Wrap(err, "bar"), err))
}
func TestWrapf(t *testing.T) {
assert.Nil(t, Wrapf(nil, "%s", "test"))
assert.Equal(t, "foo bar: quz", Wrapf(errors.New("quz"), "foo %s", "bar").Error())
err := errors.New("foo")
assert.True(t, errors.Is(Wrapf(err, "foo %s", "bar"), err))
}

View File

@@ -13,6 +13,16 @@ func Marshal(v interface{}) ([]byte, error) {
return json.Marshal(v) return json.Marshal(v)
} }
// MarshalToString marshals v into a string.
func MarshalToString(v interface{}) (string, error) {
data, err := Marshal(v)
if err != nil {
return "", err
}
return string(data), nil
}
// Unmarshal unmarshals data bytes into v. // Unmarshal unmarshals data bytes into v.
func Unmarshal(data []byte, v interface{}) error { func Unmarshal(data []byte, v interface{}) error {
decoder := json.NewDecoder(bytes.NewReader(data)) decoder := json.NewDecoder(bytes.NewReader(data))

View File

@@ -20,6 +20,22 @@ func TestMarshal(t *testing.T) {
assert.Equal(t, `{"name":"John","age":30}`, string(bs)) assert.Equal(t, `{"name":"John","age":30}`, string(bs))
} }
func TestMarshalToString(t *testing.T) {
var v = struct {
Name string `json:"name"`
Age int `json:"age"`
}{
Name: "John",
Age: 30,
}
toString, err := MarshalToString(v)
assert.Nil(t, err)
assert.Equal(t, `{"name":"John","age":30}`, toString)
_, err = MarshalToString(make(chan int))
assert.NotNil(t, err)
}
func TestUnmarshal(t *testing.T) { func TestUnmarshal(t *testing.T) {
const s = `{"name":"John","age":30}` const s = `{"name":"John","age":30}`
var v struct { var v struct {

View File

@@ -1,6 +1,7 @@
package limit package limit
import ( import (
"context"
"errors" "errors"
"strconv" "strconv"
"time" "time"
@@ -74,7 +75,12 @@ func NewPeriodLimit(period, quota int, limitStore *redis.Redis, keyPrefix string
// Take requests a permit, it returns the permit state. // Take requests a permit, it returns the permit state.
func (h *PeriodLimit) Take(key string) (int, error) { func (h *PeriodLimit) Take(key string) (int, error) {
resp, err := h.limitStore.Eval(periodScript, []string{h.keyPrefix + key}, []string{ return h.TakeCtx(context.Background(), key)
}
// TakeCtx requests a permit with context, it returns the permit state.
func (h *PeriodLimit) TakeCtx(ctx context.Context, key string) (int, error) {
resp, err := h.limitStore.EvalCtx(ctx, periodScript, []string{h.keyPrefix + key}, []string{
strconv.Itoa(h.quota), strconv.Itoa(h.quota),
strconv.Itoa(h.calcExpireSeconds()), strconv.Itoa(h.calcExpireSeconds()),
}) })

View File

@@ -11,4 +11,16 @@ type LogConf struct {
Compress bool `json:",optional"` Compress bool `json:",optional"`
KeepDays int `json:",optional"` KeepDays int `json:",optional"`
StackCooldownMillis int `json:",default=100"` StackCooldownMillis int `json:",default=100"`
// MaxBackups represents how many backup log files will be kept. 0 means all files will be kept forever.
// Only take effect when RotationRuleType is `size`.
// Even thougth `MaxBackups` sets 0, log files will still be removed
// if the `KeepDays` limitation is reached.
MaxBackups int `json:",default=0"`
// MaxSize represents how much space the writing log file takes up. 0 means no limit. The unit is `MB`.
// Only take effect when RotationRuleType is `size`
MaxSize int `json:",default=0"`
// RotationRuleType represents the type of log rotation rule. Default is `daily`.
// daily: daily rotation.
// size: size limited rotation.
Rotation string `json:",default=daily,options=[daily,size]"`
} }

View File

@@ -11,65 +11,65 @@ import (
// WithContext sets ctx to log, for keeping tracing information. // WithContext sets ctx to log, for keeping tracing information.
func WithContext(ctx context.Context) Logger { func WithContext(ctx context.Context) Logger {
return &traceLogger{ return &contextLogger{
ctx: ctx, ctx: ctx,
} }
} }
type traceLogger struct { type contextLogger struct {
logEntry logEntry
ctx context.Context ctx context.Context
} }
func (l *traceLogger) Error(v ...interface{}) { func (l *contextLogger) Error(v ...interface{}) {
l.err(fmt.Sprint(v...)) l.err(fmt.Sprint(v...))
} }
func (l *traceLogger) Errorf(format string, v ...interface{}) { func (l *contextLogger) Errorf(format string, v ...interface{}) {
l.err(fmt.Sprintf(format, v...)) l.err(fmt.Sprintf(format, v...))
} }
func (l *traceLogger) Errorv(v interface{}) { func (l *contextLogger) Errorv(v interface{}) {
l.err(fmt.Sprint(v)) l.err(fmt.Sprint(v))
} }
func (l *traceLogger) Errorw(msg string, fields ...LogField) { func (l *contextLogger) Errorw(msg string, fields ...LogField) {
l.err(msg, fields...) l.err(msg, fields...)
} }
func (l *traceLogger) Info(v ...interface{}) { func (l *contextLogger) Info(v ...interface{}) {
l.info(fmt.Sprint(v...)) l.info(fmt.Sprint(v...))
} }
func (l *traceLogger) Infof(format string, v ...interface{}) { func (l *contextLogger) Infof(format string, v ...interface{}) {
l.info(fmt.Sprintf(format, v...)) l.info(fmt.Sprintf(format, v...))
} }
func (l *traceLogger) Infov(v interface{}) { func (l *contextLogger) Infov(v interface{}) {
l.info(v) l.info(v)
} }
func (l *traceLogger) Infow(msg string, fields ...LogField) { func (l *contextLogger) Infow(msg string, fields ...LogField) {
l.info(msg, fields...) l.info(msg, fields...)
} }
func (l *traceLogger) Slow(v ...interface{}) { func (l *contextLogger) Slow(v ...interface{}) {
l.slow(fmt.Sprint(v...)) l.slow(fmt.Sprint(v...))
} }
func (l *traceLogger) Slowf(format string, v ...interface{}) { func (l *contextLogger) Slowf(format string, v ...interface{}) {
l.slow(fmt.Sprintf(format, v...)) l.slow(fmt.Sprintf(format, v...))
} }
func (l *traceLogger) Slowv(v interface{}) { func (l *contextLogger) Slowv(v interface{}) {
l.slow(v) l.slow(v)
} }
func (l *traceLogger) Sloww(msg string, fields ...LogField) { func (l *contextLogger) Sloww(msg string, fields ...LogField) {
l.slow(msg, fields...) l.slow(msg, fields...)
} }
func (l *traceLogger) WithContext(ctx context.Context) Logger { func (l *contextLogger) WithContext(ctx context.Context) Logger {
if ctx == nil { if ctx == nil {
return l return l
} }
@@ -78,40 +78,49 @@ func (l *traceLogger) WithContext(ctx context.Context) Logger {
return l return l
} }
func (l *traceLogger) WithDuration(duration time.Duration) Logger { func (l *contextLogger) WithDuration(duration time.Duration) Logger {
l.Duration = timex.ReprOfDuration(duration) l.Duration = timex.ReprOfDuration(duration)
return l return l
} }
func (l *traceLogger) buildFields(fields ...LogField) []LogField { func (l *contextLogger) buildFields(fields ...LogField) []LogField {
if len(l.Duration) > 0 { if len(l.Duration) > 0 {
fields = append(fields, Field(durationKey, l.Duration)) fields = append(fields, Field(durationKey, l.Duration))
} }
traceID := traceIdFromContext(l.ctx) traceID := traceIdFromContext(l.ctx)
if len(traceID) > 0 { if len(traceID) > 0 {
fields = append(fields, Field(traceKey, traceID)) fields = append(fields, Field(traceKey, traceID))
} }
spanID := spanIdFromContext(l.ctx) spanID := spanIdFromContext(l.ctx)
if len(spanID) > 0 { if len(spanID) > 0 {
fields = append(fields, Field(spanKey, spanID)) fields = append(fields, Field(spanKey, spanID))
} }
val := l.ctx.Value(fieldsContextKey)
if val != nil {
if arr, ok := val.([]LogField); ok {
fields = append(fields, arr...)
}
}
return fields return fields
} }
func (l *traceLogger) err(v interface{}, fields ...LogField) { func (l *contextLogger) err(v interface{}, fields ...LogField) {
if shallLog(ErrorLevel) { if shallLog(ErrorLevel) {
getWriter().Error(v, l.buildFields(fields...)...) getWriter().Error(v, l.buildFields(fields...)...)
} }
} }
func (l *traceLogger) info(v interface{}, fields ...LogField) { func (l *contextLogger) info(v interface{}, fields ...LogField) {
if shallLog(InfoLevel) { if shallLog(InfoLevel) {
getWriter().Info(v, l.buildFields(fields...)...) getWriter().Info(v, l.buildFields(fields...)...)
} }
} }
func (l *traceLogger) slow(v interface{}, fields ...LogField) { func (l *contextLogger) slow(v interface{}, fields ...LogField) {
if shallLog(ErrorLevel) { if shallLog(ErrorLevel) {
getWriter().Slow(v, l.buildFields(fields...)...) getWriter().Slow(v, l.buildFields(fields...)...)
} }

View File

@@ -29,7 +29,7 @@ func TestTraceLog(t *testing.T) {
otel.SetTracerProvider(tp) otel.SetTracerProvider(tp)
defer otel.SetTracerProvider(otp) defer otel.SetTracerProvider(otp)
ctx, span := tp.Tracer("foo").Start(context.Background(), "bar") ctx, span := tp.Tracer("trace-id").Start(context.Background(), "span-id")
defer span.End() defer span.End()
WithContext(ctx).Info(testlog) WithContext(ctx).Info(testlog)
@@ -50,7 +50,7 @@ func TestTraceError(t *testing.T) {
otel.SetTracerProvider(tp) otel.SetTracerProvider(tp)
defer otel.SetTracerProvider(otp) defer otel.SetTracerProvider(otp)
ctx, span := tp.Tracer("foo").Start(context.Background(), "bar") ctx, span := tp.Tracer("trace-id").Start(context.Background(), "span-id")
defer span.End() defer span.End()
var nilCtx context.Context var nilCtx context.Context
@@ -67,10 +67,10 @@ func TestTraceError(t *testing.T) {
l.WithDuration(time.Second).Errorv(testlog) l.WithDuration(time.Second).Errorv(testlog)
validate(t, w.String(), true, true) validate(t, w.String(), true, true)
w.Reset() w.Reset()
l.WithDuration(time.Second).Errorw(testlog, Field("foo", "bar")) l.WithDuration(time.Second).Errorw(testlog, Field("basket", "ball"))
validate(t, w.String(), true, true) validate(t, w.String(), true, true)
assert.True(t, strings.Contains(w.String(), "foo"), w.String()) assert.True(t, strings.Contains(w.String(), "basket"), w.String())
assert.True(t, strings.Contains(w.String(), "bar"), w.String()) assert.True(t, strings.Contains(w.String(), "ball"), w.String())
} }
func TestTraceInfo(t *testing.T) { func TestTraceInfo(t *testing.T) {
@@ -87,7 +87,7 @@ func TestTraceInfo(t *testing.T) {
otel.SetTracerProvider(tp) otel.SetTracerProvider(tp)
defer otel.SetTracerProvider(otp) defer otel.SetTracerProvider(otp)
ctx, span := tp.Tracer("foo").Start(context.Background(), "bar") ctx, span := tp.Tracer("trace-id").Start(context.Background(), "span-id")
defer span.End() defer span.End()
SetLevel(InfoLevel) SetLevel(InfoLevel)
@@ -101,10 +101,10 @@ func TestTraceInfo(t *testing.T) {
l.WithDuration(time.Second).Infov(testlog) l.WithDuration(time.Second).Infov(testlog)
validate(t, w.String(), true, true) validate(t, w.String(), true, true)
w.Reset() w.Reset()
l.WithDuration(time.Second).Infow(testlog, Field("foo", "bar")) l.WithDuration(time.Second).Infow(testlog, Field("basket", "ball"))
validate(t, w.String(), true, true) validate(t, w.String(), true, true)
assert.True(t, strings.Contains(w.String(), "foo"), w.String()) assert.True(t, strings.Contains(w.String(), "basket"), w.String())
assert.True(t, strings.Contains(w.String(), "bar"), w.String()) assert.True(t, strings.Contains(w.String(), "ball"), w.String())
} }
func TestTraceInfoConsole(t *testing.T) { func TestTraceInfoConsole(t *testing.T) {
@@ -124,7 +124,7 @@ func TestTraceInfoConsole(t *testing.T) {
otel.SetTracerProvider(tp) otel.SetTracerProvider(tp)
defer otel.SetTracerProvider(otp) defer otel.SetTracerProvider(otp)
ctx, span := tp.Tracer("foo").Start(context.Background(), "bar") ctx, span := tp.Tracer("trace-id").Start(context.Background(), "span-id")
defer span.End() defer span.End()
l := WithContext(ctx) l := WithContext(ctx)
@@ -153,7 +153,7 @@ func TestTraceSlow(t *testing.T) {
otel.SetTracerProvider(tp) otel.SetTracerProvider(tp)
defer otel.SetTracerProvider(otp) defer otel.SetTracerProvider(otp)
ctx, span := tp.Tracer("foo").Start(context.Background(), "bar") ctx, span := tp.Tracer("trace-id").Start(context.Background(), "span-id")
defer span.End() defer span.End()
l := WithContext(ctx) l := WithContext(ctx)
@@ -168,10 +168,10 @@ func TestTraceSlow(t *testing.T) {
l.WithDuration(time.Second).Slowv(testlog) l.WithDuration(time.Second).Slowv(testlog)
validate(t, w.String(), true, true) validate(t, w.String(), true, true)
w.Reset() w.Reset()
l.WithDuration(time.Second).Sloww(testlog, Field("foo", "bar")) l.WithDuration(time.Second).Sloww(testlog, Field("basket", "ball"))
validate(t, w.String(), true, true) validate(t, w.String(), true, true)
assert.True(t, strings.Contains(w.String(), "foo"), w.String()) assert.True(t, strings.Contains(w.String(), "basket"), w.String())
assert.True(t, strings.Contains(w.String(), "bar"), w.String()) assert.True(t, strings.Contains(w.String(), "ball"), w.String())
} }
func TestTraceWithoutContext(t *testing.T) { func TestTraceWithoutContext(t *testing.T) {
@@ -192,6 +192,25 @@ func TestTraceWithoutContext(t *testing.T) {
validate(t, w.String(), false, false) validate(t, w.String(), false, false)
} }
func TestLogWithFields(t *testing.T) {
w := new(mockWriter)
old := writer.Swap(w)
writer.lock.RLock()
defer func() {
writer.lock.RUnlock()
writer.Store(old)
}()
ctx := WithFields(context.Background(), Field("foo", "bar"))
l := WithContext(ctx)
SetLevel(InfoLevel)
l.Info(testlog)
var val mockValue
assert.Nil(t, json.Unmarshal([]byte(w.String()), &val))
assert.Equal(t, "bar", val.Foo)
}
func validate(t *testing.T, body string, expectedTrace, expectedSpan bool) { func validate(t *testing.T, body string, expectedTrace, expectedSpan bool) {
var val mockValue var val mockValue
dec := json.NewDecoder(strings.NewReader(body)) dec := json.NewDecoder(strings.NewReader(body))
@@ -217,4 +236,5 @@ func validate(t *testing.T, body string, expectedTrace, expectedSpan bool) {
type mockValue struct { type mockValue struct {
Trace string `json:"trace"` Trace string `json:"trace"`
Span string `json:"span"` Span string `json:"span"`
Foo string `json:"foo"`
} }

View File

@@ -66,7 +66,7 @@ func (l *durationLogger) Sloww(msg string, fields ...LogField) {
} }
func (l *durationLogger) WithContext(ctx context.Context) Logger { func (l *durationLogger) WithContext(ctx context.Context) Logger {
return &traceLogger{ return &contextLogger{
ctx: ctx, ctx: ctx,
logEntry: logEntry{ logEntry: logEntry{
Duration: l.Duration, Duration: l.Duration,

18
core/logx/fields.go Normal file
View File

@@ -0,0 +1,18 @@
package logx
import "context"
var fieldsContextKey contextKey
type contextKey struct{}
// WithFields returns a new context with the given fields.
func WithFields(ctx context.Context, fields ...LogField) context.Context {
if val := ctx.Value(fieldsContextKey); val != nil {
if arr, ok := val.([]LogField); ok {
return context.WithValue(ctx, fieldsContextKey, append(arr, fields...))
}
}
return context.WithValue(ctx, fieldsContextKey, fields)
}

35
core/logx/fields_test.go Normal file
View File

@@ -0,0 +1,35 @@
package logx
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestWithFields(t *testing.T) {
ctx := WithFields(context.Background(), Field("a", 1), Field("b", 2))
vals := ctx.Value(fieldsContextKey)
assert.NotNil(t, vals)
fields, ok := vals.([]LogField)
assert.True(t, ok)
assert.EqualValues(t, []LogField{Field("a", 1), Field("b", 2)}, fields)
}
func TestWithFieldsAppend(t *testing.T) {
var dummyKey struct{}
ctx := context.WithValue(context.Background(), dummyKey, "dummy")
ctx = WithFields(ctx, Field("a", 1), Field("b", 2))
ctx = WithFields(ctx, Field("c", 3), Field("d", 4))
vals := ctx.Value(fieldsContextKey)
assert.NotNil(t, vals)
fields, ok := vals.([]LogField)
assert.True(t, ok)
assert.Equal(t, "dummy", ctx.Value(dummyKey))
assert.EqualValues(t, []LogField{
Field("a", 1),
Field("b", 2),
Field("c", 3),
Field("d", 4),
}, fields)
}

View File

@@ -7,6 +7,7 @@ import (
"os" "os"
"path" "path"
"runtime/debug" "runtime/debug"
"sync"
"sync/atomic" "sync/atomic"
"time" "time"
@@ -21,9 +22,9 @@ var (
encoding uint32 = jsonEncodingType encoding uint32 = jsonEncodingType
// use uint32 for atomic operations // use uint32 for atomic operations
disableStat uint32 disableStat uint32
options logOptions
options logOptions writer = new(atomicWriter)
writer = new(atomicWriter) setupOnce sync.Once
) )
type ( type (
@@ -41,6 +42,9 @@ type (
gzipEnabled bool gzipEnabled bool
logStackCooldownMills int logStackCooldownMills int
keepDays int keepDays int
maxBackups int
maxSize int
rotationRule string
} }
// LogField is a key-value pair that will be added to the log entry. // LogField is a key-value pair that will be added to the log entry.
@@ -187,7 +191,6 @@ func MustSetup(c LogConf) {
// Reset clears the writer and resets the log level. // Reset clears the writer and resets the log level.
func Reset() Writer { func Reset() Writer {
SetLevel(InfoLevel)
return writer.Swap(nil) return writer.Swap(nil)
} }
@@ -197,40 +200,42 @@ func SetLevel(level uint32) {
} }
// SetWriter sets the logging writer. It can be used to customize the logging. // SetWriter sets the logging writer. It can be used to customize the logging.
// Call Reset before calling SetWriter again.
func SetWriter(w Writer) { func SetWriter(w Writer) {
if writer.Load() == nil { writer.Store(w)
writer.Store(w)
}
} }
// SetUp sets up the logx. If already set up, just return nil. // SetUp sets up the logx. If already set up, just return nil.
// we allow SetUp to be called multiple times, because for example // we allow SetUp to be called multiple times, because for example
// we need to allow different service frameworks to initialize logx respectively. // we need to allow different service frameworks to initialize logx respectively.
// the same logic for SetUp func SetUp(c LogConf) (err error) {
func SetUp(c LogConf) error { // Just ignore the subsequent SetUp calls.
setupLogLevel(c) // Because multiple services in one process might call SetUp respectively.
// Need to wait for the first caller to complete the execution.
setupOnce.Do(func() {
setupLogLevel(c)
if len(c.TimeFormat) > 0 { if len(c.TimeFormat) > 0 {
timeFormat = c.TimeFormat timeFormat = c.TimeFormat
} }
switch c.Encoding { switch c.Encoding {
case plainEncoding: case plainEncoding:
atomic.StoreUint32(&encoding, plainEncodingType) atomic.StoreUint32(&encoding, plainEncodingType)
default: default:
atomic.StoreUint32(&encoding, jsonEncodingType) atomic.StoreUint32(&encoding, jsonEncodingType)
} }
switch c.Mode { switch c.Mode {
case fileMode: case fileMode:
return setupWithFiles(c) err = setupWithFiles(c)
case volumeMode: case volumeMode:
return setupWithVolume(c) err = setupWithVolume(c)
default: default:
setupWithConsole() setupWithConsole()
return nil }
} })
return
} }
// Severe writes v into severe log. // Severe writes v into severe log.
@@ -294,13 +299,40 @@ func WithGzip() LogOption {
} }
} }
// WithMaxBackups customizes how many log files backups will be kept.
func WithMaxBackups(count int) LogOption {
return func(opts *logOptions) {
opts.maxBackups = count
}
}
// WithMaxSize customizes how much space the writing log file can take up.
func WithMaxSize(size int) LogOption {
return func(opts *logOptions) {
opts.maxSize = size
}
}
// WithRotation customizes which log rotation rule to use.
func WithRotation(r string) LogOption {
return func(opts *logOptions) {
opts.rotationRule = r
}
}
func createOutput(path string) (io.WriteCloser, error) { func createOutput(path string) (io.WriteCloser, error) {
if len(path) == 0 { if len(path) == 0 {
return nil, ErrLogPathNotSet return nil, ErrLogPathNotSet
} }
return NewLogger(path, DefaultRotateRule(path, backupFileDelimiter, options.keepDays, switch options.rotationRule {
options.gzipEnabled), options.gzipEnabled) case sizeRotationRule:
return NewLogger(path, NewSizeLimitRotateRule(path, backupFileDelimiter, options.keepDays,
options.maxSize, options.maxBackups, options.gzipEnabled), options.gzipEnabled)
default:
return NewLogger(path, DefaultRotateRule(path, backupFileDelimiter, options.keepDays,
options.gzipEnabled), options.gzipEnabled)
}
} }
func errorAnySync(v interface{}) { func errorAnySync(v interface{}) {

View File

@@ -603,8 +603,9 @@ func TestSetWriter(t *testing.T) {
SetWriter(nopWriter{}) SetWriter(nopWriter{})
assert.NotNil(t, writer.Load()) assert.NotNil(t, writer.Load())
assert.True(t, writer.Load() == nopWriter{}) assert.True(t, writer.Load() == nopWriter{})
SetWriter(new(mockWriter)) mocked := new(mockWriter)
assert.True(t, writer.Load() == nopWriter{}) SetWriter(mocked)
assert.Equal(t, mocked, writer.Load())
} }
func TestWithGzip(t *testing.T) { func TestWithGzip(t *testing.T) {

View File

@@ -8,15 +8,18 @@
```go ```go
type LogConf struct { type LogConf struct {
ServiceName string `json:",optional"` ServiceName string `json:",optional"`
Mode string `json:",default=console,options=[console,file,volume]"` Mode string `json:",default=console,options=[console,file,volume]"`
Encoding string `json:",default=json,options=[json,plain]"` Encoding string `json:",default=json,options=[json,plain]"`
TimeFormat string `json:",optional"` TimeFormat string `json:",optional"`
Path string `json:",default=logs"` Path string `json:",default=logs"`
Level string `json:",default=info,options=[info,error,severe]"` Level string `json:",default=info,options=[info,error,severe]"`
Compress bool `json:",optional"` Compress bool `json:",optional"`
KeepDays int `json:",optional"` KeepDays int `json:",optional"`
StackCooldownMillis int `json:",default=100"` StackCooldownMillis int `json:",default=100"`
MaxBackups int `json:",default=0"`
MaxSize int `json:",default=0"`
Rotation string `json:",default=daily,options=[daily,size]"`
} }
``` ```
@@ -37,6 +40,12 @@ type LogConf struct {
- `Compress`: 是否压缩日志文件,只在 `file` 模式下工作 - `Compress`: 是否压缩日志文件,只在 `file` 模式下工作
- `KeepDays`:日志文件被保留多少天,在给定的天数之后,过期的文件将被自动删除。对 `console` 模式没有影响 - `KeepDays`:日志文件被保留多少天,在给定的天数之后,过期的文件将被自动删除。对 `console` 模式没有影响
- `StackCooldownMillis`:多少毫秒后再次写入堆栈跟踪。用来避免堆栈跟踪日志过多 - `StackCooldownMillis`:多少毫秒后再次写入堆栈跟踪。用来避免堆栈跟踪日志过多
- `MaxBackups`: 多少个日志文件备份将被保存。0代表所有备份都被保存。当`Rotation`被设置为`size`时才会起作用。注意:`KeepDays`选项的优先级会比`MaxBackups`高,即使`MaxBackups`被设置为0当达到`KeepDays`上限时备份文件同样会被删除。
- `MaxSize`: 当前被写入的日志文件最大可占用多少空间。0代表没有上限。单位为`MB`。当`Rotation`被设置为`size`时才会起作用。
- `Rotation`: 日志轮转策略类型。默认为`daily`(按天轮转)。
- `daily` 按天轮转。
- `size` 按日志大小轮转。
## 打印日志方法 ## 打印日志方法

View File

@@ -8,15 +8,18 @@ English | [简体中文](readme-cn.md)
```go ```go
type LogConf struct { type LogConf struct {
ServiceName string `json:",optional"` ServiceName string `json:",optional"`
Mode string `json:",default=console,options=[console,file,volume]"` Mode string `json:",default=console,options=[console,file,volume]"`
Encoding string `json:",default=json,options=[json,plain]"` Encoding string `json:",default=json,options=[json,plain]"`
TimeFormat string `json:",optional"` TimeFormat string `json:",optional"`
Path string `json:",default=logs"` Path string `json:",default=logs"`
Level string `json:",default=info,options=[info,error,severe]"` Level string `json:",default=info,options=[info,error,severe]"`
Compress bool `json:",optional"` Compress bool `json:",optional"`
KeepDays int `json:",optional"` KeepDays int `json:",optional"`
StackCooldownMillis int `json:",default=100"` StackCooldownMillis int `json:",default=100"`
MaxBackups int `json:",default=0"`
MaxSize int `json:",default=0"`
Rotation string `json:",default=daily,options=[daily,size]"`
} }
``` ```
@@ -37,6 +40,11 @@ type LogConf struct {
- `Compress`: whether or not to compress log files, only works with `file` mode. - `Compress`: whether or not to compress log files, only works with `file` mode.
- `KeepDays`: how many days that the log files are kept, after the given days, the outdated files will be deleted automatically. It has no effect on `console` mode. - `KeepDays`: how many days that the log files are kept, after the given days, the outdated files will be deleted automatically. It has no effect on `console` mode.
- `StackCooldownMillis`: how many milliseconds to rewrite stacktrace again. Its used to avoid stacktrace flooding. - `StackCooldownMillis`: how many milliseconds to rewrite stacktrace again. Its used to avoid stacktrace flooding.
- `MaxBackups`: represents how many backup log files will be kept. 0 means all files will be kept forever. Only take effect when `Rotation` is `size`. NOTE: the level of option `KeepDays` will be higher. Even thougth `MaxBackups` sets 0, log files will still be removed if the `KeepDays` limitation is reached.
- `MaxSize`: represents how much space the writing log file takes up. 0 means no limit. The unit is `MB`. Only take effect when `Rotation` is `size`.
- `Rotation`: represents the type of log rotation rule. Default is `daily`.
- `daily` rotate the logs by day.
- `size` rotate the logs by size of logs.
## Logging methods ## Logging methods

View File

@@ -9,6 +9,7 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"sort"
"strings" "strings"
"sync" "sync"
"time" "time"
@@ -19,10 +20,13 @@ import (
const ( const (
dateFormat = "2006-01-02" dateFormat = "2006-01-02"
fileTimeFormat = time.RFC3339
hoursPerDay = 24 hoursPerDay = 24
bufferSize = 100 bufferSize = 100
defaultDirMode = 0o755 defaultDirMode = 0o755
defaultFileMode = 0o600 defaultFileMode = 0o600
gzipExt = ".gz"
megaBytes = 1 << 20
) )
// ErrLogFileClosed is an error that indicates the log file is already closed. // ErrLogFileClosed is an error that indicates the log file is already closed.
@@ -34,7 +38,7 @@ type (
BackupFileName() string BackupFileName() string
MarkRotated() MarkRotated()
OutdatedFiles() []string OutdatedFiles() []string
ShallRotate() bool ShallRotate(size int64) bool
} }
// A RotateLogger is a Logger that can rotate log files with given rules. // A RotateLogger is a Logger that can rotate log files with given rules.
@@ -47,8 +51,9 @@ type (
rule RotateRule rule RotateRule
compress bool compress bool
// can't use threading.RoutineGroup because of cycle import // can't use threading.RoutineGroup because of cycle import
waitGroup sync.WaitGroup waitGroup sync.WaitGroup
closeOnce sync.Once closeOnce sync.Once
currentSize int64
} }
// A DailyRotateRule is a rule to daily rotate the log files. // A DailyRotateRule is a rule to daily rotate the log files.
@@ -59,6 +64,13 @@ type (
days int days int
gzip bool gzip bool
} }
// SizeLimitRotateRule a rotation rule that make the log file rotated base on size
SizeLimitRotateRule struct {
DailyRotateRule
maxSize int64
maxBackups int
}
) )
// DefaultRotateRule is a default log rotating rule, currently DailyRotateRule. // DefaultRotateRule is a default log rotating rule, currently DailyRotateRule.
@@ -90,7 +102,7 @@ func (r *DailyRotateRule) OutdatedFiles() []string {
var pattern string var pattern string
if r.gzip { if r.gzip {
pattern = fmt.Sprintf("%s%s*.gz", r.filename, r.delimiter) pattern = fmt.Sprintf("%s%s*%s", r.filename, r.delimiter, gzipExt)
} else { } else {
pattern = fmt.Sprintf("%s%s*", r.filename, r.delimiter) pattern = fmt.Sprintf("%s%s*", r.filename, r.delimiter)
} }
@@ -105,7 +117,7 @@ func (r *DailyRotateRule) OutdatedFiles() []string {
boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(dateFormat) boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(dateFormat)
fmt.Fprintf(&buf, "%s%s%s", r.filename, r.delimiter, boundary) fmt.Fprintf(&buf, "%s%s%s", r.filename, r.delimiter, boundary)
if r.gzip { if r.gzip {
buf.WriteString(".gz") buf.WriteString(gzipExt)
} }
boundaryFile := buf.String() boundaryFile := buf.String()
@@ -120,10 +132,100 @@ func (r *DailyRotateRule) OutdatedFiles() []string {
} }
// ShallRotate checks if the file should be rotated. // ShallRotate checks if the file should be rotated.
func (r *DailyRotateRule) ShallRotate() bool { func (r *DailyRotateRule) ShallRotate(_ int64) bool {
return len(r.rotatedTime) > 0 && getNowDate() != r.rotatedTime return len(r.rotatedTime) > 0 && getNowDate() != r.rotatedTime
} }
// NewSizeLimitRotateRule returns the rotation rule with size limit
func NewSizeLimitRotateRule(filename, delimiter string, days, maxSize, maxBackups int, gzip bool) RotateRule {
return &SizeLimitRotateRule{
DailyRotateRule: DailyRotateRule{
rotatedTime: getNowDateInRFC3339Format(),
filename: filename,
delimiter: delimiter,
days: days,
gzip: gzip,
},
maxSize: int64(maxSize) * megaBytes,
maxBackups: maxBackups,
}
}
func (r *SizeLimitRotateRule) BackupFileName() string {
dir := filepath.Dir(r.filename)
prefix, ext := r.parseFilename()
timestamp := getNowDateInRFC3339Format()
return filepath.Join(dir, fmt.Sprintf("%s%s%s%s", prefix, r.delimiter, timestamp, ext))
}
func (r *SizeLimitRotateRule) MarkRotated() {
r.rotatedTime = getNowDateInRFC3339Format()
}
func (r *SizeLimitRotateRule) OutdatedFiles() []string {
dir := filepath.Dir(r.filename)
prefix, ext := r.parseFilename()
var pattern string
if r.gzip {
pattern = fmt.Sprintf("%s%s%s%s*%s%s", dir, string(filepath.Separator),
prefix, r.delimiter, ext, gzipExt)
} else {
pattern = fmt.Sprintf("%s%s%s%s*%s", dir, string(filepath.Separator),
prefix, r.delimiter, ext)
}
files, err := filepath.Glob(pattern)
if err != nil {
Errorf("failed to delete outdated log files, error: %s", err)
return nil
}
sort.Strings(files)
outdated := make(map[string]lang.PlaceholderType)
// test if too many backups
if r.maxBackups > 0 && len(files) > r.maxBackups {
for _, f := range files[:len(files)-r.maxBackups] {
outdated[f] = lang.Placeholder
}
files = files[len(files)-r.maxBackups:]
}
// test if any too old backups
if r.days > 0 {
boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(fileTimeFormat)
boundaryFile := filepath.Join(dir, fmt.Sprintf("%s%s%s%s", prefix, r.delimiter, boundary, ext))
if r.gzip {
boundaryFile += gzipExt
}
for _, f := range files {
if f >= boundaryFile {
break
}
outdated[f] = lang.Placeholder
}
}
var result []string
for k := range outdated {
result = append(result, k)
}
return result
}
func (r *SizeLimitRotateRule) ShallRotate(size int64) bool {
return r.maxSize > 0 && r.maxSize < size
}
func (r *SizeLimitRotateRule) parseFilename() (prefix, ext string) {
logName := filepath.Base(r.filename)
ext = filepath.Ext(r.filename)
prefix = logName[:len(logName)-len(ext)]
return
}
// NewLogger returns a RotateLogger with given filename and rule, etc. // NewLogger returns a RotateLogger with given filename and rule, etc.
func NewLogger(filename string, rule RotateRule, compress bool) (*RotateLogger, error) { func NewLogger(filename string, rule RotateRule, compress bool) (*RotateLogger, error) {
l := &RotateLogger{ l := &RotateLogger{
@@ -282,15 +384,17 @@ func (l *RotateLogger) startWorker() {
} }
func (l *RotateLogger) write(v []byte) { func (l *RotateLogger) write(v []byte) {
if l.rule.ShallRotate() { if l.rule.ShallRotate(l.currentSize + int64(len(v))) {
if err := l.rotate(); err != nil { if err := l.rotate(); err != nil {
log.Println(err) log.Println(err)
} else { } else {
l.rule.MarkRotated() l.rule.MarkRotated()
l.currentSize = 0
} }
} }
if l.fp != nil { if l.fp != nil {
l.fp.Write(v) l.fp.Write(v)
l.currentSize += int64(len(v))
} }
} }
@@ -308,6 +412,10 @@ func getNowDate() string {
return time.Now().Format(dateFormat) return time.Now().Format(dateFormat)
} }
func getNowDateInRFC3339Format() string {
return time.Now().Format(fileTimeFormat)
}
func gzipFile(file string) error { func gzipFile(file string) error {
in, err := os.Open(file) in, err := os.Open(file)
if err != nil { if err != nil {
@@ -315,7 +423,7 @@ func gzipFile(file string) error {
} }
defer in.Close() defer in.Close()
out, err := os.Create(fmt.Sprintf("%s.gz", file)) out, err := os.Create(fmt.Sprintf("%s%s", file, gzipExt))
if err != nil { if err != nil {
return err return err
} }

View File

@@ -29,7 +29,34 @@ func TestDailyRotateRuleOutdatedFiles(t *testing.T) {
func TestDailyRotateRuleShallRotate(t *testing.T) { func TestDailyRotateRuleShallRotate(t *testing.T) {
var rule DailyRotateRule var rule DailyRotateRule
rule.rotatedTime = time.Now().Add(time.Hour * 24).Format(dateFormat) rule.rotatedTime = time.Now().Add(time.Hour * 24).Format(dateFormat)
assert.True(t, rule.ShallRotate()) assert.True(t, rule.ShallRotate(0))
}
func TestSizeLimitRotateRuleMarkRotated(t *testing.T) {
var rule SizeLimitRotateRule
rule.MarkRotated()
assert.Equal(t, getNowDateInRFC3339Format(), rule.rotatedTime)
}
func TestSizeLimitRotateRuleOutdatedFiles(t *testing.T) {
var rule SizeLimitRotateRule
assert.Empty(t, rule.OutdatedFiles())
rule.days = 1
assert.Empty(t, rule.OutdatedFiles())
rule.gzip = true
assert.Empty(t, rule.OutdatedFiles())
rule.maxBackups = 0
assert.Empty(t, rule.OutdatedFiles())
}
func TestSizeLimitRotateRuleShallRotate(t *testing.T) {
var rule SizeLimitRotateRule
rule.rotatedTime = time.Now().Add(time.Hour * 24).Format(fileTimeFormat)
rule.maxSize = 0
assert.False(t, rule.ShallRotate(0))
rule.maxSize = 100
assert.False(t, rule.ShallRotate(0))
assert.True(t, rule.ShallRotate(101*megaBytes))
} }
func TestRotateLoggerClose(t *testing.T) { func TestRotateLoggerClose(t *testing.T) {
@@ -142,3 +169,162 @@ func TestRotateLoggerWrite(t *testing.T) {
func TestLogWriterClose(t *testing.T) { func TestLogWriterClose(t *testing.T) {
assert.Nil(t, newLogWriter(nil).Close()) assert.Nil(t, newLogWriter(nil).Close())
} }
func TestRotateLoggerWithSizeLimitRotateRuleClose(t *testing.T) {
filename, err := fs.TempFilenameWithText("foo")
assert.Nil(t, err)
if len(filename) > 0 {
defer os.Remove(filename)
}
logger, err := NewLogger(filename, new(SizeLimitRotateRule), false)
assert.Nil(t, err)
assert.Nil(t, logger.Close())
}
func TestRotateLoggerGetBackupWithSizeLimitRotateRuleFilename(t *testing.T) {
filename, err := fs.TempFilenameWithText("foo")
assert.Nil(t, err)
if len(filename) > 0 {
defer os.Remove(filename)
}
logger, err := NewLogger(filename, new(SizeLimitRotateRule), false)
assert.Nil(t, err)
assert.True(t, len(logger.getBackupFilename()) > 0)
logger.backup = ""
assert.True(t, len(logger.getBackupFilename()) > 0)
}
func TestRotateLoggerWithSizeLimitRotateRuleMayCompressFile(t *testing.T) {
old := os.Stdout
os.Stdout = os.NewFile(0, os.DevNull)
defer func() {
os.Stdout = old
}()
filename, err := fs.TempFilenameWithText("foo")
assert.Nil(t, err)
if len(filename) > 0 {
defer os.Remove(filename)
}
logger, err := NewLogger(filename, new(SizeLimitRotateRule), false)
assert.Nil(t, err)
logger.maybeCompressFile(filename)
_, err = os.Stat(filename)
assert.Nil(t, err)
}
func TestRotateLoggerWithSizeLimitRotateRuleMayCompressFileTrue(t *testing.T) {
old := os.Stdout
os.Stdout = os.NewFile(0, os.DevNull)
defer func() {
os.Stdout = old
}()
filename, err := fs.TempFilenameWithText("foo")
assert.Nil(t, err)
logger, err := NewLogger(filename, new(SizeLimitRotateRule), true)
assert.Nil(t, err)
if len(filename) > 0 {
defer os.Remove(filepath.Base(logger.getBackupFilename()) + ".gz")
}
logger.maybeCompressFile(filename)
_, err = os.Stat(filename)
assert.NotNil(t, err)
}
func TestRotateLoggerWithSizeLimitRotateRuleRotate(t *testing.T) {
filename, err := fs.TempFilenameWithText("foo")
assert.Nil(t, err)
logger, err := NewLogger(filename, new(SizeLimitRotateRule), true)
assert.Nil(t, err)
if len(filename) > 0 {
defer func() {
os.Remove(logger.getBackupFilename())
os.Remove(filepath.Base(logger.getBackupFilename()) + ".gz")
}()
}
err = logger.rotate()
switch v := err.(type) {
case *os.LinkError:
// avoid rename error on docker container
assert.Equal(t, syscall.EXDEV, v.Err)
case *os.PathError:
// ignore remove error for tests,
// files are cleaned in GitHub actions.
assert.Equal(t, "remove", v.Op)
default:
assert.Nil(t, err)
}
}
func TestRotateLoggerWithSizeLimitRotateRuleWrite(t *testing.T) {
filename, err := fs.TempFilenameWithText("foo")
assert.Nil(t, err)
rule := new(SizeLimitRotateRule)
logger, err := NewLogger(filename, rule, true)
assert.Nil(t, err)
if len(filename) > 0 {
defer func() {
os.Remove(logger.getBackupFilename())
os.Remove(filepath.Base(logger.getBackupFilename()) + ".gz")
}()
}
// the following write calls cannot be changed to Write, because of DATA RACE.
logger.write([]byte(`foo`))
rule.rotatedTime = time.Now().Add(-time.Hour * 24).Format(dateFormat)
logger.write([]byte(`bar`))
logger.Close()
logger.write([]byte(`baz`))
}
func BenchmarkRotateLogger(b *testing.B) {
filename := "./test.log"
filename2 := "./test2.log"
dailyRotateRuleLogger, err1 := NewLogger(
filename,
DefaultRotateRule(
filename,
backupFileDelimiter,
1,
true,
),
true,
)
if err1 != nil {
b.Logf("Failed to new daily rotate rule logger: %v", err1)
b.FailNow()
}
sizeLimitRotateRuleLogger, err2 := NewLogger(
filename2,
NewSizeLimitRotateRule(
filename,
backupFileDelimiter,
1,
100,
10,
true,
),
true,
)
if err2 != nil {
b.Logf("Failed to new size limit rotate rule logger: %v", err1)
b.FailNow()
}
defer func() {
dailyRotateRuleLogger.Close()
sizeLimitRotateRuleLogger.Close()
os.Remove(filename)
os.Remove(filename2)
}()
b.Run("daily rotate rule", func(b *testing.B) {
for i := 0; i < b.N; i++ {
dailyRotateRuleLogger.write([]byte("testing\ntesting\n"))
}
})
b.Run("size limit rotate rule", func(b *testing.B) {
for i := 0; i < b.N; i++ {
sizeLimitRotateRuleLogger.write([]byte("testing\ntesting\n"))
}
})
}

View File

@@ -15,9 +15,9 @@ const (
jsonEncodingType = iota jsonEncodingType = iota
plainEncodingType plainEncodingType
jsonEncoding = "json"
plainEncoding = "plain" plainEncoding = "plain"
plainEncodingSep = '\t' plainEncodingSep = '\t'
sizeRotationRule = "size"
) )
const ( const (
@@ -27,9 +27,8 @@ const (
slowFilename = "slow.log" slowFilename = "slow.log"
statFilename = "stat.log" statFilename = "stat.log"
consoleMode = "console" fileMode = "file"
fileMode = "file" volumeMode = "volume"
volumeMode = "volume"
levelAlert = "alert" levelAlert = "alert"
levelInfo = "info" levelInfo = "info"

View File

@@ -63,15 +63,15 @@ func (w *atomicWriter) Load() Writer {
func (w *atomicWriter) Store(v Writer) { func (w *atomicWriter) Store(v Writer) {
w.lock.Lock() w.lock.Lock()
defer w.lock.Unlock()
w.writer = v w.writer = v
w.lock.Unlock()
} }
func (w *atomicWriter) Swap(v Writer) Writer { func (w *atomicWriter) Swap(v Writer) Writer {
w.lock.Lock() w.lock.Lock()
defer w.lock.Unlock()
old := w.writer old := w.writer
w.writer = v w.writer = v
w.lock.Unlock()
return old return old
} }
@@ -109,6 +109,14 @@ func newFileWriter(c LogConf) (Writer, error) {
if c.KeepDays > 0 { if c.KeepDays > 0 {
opts = append(opts, WithKeepDays(c.KeepDays)) opts = append(opts, WithKeepDays(c.KeepDays))
} }
if c.MaxBackups > 0 {
opts = append(opts, WithMaxBackups(c.MaxBackups))
}
if c.MaxSize > 0 {
opts = append(opts, WithMaxSize(c.MaxSize))
}
opts = append(opts, WithRotation(c.Rotation))
accessFile := path.Join(c.Path, accessFilename) accessFile := path.Join(c.Path, accessFilename)
errorFile := path.Join(c.Path, errorFilename) errorFile := path.Join(c.Path, errorFilename)

View File

@@ -534,8 +534,10 @@ func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int,
baseKind reflect.Kind, value interface{}) error { baseKind reflect.Kind, value interface{}) error {
ithVal := slice.Index(index) ithVal := slice.Index(index)
switch v := value.(type) { switch v := value.(type) {
case json.Number: case fmt.Stringer:
return setValue(baseKind, ithVal, v.String()) return setValue(baseKind, ithVal, v.String())
case string:
return setValue(baseKind, ithVal, v)
default: default:
// don't need to consider the difference between int, int8, int16, int32, int64, // don't need to consider the difference between int, int8, int16, int32, int64,
// uint, uint8, uint16, uint32, uint64, because they're handled as json.Number. // uint, uint8, uint16, uint32, uint64, because they're handled as json.Number.

View File

@@ -2681,7 +2681,7 @@ func TestUnmarshalJsonReaderMultiArray(t *testing.T) {
assert.Equal(t, 2, len(res.B)) assert.Equal(t, 2, len(res.B))
} }
func TestUnmarshalJsonReaderPtrMultiArray(t *testing.T) { func TestUnmarshalJsonReaderPtrMultiArrayString(t *testing.T) {
payload := `{"a": "133", "b": [["add", "cccd"], ["eeee"]]}` payload := `{"a": "133", "b": [["add", "cccd"], ["eeee"]]}`
var res struct { var res struct {
A string `json:"a"` A string `json:"a"`
@@ -2694,6 +2694,32 @@ func TestUnmarshalJsonReaderPtrMultiArray(t *testing.T) {
assert.Equal(t, 2, len(res.B[0])) assert.Equal(t, 2, len(res.B[0]))
} }
func TestUnmarshalJsonReaderPtrMultiArrayString_Int(t *testing.T) {
payload := `{"a": "133", "b": [[11, 22], [33]]}`
var res struct {
A string `json:"a"`
B [][]*string `json:"b"`
}
reader := strings.NewReader(payload)
err := UnmarshalJsonReader(reader, &res)
assert.Nil(t, err)
assert.Equal(t, 2, len(res.B))
assert.Equal(t, 2, len(res.B[0]))
}
func TestUnmarshalJsonReaderPtrMultiArrayInt(t *testing.T) {
payload := `{"a": "133", "b": [[11, 22], [33]]}`
var res struct {
A string `json:"a"`
B [][]*int `json:"b"`
}
reader := strings.NewReader(payload)
err := UnmarshalJsonReader(reader, &res)
assert.Nil(t, err)
assert.Equal(t, 2, len(res.B))
assert.Equal(t, 2, len(res.B[0]))
}
func TestUnmarshalJsonReaderPtrArray(t *testing.T) { func TestUnmarshalJsonReaderPtrArray(t *testing.T) {
payload := `{"a": "133", "b": ["add", "cccd", "eeee"]}` payload := `{"a": "133", "b": ["add", "cccd", "eeee"]}`
var res struct { var res struct {
@@ -2706,6 +2732,30 @@ func TestUnmarshalJsonReaderPtrArray(t *testing.T) {
assert.Equal(t, 3, len(res.B)) assert.Equal(t, 3, len(res.B))
} }
func TestUnmarshalJsonReaderPtrArray_Int(t *testing.T) {
payload := `{"a": "133", "b": [11, 22, 33]}`
var res struct {
A string `json:"a"`
B []*string `json:"b"`
}
reader := strings.NewReader(payload)
err := UnmarshalJsonReader(reader, &res)
assert.Nil(t, err)
assert.Equal(t, 3, len(res.B))
}
func TestUnmarshalJsonReaderPtrInt(t *testing.T) {
payload := `{"a": "133", "b": [11, 22, 33]}`
var res struct {
A string `json:"a"`
B []*string `json:"b"`
}
reader := strings.NewReader(payload)
err := UnmarshalJsonReader(reader, &res)
assert.Nil(t, err)
assert.Equal(t, 3, len(res.B))
}
func TestUnmarshalJsonWithoutKey(t *testing.T) { func TestUnmarshalJsonWithoutKey(t *testing.T) {
payload := `{"A": "1", "B": "2"}` payload := `{"A": "1", "B": "2"}`
var res struct { var res struct {

View File

@@ -143,6 +143,23 @@ func doParseKeyAndOptions(field reflect.StructField, value string) (string, *fie
return key, &fieldOpts, nil return key, &fieldOpts, nil
} }
// ensureValue ensures nested members not to be nil.
// If pointer value is nil, set to a new value.
func ensureValue(v reflect.Value) reflect.Value {
for {
if v.Kind() != reflect.Ptr {
break
}
if v.IsNil() {
v.Set(reflect.New(v.Type().Elem()))
}
v = v.Elem()
}
return v
}
func implicitValueRequiredStruct(tag string, tp reflect.Type) (bool, error) { func implicitValueRequiredStruct(tag string, tp reflect.Type) (bool, error) {
numFields := tp.NumField() numFields := tp.NumField()
for i := 0; i < numFields; i++ { for i := 0; i < numFields; i++ {
@@ -478,6 +495,7 @@ func setValue(kind reflect.Kind, value reflect.Value, str string) error {
return errValueNotSettable return errValueNotSettable
} }
value = ensureValue(value)
v, err := convertType(kind, str) v, err := convertType(kind, str)
if err != nil { if err != nil {
return err return err

View File

@@ -15,7 +15,7 @@ type Foo struct {
StrWithTagAndOption string `key:"stringwithtag,string"` StrWithTagAndOption string `key:"stringwithtag,string"`
} }
func TestDeferInt(t *testing.T) { func TestDerefInt(t *testing.T) {
i := 1 i := 1
s := "hello" s := "hello"
number := struct { number := struct {
@@ -60,6 +60,51 @@ func TestDeferInt(t *testing.T) {
} }
} }
func TestDerefValInt(t *testing.T) {
i := 1
s := "hello"
number := struct {
f float64
}{
f: 6.4,
}
cases := []struct {
t reflect.Value
expect reflect.Kind
}{
{
t: reflect.ValueOf(i),
expect: reflect.Int,
},
{
t: reflect.ValueOf(&i),
expect: reflect.Int,
},
{
t: reflect.ValueOf(s),
expect: reflect.String,
},
{
t: reflect.ValueOf(&s),
expect: reflect.String,
},
{
t: reflect.ValueOf(number.f),
expect: reflect.Float64,
},
{
t: reflect.ValueOf(&number.f),
expect: reflect.Float64,
},
}
for _, each := range cases {
t.Run(each.t.String(), func(t *testing.T) {
assert.Equal(t, each.expect, ensureValue(each.t).Kind())
})
}
}
func TestParseKeyAndOptionWithoutTag(t *testing.T) { func TestParseKeyAndOptionWithoutTag(t *testing.T) {
var foo Foo var foo Foo
rte := reflect.TypeOf(&foo).Elem() rte := reflect.TypeOf(&foo).Elem()

View File

@@ -376,9 +376,7 @@ type onceChan struct {
} }
func (oc *onceChan) write(val interface{}) { func (oc *onceChan) write(val interface{}) {
if atomic.AddInt32(&oc.wrote, 1) > 1 { if atomic.CompareAndSwapInt32(&oc.wrote, 0, 1) {
return oc.channel <- val
} }
oc.channel <- val
} }

View File

@@ -1,12 +1,14 @@
package redis package redis
import ( import (
"context"
"math/rand" "math/rand"
"strconv" "strconv"
"sync/atomic" "sync/atomic"
"time" "time"
red "github.com/go-redis/redis/v8" red "github.com/go-redis/redis/v8"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/stringx" "github.com/zeromicro/go-zero/core/stringx"
) )
@@ -51,8 +53,13 @@ func NewRedisLock(store *Redis, key string) *RedisLock {
// Acquire acquires the lock. // Acquire acquires the lock.
func (rl *RedisLock) Acquire() (bool, error) { func (rl *RedisLock) Acquire() (bool, error) {
return rl.AcquireCtx(context.Background())
}
// AcquireCtx acquires the lock with the given ctx.
func (rl *RedisLock) AcquireCtx(ctx context.Context) (bool, error) {
seconds := atomic.LoadUint32(&rl.seconds) seconds := atomic.LoadUint32(&rl.seconds)
resp, err := rl.store.Eval(lockCommand, []string{rl.key}, []string{ resp, err := rl.store.EvalCtx(ctx, lockCommand, []string{rl.key}, []string{
rl.id, strconv.Itoa(int(seconds)*millisPerSecond + tolerance), rl.id, strconv.Itoa(int(seconds)*millisPerSecond + tolerance),
}) })
if err == red.Nil { if err == red.Nil {
@@ -75,7 +82,12 @@ func (rl *RedisLock) Acquire() (bool, error) {
// Release releases the lock. // Release releases the lock.
func (rl *RedisLock) Release() (bool, error) { func (rl *RedisLock) Release() (bool, error) {
resp, err := rl.store.Eval(delCommand, []string{rl.key}, []string{rl.id}) return rl.ReleaseCtx(context.Background())
}
// ReleaseCtx releases the lock with the given ctx.
func (rl *RedisLock) ReleaseCtx(ctx context.Context) (bool, error) {
resp, err := rl.store.EvalCtx(ctx, delCommand, []string{rl.key}, []string{rl.id})
if err != nil { if err != nil {
return false, err return false, err
} }

View File

@@ -1,33 +1,65 @@
package redis package redis
import ( import (
"context"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/stringx" "github.com/zeromicro/go-zero/core/stringx"
) )
func TestRedisLock(t *testing.T) { func TestRedisLock(t *testing.T) {
runOnRedis(t, func(client *Redis) { testFn := func(ctx context.Context) func(client *Redis) {
key := stringx.Rand() return func(client *Redis) {
firstLock := NewRedisLock(client, key) key := stringx.Rand()
firstLock.SetExpire(5) firstLock := NewRedisLock(client, key)
firstAcquire, err := firstLock.Acquire() firstLock.SetExpire(5)
assert.Nil(t, err) firstAcquire, err := firstLock.Acquire()
assert.True(t, firstAcquire) assert.Nil(t, err)
assert.True(t, firstAcquire)
secondLock := NewRedisLock(client, key) secondLock := NewRedisLock(client, key)
secondLock.SetExpire(5) secondLock.SetExpire(5)
againAcquire, err := secondLock.Acquire() againAcquire, err := secondLock.Acquire()
assert.Nil(t, err) assert.Nil(t, err)
assert.False(t, againAcquire) assert.False(t, againAcquire)
release, err := firstLock.Release() release, err := firstLock.Release()
assert.Nil(t, err) assert.Nil(t, err)
assert.True(t, release) assert.True(t, release)
endAcquire, err := secondLock.Acquire() endAcquire, err := secondLock.Acquire()
assert.Nil(t, err) assert.Nil(t, err)
assert.True(t, endAcquire) assert.True(t, endAcquire)
}
}
t.Run("normal", func(t *testing.T) {
runOnRedis(t, testFn(nil))
})
t.Run("withContext", func(t *testing.T) {
runOnRedis(t, testFn(context.Background()))
})
}
func TestRedisLock_Expired(t *testing.T) {
runOnRedis(t, func(client *Redis) {
key := stringx.Rand()
redisLock := NewRedisLock(client, key)
ctx, cancel := context.WithCancel(context.Background())
cancel()
_, err := redisLock.AcquireCtx(ctx)
assert.NotNil(t, err)
})
runOnRedis(t, func(client *Redis) {
key := stringx.Rand()
redisLock := NewRedisLock(client, key)
ctx, cancel := context.WithCancel(context.Background())
cancel()
_, err := redisLock.ReleaseCtx(ctx)
assert.NotNil(t, err)
}) })
} }

View File

@@ -35,13 +35,11 @@ func CompareVersions(v1, op, v2 string) bool {
// return -1 if v1<v2, 0 if they are equal, and 1 if v1>v2 // return -1 if v1<v2, 0 if they are equal, and 1 if v1>v2
func compare(v1, v2 string) int { func compare(v1, v2 string) int {
v1 = replacer.Replace(v1) v1, v2 = replacer.Replace(v1), replacer.Replace(v2)
v2 = replacer.Replace(v2) fields1, fields2 := strings.Split(v1, "."), strings.Split(v2, ".")
fields1 := strings.Split(v1, ".") ver1, ver2 := strsToInts(fields1), strsToInts(fields2)
fields2 := strings.Split(v2, ".") ver1len, ver2len := len(ver1), len(ver2)
ver1 := strsToInts(fields1) shorter := mathx.MinInt(ver1len, ver2len)
ver2 := strsToInts(fields2)
shorter := mathx.MinInt(len(ver1), len(ver2))
for i := 0; i < shorter; i++ { for i := 0; i < shorter; i++ {
if ver1[i] == ver2[i] { if ver1[i] == ver2[i] {
@@ -53,9 +51,9 @@ func compare(v1, v2 string) int {
} }
} }
if len(ver1) < len(ver2) { if ver1len < ver2len {
return -1 return -1
} else if len(ver1) == len(ver2) { } else if ver1len == ver2len {
return 0 return 0
} else { } else {
return 1 return 1

42
gateway/config.go Normal file
View File

@@ -0,0 +1,42 @@
package gateway
import (
"time"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
)
type (
// GatewayConf is the configuration for gateway.
GatewayConf struct {
rest.RestConf
Upstreams []Upstream
Timeout time.Duration `json:",default=5s"`
}
// RouteMapping is a mapping between a gateway route and an upstream rpc method.
RouteMapping struct {
// Method is the HTTP method, like GET, POST, PUT, DELETE.
Method string
// Path is the HTTP path.
Path string
// RpcPath is the gRPC rpc method, with format of package.service/method
RpcPath string
}
// Upstream is the configuration for an upstream.
Upstream struct {
// Name is the name of the upstream.
Name string `json:",optional"`
// Grpc is the target of the upstream.
Grpc zrpc.RpcClientConf
// ProtoSets is the file list of proto set, like [hello.pb].
// if your proto file import another proto file, you need to write multi-file slice,
// like [hello.pb, common.pb].
ProtoSets []string `json:",optional"`
// Mappings is the mapping between gateway routes and Upstream rpc methods.
// Keep it blank if annotations are added in rpc methods.
Mappings []RouteMapping `json:",optional"`
}
)

View File

@@ -0,0 +1,102 @@
package internal
import (
"fmt"
"net/http"
"strings"
"github.com/fullstorydev/grpcurl"
"github.com/jhump/protoreflect/desc"
"google.golang.org/genproto/googleapis/api/annotations"
"google.golang.org/protobuf/proto"
)
type Method struct {
HttpMethod string
HttpPath string
RpcPath string
}
// GetMethods returns all methods of the given grpcurl.DescriptorSource.
func GetMethods(source grpcurl.DescriptorSource) ([]Method, error) {
svcs, err := source.ListServices()
if err != nil {
return nil, err
}
var methods []Method
for _, svc := range svcs {
d, err := source.FindSymbol(svc)
if err != nil {
return nil, err
}
switch val := d.(type) {
case *desc.ServiceDescriptor:
svcMethods := val.GetMethods()
for _, method := range svcMethods {
rpcPath := fmt.Sprintf("%s/%s", svc, method.GetName())
ext := proto.GetExtension(method.GetMethodOptions(), annotations.E_Http)
if ext == nil {
methods = append(methods, Method{
RpcPath: rpcPath,
})
continue
}
httpExt, ok := ext.(*annotations.HttpRule)
if !ok {
methods = append(methods, Method{
RpcPath: rpcPath,
})
continue
}
switch rule := httpExt.GetPattern().(type) {
case *annotations.HttpRule_Get:
methods = append(methods, Method{
HttpMethod: http.MethodGet,
HttpPath: adjustHttpPath(rule.Get),
RpcPath: rpcPath,
})
case *annotations.HttpRule_Post:
methods = append(methods, Method{
HttpMethod: http.MethodPost,
HttpPath: adjustHttpPath(rule.Post),
RpcPath: rpcPath,
})
case *annotations.HttpRule_Put:
methods = append(methods, Method{
HttpMethod: http.MethodPut,
HttpPath: adjustHttpPath(rule.Put),
RpcPath: rpcPath,
})
case *annotations.HttpRule_Delete:
methods = append(methods, Method{
HttpMethod: http.MethodDelete,
HttpPath: adjustHttpPath(rule.Delete),
RpcPath: rpcPath,
})
case *annotations.HttpRule_Patch:
methods = append(methods, Method{
HttpMethod: http.MethodPatch,
HttpPath: adjustHttpPath(rule.Patch),
RpcPath: rpcPath,
})
default:
methods = append(methods, Method{
RpcPath: rpcPath,
})
}
}
}
}
return methods, nil
}
func adjustHttpPath(path string) string {
path = strings.ReplaceAll(path, "{", ":")
path = strings.ReplaceAll(path, "}", "")
return path
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,30 @@
package internal
import (
"fmt"
"net/http"
"strings"
)
const (
metadataHeaderPrefix = "Grpc-Metadata-"
metadataPrefix = "gateway-"
)
// ProcessHeaders builds the headers for the gateway from HTTP headers.
func ProcessHeaders(header http.Header) []string {
var headers []string
for k, v := range header {
if !strings.HasPrefix(k, metadataHeaderPrefix) {
continue
}
key := fmt.Sprintf("%s%s", metadataPrefix, strings.TrimPrefix(k, metadataHeaderPrefix))
for _, vv := range v {
headers = append(headers, key+":"+vv)
}
}
return headers
}

View File

@@ -0,0 +1,21 @@
package internal
import (
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBuildHeadersNoValue(t *testing.T) {
req := httptest.NewRequest("GET", "/", nil)
req.Header.Add("a", "b")
assert.Nil(t, ProcessHeaders(req.Header))
}
func TestBuildHeadersWithValues(t *testing.T) {
req := httptest.NewRequest("GET", "/", nil)
req.Header.Add("grpc-metadata-a", "b")
req.Header.Add("grpc-metadata-b", "b")
assert.ElementsMatch(t, []string{"gateway-A:b", "gateway-B:b"}, ProcessHeaders(req.Header))
}

View File

@@ -0,0 +1,53 @@
package internal
import (
"bytes"
"encoding/json"
"net/http"
"github.com/fullstorydev/grpcurl"
"github.com/golang/protobuf/jsonpb"
"github.com/zeromicro/go-zero/rest/httpx"
"github.com/zeromicro/go-zero/rest/pathvar"
)
// NewRequestParser creates a new request parser from the given http.Request and resolver.
func NewRequestParser(r *http.Request, resolver jsonpb.AnyResolver) (grpcurl.RequestParser, error) {
vars := pathvar.Vars(r)
params, err := httpx.GetFormValues(r)
if err != nil {
return nil, err
}
for k, v := range vars {
params[k] = v
}
if len(params) == 0 {
return grpcurl.NewJSONRequestParser(r.Body, resolver), nil
}
if r.ContentLength == 0 {
return buildJsonRequestParser(params, resolver)
}
m := make(map[string]interface{})
if err := json.NewDecoder(r.Body).Decode(&m); err != nil {
return nil, err
}
for k, v := range params {
m[k] = v
}
return buildJsonRequestParser(m, resolver)
}
func buildJsonRequestParser(m map[string]interface{}, resolver jsonpb.AnyResolver) (
grpcurl.RequestParser, error) {
var buf bytes.Buffer
if err := json.NewEncoder(&buf).Encode(m); err != nil {
return nil, err
}
return grpcurl.NewJSONRequestParser(&buf, resolver), nil
}

View File

@@ -0,0 +1,55 @@
package internal
import (
"net/http/httptest"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/rest/pathvar"
)
func TestNewRequestParserNoVar(t *testing.T) {
req := httptest.NewRequest("GET", "/", nil)
parser, err := NewRequestParser(req, nil)
assert.Nil(t, err)
assert.NotNil(t, parser)
}
func TestNewRequestParserWithVars(t *testing.T) {
req := httptest.NewRequest("GET", "/", nil)
req = pathvar.WithVars(req, map[string]string{"a": "b"})
parser, err := NewRequestParser(req, nil)
assert.Nil(t, err)
assert.NotNil(t, parser)
}
func TestNewRequestParserNoVarWithBody(t *testing.T) {
req := httptest.NewRequest("GET", "/", strings.NewReader(`{"a": "b"}`))
parser, err := NewRequestParser(req, nil)
assert.Nil(t, err)
assert.NotNil(t, parser)
}
func TestNewRequestParserWithVarsWithBody(t *testing.T) {
req := httptest.NewRequest("GET", "/", strings.NewReader(`{"a": "b"}`))
req = pathvar.WithVars(req, map[string]string{"c": "d"})
parser, err := NewRequestParser(req, nil)
assert.Nil(t, err)
assert.NotNil(t, parser)
}
func TestNewRequestParserWithVarsWithWrongBody(t *testing.T) {
req := httptest.NewRequest("GET", "/", strings.NewReader(`{"a": "b"`))
req = pathvar.WithVars(req, map[string]string{"c": "d"})
parser, err := NewRequestParser(req, nil)
assert.NotNil(t, err)
assert.Nil(t, parser)
}
func TestNewRequestParserWithForm(t *testing.T) {
req := httptest.NewRequest("GET", "/val?a=b", nil)
parser, err := NewRequestParser(req, nil)
assert.Nil(t, err)
assert.NotNil(t, parser)
}

View File

@@ -0,0 +1,19 @@
package internal
import (
"net/http"
"time"
)
const grpcTimeoutHeader = "Grpc-Timeout"
// GetTimeout returns the timeout from the header, if not set, returns the default timeout.
func GetTimeout(header http.Header, defaultTimeout time.Duration) time.Duration {
if timeout := header.Get(grpcTimeoutHeader); len(timeout) > 0 {
if t, err := time.ParseDuration(timeout); err == nil {
return t
}
}
return defaultTimeout
}

View File

@@ -0,0 +1,22 @@
package internal
import (
"net/http/httptest"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestGetTimeout(t *testing.T) {
req := httptest.NewRequest("GET", "/", nil)
req.Header.Set(grpcTimeoutHeader, "1s")
timeout := GetTimeout(req.Header, time.Second*5)
assert.Equal(t, time.Second, timeout)
}
func TestGetTimeoutDefault(t *testing.T) {
req := httptest.NewRequest("GET", "/", nil)
timeout := GetTimeout(req.Header, time.Second*5)
assert.Equal(t, time.Second*5, timeout)
}

63
gateway/readme.md Normal file
View File

@@ -0,0 +1,63 @@
# Gateway
## Usage
- main.go
```go
var configFile = flag.String("f", "config.yaml", "config file")
func main() {
flag.Parse()
var c gateway.GatewayConf
conf.MustLoad(*configFile, &c)
gw := gateway.MustNewServer(c)
defer gw.Stop()
gw.Start()
}
```
- config.yaml
```yaml
Name: demo-gateway
Host: localhost
Port: 8888
Upstreams:
- Grpc:
Etcd:
Hosts:
- localhost:2379
Key: hello.rpc
# protoset mode
ProtoSets:
- hello.pb
# Mappings can also be written in proto options
Mappings:
- Method: get
Path: /pingHello/:ping
RpcPath: hello.Hello/Ping
- Grpc:
Endpoints:
- localhost:8081
# reflection mode, no ProtoSet settings
Mappings:
- Method: post
Path: /pingWorld
RpcPath: world.World/Ping
```
## Generate ProtoSet files
- example command without external imports
```shell
protoc --descriptor_set_out=hello.pb hello.proto
```
- example command with external imports
```shell
protoc --include_imports --proto_path=. --descriptor_set_out=hello.pb hello.proto
```

197
gateway/server.go Normal file
View File

@@ -0,0 +1,197 @@
package gateway
import (
"context"
"fmt"
"net/http"
"strings"
"time"
"github.com/fullstorydev/grpcurl"
"github.com/golang/protobuf/jsonpb"
"github.com/jhump/protoreflect/grpcreflect"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/mr"
"github.com/zeromicro/go-zero/gateway/internal"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/rest/httpx"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
)
type (
// Server is a gateway server.
Server struct {
*rest.Server
upstreams []Upstream
timeout time.Duration
processHeader func(http.Header) []string
}
// Option defines the method to customize Server.
Option func(svr *Server)
)
// MustNewServer creates a new gateway server.
func MustNewServer(c GatewayConf, opts ...Option) *Server {
svr := &Server{
Server: rest.MustNewServer(c.RestConf),
upstreams: c.Upstreams,
timeout: c.Timeout,
}
for _, opt := range opts {
opt(svr)
}
return svr
}
// Start starts the gateway server.
func (s *Server) Start() {
logx.Must(s.build())
s.Server.Start()
}
// Stop stops the gateway server.
func (s *Server) Stop() {
s.Server.Stop()
}
func (s *Server) build() error {
if err := s.ensureUpstreamNames(); err != nil {
return err
}
return mr.MapReduceVoid(func(source chan<- interface{}) {
for _, up := range s.upstreams {
source <- up
}
}, func(item interface{}, writer mr.Writer, cancel func(error)) {
up := item.(Upstream)
cli := zrpc.MustNewClient(up.Grpc)
source, err := s.createDescriptorSource(cli, up)
if err != nil {
cancel(fmt.Errorf("%s: %w", up.Name, err))
return
}
methods, err := internal.GetMethods(source)
if err != nil {
cancel(fmt.Errorf("%s: %w", up.Name, err))
return
}
resolver := grpcurl.AnyResolverFromDescriptorSource(source)
for _, m := range methods {
if len(m.HttpMethod) > 0 && len(m.HttpPath) > 0 {
writer.Write(rest.Route{
Method: m.HttpMethod,
Path: m.HttpPath,
Handler: s.buildHandler(source, resolver, cli, m.RpcPath),
})
}
}
methodSet := make(map[string]struct{})
for _, m := range methods {
methodSet[m.RpcPath] = struct{}{}
}
for _, m := range up.Mappings {
if _, ok := methodSet[m.RpcPath]; !ok {
cancel(fmt.Errorf("%s: rpc method %s not found", up.Name, m.RpcPath))
return
}
writer.Write(rest.Route{
Method: strings.ToUpper(m.Method),
Path: m.Path,
Handler: s.buildHandler(source, resolver, cli, m.RpcPath),
})
}
}, func(pipe <-chan interface{}, cancel func(error)) {
for item := range pipe {
route := item.(rest.Route)
s.Server.AddRoute(route)
}
})
}
func (s *Server) buildHandler(source grpcurl.DescriptorSource, resolver jsonpb.AnyResolver,
cli zrpc.Client, rpcPath string) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
handler := &grpcurl.DefaultEventHandler{
Out: w,
Formatter: grpcurl.NewJSONFormatter(true,
grpcurl.AnyResolverFromDescriptorSource(source)),
}
parser, err := internal.NewRequestParser(r, resolver)
if err != nil {
httpx.Error(w, err)
return
}
timeout := internal.GetTimeout(r.Header, s.timeout)
ctx, can := context.WithTimeout(r.Context(), timeout)
defer can()
w.Header().Set(httpx.ContentType, httpx.JsonContentType)
if err := grpcurl.InvokeRPC(ctx, source, cli.Conn(), rpcPath, s.prepareMetadata(r.Header),
handler, parser.Next); err != nil {
httpx.Error(w, err)
}
st := handler.Status
if st.Code() != codes.OK {
httpx.Error(w, st.Err())
}
}
}
func (s *Server) createDescriptorSource(cli zrpc.Client, up Upstream) (grpcurl.DescriptorSource, error) {
var source grpcurl.DescriptorSource
var err error
if len(up.ProtoSets) > 0 {
source, err = grpcurl.DescriptorSourceFromProtoSets(up.ProtoSets...)
if err != nil {
return nil, err
}
} else {
refCli := grpc_reflection_v1alpha.NewServerReflectionClient(cli.Conn())
client := grpcreflect.NewClient(context.Background(), refCli)
source = grpcurl.DescriptorSourceFromServer(context.Background(), client)
}
return source, nil
}
func (s *Server) ensureUpstreamNames() error {
for _, up := range s.upstreams {
target, err := up.Grpc.BuildTarget()
if err != nil {
return err
}
up.Name = target
}
return nil
}
func (s *Server) prepareMetadata(header http.Header) []string {
vals := internal.ProcessHeaders(header)
if s.processHeader != nil {
vals = append(vals, s.processHeader(header)...)
}
return vals
}
// WithHeaderProcessor sets a processor to process request headers.
// The returned headers are used as metadata to invoke the RPC.
func WithHeaderProcessor(processHeader func(http.Header) []string) func(*Server) {
return func(s *Server) {
s.processHeader = processHeader
}
}

33
go.mod
View File

@@ -3,44 +3,47 @@ module github.com/zeromicro/go-zero
go 1.16 go 1.16
require ( require (
github.com/ClickHouse/clickhouse-go/v2 v2.0.14 github.com/ClickHouse/clickhouse-go/v2 v2.2.0
github.com/DATA-DOG/go-sqlmock v1.5.0 github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/alicebob/miniredis/v2 v2.21.0 github.com/alicebob/miniredis/v2 v2.22.0
github.com/fatih/color v1.13.0 github.com/fatih/color v1.13.0
github.com/fullstorydev/grpcurl v1.8.6
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
github.com/go-redis/redis/v8 v8.11.5 github.com/go-redis/redis/v8 v8.11.5
github.com/go-sql-driver/mysql v1.6.0 github.com/go-sql-driver/mysql v1.6.0
github.com/golang-jwt/jwt/v4 v4.4.1 github.com/golang-jwt/jwt/v4 v4.4.2
github.com/golang/mock v1.6.0 github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/jhump/protoreflect v1.12.0
github.com/justinas/alice v1.2.0 github.com/justinas/alice v1.2.0
github.com/lib/pq v1.10.6 github.com/lib/pq v1.10.6
github.com/olekukonko/tablewriter v0.0.5 github.com/olekukonko/tablewriter v0.0.5
github.com/pelletier/go-toml/v2 v2.0.1 github.com/pelletier/go-toml/v2 v2.0.2
github.com/prometheus/client_golang v1.12.2 github.com/prometheus/client_golang v1.12.2
github.com/spaolacci/murmur3 v1.1.0 github.com/spaolacci/murmur3 v1.1.0
github.com/stretchr/testify v1.7.1 github.com/stretchr/testify v1.8.0
go.etcd.io/etcd/api/v3 v3.5.4 go.etcd.io/etcd/api/v3 v3.5.4
go.etcd.io/etcd/client/v3 v3.5.4 go.etcd.io/etcd/client/v3 v3.5.4
go.mongodb.org/mongo-driver v1.9.1 go.mongodb.org/mongo-driver v1.10.1
go.opentelemetry.io/otel v1.7.0 go.opentelemetry.io/otel v1.9.0
go.opentelemetry.io/otel/exporters/jaeger v1.7.0 go.opentelemetry.io/otel/exporters/jaeger v1.9.0
go.opentelemetry.io/otel/exporters/zipkin v1.7.0 go.opentelemetry.io/otel/exporters/zipkin v1.9.0
go.opentelemetry.io/otel/sdk v1.7.0 go.opentelemetry.io/otel/sdk v1.9.0
go.opentelemetry.io/otel/trace v1.7.0 go.opentelemetry.io/otel/trace v1.9.0
go.uber.org/automaxprocs v1.5.1 go.uber.org/automaxprocs v1.5.1
go.uber.org/goleak v1.1.12 go.uber.org/goleak v1.1.12
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
golang.org/x/time v0.0.0-20220411224347-583f2d630306 golang.org/x/time v0.0.0-20220411224347-583f2d630306
google.golang.org/grpc v1.47.0 google.golang.org/grpc v1.48.0
google.golang.org/protobuf v1.28.0 google.golang.org/protobuf v1.28.1
gopkg.in/cheggaaa/pb.v1 v1.0.28 gopkg.in/cheggaaa/pb.v1 v1.0.28
gopkg.in/h2non/gock.v1 v1.1.2 gopkg.in/h2non/gock.v1 v1.1.2
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.22.9 k8s.io/api v0.22.9
k8s.io/apimachinery v0.22.9 k8s.io/apimachinery v0.22.9
k8s.io/client-go v0.22.9 k8s.io/client-go v0.22.9
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 k8s.io/utils v0.0.0-20220706174534-f6158b442e7c
) )
require ( require (
@@ -51,6 +54,6 @@ require (
go.uber.org/multierr v1.8.0 // indirect go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect go.uber.org/zap v1.21.0 // indirect
golang.org/x/net v0.0.0-20220531201128-c960675eff93 // indirect golang.org/x/net v0.0.0-20220531201128-c960675eff93 // indirect
google.golang.org/genproto v0.0.0-20220602131408-e326c6e8e9c8 // indirect google.golang.org/genproto v0.0.0-20220602131408-e326c6e8e9c8
k8s.io/klog/v2 v2.40.1 // indirect k8s.io/klog/v2 v2.40.1 // indirect
) )

104
go.sum
View File

@@ -42,8 +42,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0= github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0=
github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI=
github.com/ClickHouse/clickhouse-go/v2 v2.0.14 h1:7HW+MXPaQfVyCzPGEn/LciMc8K6cG58FZMUc7DXQmro= github.com/ClickHouse/clickhouse-go/v2 v2.2.0 h1:dj00TDKY+xwuTJdbpspCSmTLFyWzRJerTHwaBxut1C0=
github.com/ClickHouse/clickhouse-go/v2 v2.0.14/go.mod h1:iq2DUGgpA4BBki2CVwrF8x43zqBjdgHtbexkFkh5a6M= github.com/ClickHouse/clickhouse-go/v2 v2.2.0/go.mod h1:8f2XZUi7XoeU+uPIytSi1cvx8fmJxi7vIgqpvYTF1+o=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
@@ -59,8 +59,8 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk=
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.21.0 h1:CdmwIlKUWFBDS+4464GtQiQ0R1vpzOgu4Vnd74rBL7M= github.com/alicebob/miniredis/v2 v2.22.0 h1:lIHHiSkEyS1MkKHCHzN+0mWrA4YdbGdimE5iZ2sHSzo=
github.com/alicebob/miniredis/v2 v2.21.0/go.mod h1:XNqvJdQJv5mSuVMc0ynneafpnL/zv52acZ6kqeS0t88= github.com/alicebob/miniredis/v2 v2.22.0/go.mod h1:XNqvJdQJv5mSuVMc0ynneafpnL/zv52acZ6kqeS0t88=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
@@ -122,6 +122,8 @@ github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fullstorydev/grpcurl v1.8.6 h1:WylAwnPauJIofYSHqqMTC1eEfUIzqzevXyogBxnQquo=
github.com/fullstorydev/grpcurl v1.8.6/go.mod h1:WhP7fRQdhxz2TkL97u+TCb505sxfH78W1usyoB3tepw=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is=
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
@@ -143,6 +145,7 @@ github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8=
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
@@ -151,15 +154,14 @@ github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.4.1 h1:pC5DB52sCeK48Wlb9oPcdhnjkz1TKt1D/P7WKJ0kUcQ= github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs=
github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -208,8 +210,9 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
@@ -234,6 +237,7 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m
github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU=
github.com/googleapis/gnostic v0.5.5 h1:9fHAtK0uDfpveeqqo1hkEZJcFvYXAiCN3UutL8F9xHw= github.com/googleapis/gnostic v0.5.5 h1:9fHAtK0uDfpveeqqo1hkEZJcFvYXAiCN3UutL8F9xHw=
github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA= github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA=
github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU=
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
@@ -258,6 +262,13 @@ github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/U
github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg= github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
github.com/jcmturner/gokrb5/v8 v8.4.2/go.mod h1:sb+Xq/fTY5yktf/VxLsE3wlfPqQjp0aWNYyvBVK62bc= github.com/jcmturner/gokrb5/v8 v8.4.2/go.mod h1:sb+Xq/fTY5yktf/VxLsE3wlfPqQjp0aWNYyvBVK62bc=
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
github.com/jhump/gopoet v0.0.0-20190322174617-17282ff210b3/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI=
github.com/jhump/gopoet v0.1.0/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI=
github.com/jhump/goprotoc v0.5.0/go.mod h1:VrbvcYrQOrTi3i0Vf+m+oqQWk9l72mjkJCYo7UvLHRQ=
github.com/jhump/protoreflect v1.10.3/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg=
github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E=
github.com/jhump/protoreflect v1.12.0 h1:1NQ4FpWMgn3by/n1X0fbeKEUxP1wBt7+Oitpv01HR10=
github.com/jhump/protoreflect v1.12.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
@@ -313,6 +324,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
@@ -321,6 +333,7 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= 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 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
@@ -343,17 +356,17 @@ github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/openzipkin/zipkin-go v0.4.0 h1:CtfRrOVZtbDj8rt1WXjklw0kqqJQwICrCKmlfUuBUUw= github.com/openzipkin/zipkin-go v0.4.0 h1:CtfRrOVZtbDj8rt1WXjklw0kqqJQwICrCKmlfUuBUUw=
github.com/openzipkin/zipkin-go v0.4.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ= github.com/openzipkin/zipkin-go v0.4.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ=
github.com/paulmach/orb v0.5.0 h1:sNhJV5ML+mv1F077ljOck/9inorF4ahDO8iNNpHbKHY= github.com/paulmach/orb v0.7.1 h1:Zha++Z5OX/l168sqHK3k4z18LDvr+YAO/VjK0ReQ9rU=
github.com/paulmach/orb v0.5.0/go.mod h1:FWRlTgl88VI1RBx/MkrwWDRhQ96ctqMCh8boXhmqB/A= github.com/paulmach/orb v0.7.1/go.mod h1:FWRlTgl88VI1RBx/MkrwWDRhQ96ctqMCh8boXhmqB/A=
github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=
github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU= github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw=
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pierrec/lz4/v4 v4.1.14 h1:+fL8AQEZtz/ijeNnpduH0bROTu0O3NZAlPjQxGn8LwE= github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0=
github.com/pierrec/lz4/v4 v4.1.14/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -410,16 +423,20 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 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.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.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 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.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/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
@@ -427,10 +444,12 @@ github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hM
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w=
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc= github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -440,29 +459,32 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 h1:k/gmLsJDWwWqbLCur2yWnJzwQEKRcAHXo6seXGuSwWw= github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 h1:k/gmLsJDWwWqbLCur2yWnJzwQEKRcAHXo6seXGuSwWw=
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA= github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.etcd.io/etcd/api/v3 v3.5.4 h1:OHVyt3TopwtUQ2GKdd5wu3PmmipR4FTwCqoEjSyRdIc= go.etcd.io/etcd/api/v3 v3.5.4 h1:OHVyt3TopwtUQ2GKdd5wu3PmmipR4FTwCqoEjSyRdIc=
go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=
go.etcd.io/etcd/client/pkg/v3 v3.5.4 h1:lrneYvz923dvC14R54XcA7FXoZ3mlGZAgmwhfm7HqOg= go.etcd.io/etcd/client/pkg/v3 v3.5.4 h1:lrneYvz923dvC14R54XcA7FXoZ3mlGZAgmwhfm7HqOg=
go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v3 v3.5.4 h1:p83BUL3tAYS0OT/r0qglgc3M1JjhM0diV8DSWAhVXv4= go.etcd.io/etcd/client/v3 v3.5.4 h1:p83BUL3tAYS0OT/r0qglgc3M1JjhM0diV8DSWAhVXv4=
go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/gq3kiY= go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/gq3kiY=
go.mongodb.org/mongo-driver v1.9.1 h1:m078y9v7sBItkt1aaoe2YlvWEXcD263e1a4E1fBrJ1c= go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4=
go.mongodb.org/mongo-driver v1.9.1/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM=
go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk=
go.opentelemetry.io/otel/exporters/jaeger v1.7.0 h1:wXgjiRldljksZkZrldGVe6XrG9u3kYDyQmkZwmm5dI0= go.opentelemetry.io/otel v1.9.0 h1:8WZNQFIB2a71LnANS9JeyidJKKGOOremcUtb/OtHISw=
go.opentelemetry.io/otel/exporters/jaeger v1.7.0/go.mod h1:PwQAOqBgqbLQRKlj466DuD2qyMjbtcPpfPfj+AqbSBs= go.opentelemetry.io/otel v1.9.0/go.mod h1:np4EoPGzoPs3O67xUVNoPPcmSvsfOxNlNA4F4AC+0Eo=
go.opentelemetry.io/otel/exporters/zipkin v1.7.0 h1:X0FZj+kaIdLi29UiyrEGDhRTYsEXj9GdEW5Y39UQFEE= go.opentelemetry.io/otel/exporters/jaeger v1.9.0 h1:gAEgEVGDWwFjcis9jJTOJqZNxDzoZfR12WNIxr7g9Ww=
go.opentelemetry.io/otel/exporters/zipkin v1.7.0/go.mod h1:9YBXeOMFLQGwNEjsxMRiWPGoJX83usGMhbCmxUbNe5I= go.opentelemetry.io/otel/exporters/jaeger v1.9.0/go.mod h1:hquezOLVAybNW6vanIxkdLXTXvzlj2Vn3wevSP15RYs=
go.opentelemetry.io/otel/sdk v1.7.0 h1:4OmStpcKVOfvDOgCt7UriAPtKolwIhxpnSNI/yK+1B0= go.opentelemetry.io/otel/exporters/zipkin v1.9.0 h1:06b/nt6xao6th00aue9WU3ZDTTe+InaMXA/vym6pLuA=
go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU= go.opentelemetry.io/otel/exporters/zipkin v1.9.0/go.mod h1:HyIvYIu37wV4Wx5azd7e05x9k/dOz9KB4x0plw2QNvs=
go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o= go.opentelemetry.io/otel/sdk v1.9.0 h1:LNXp1vrr83fNXTHgU8eO89mhzxb/bbWAsHG6fNf3qWo=
go.opentelemetry.io/otel/sdk v1.9.0/go.mod h1:AEZc8nt5bd2F7BC24J5R0mrjYnpEgYHyTcM/vrSple4=
go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU=
go.opentelemetry.io/otel/trace v1.9.0 h1:oZaCNJUjWcg60VXWee8lJKlqhPbXAPB51URuR47pQYc=
go.opentelemetry.io/otel/trace v1.9.0/go.mod h1:2737Q0MuG8q1uILYm2YYVkAyLtOofiTNGg6VODnOiPo=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
@@ -486,10 +508,10 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 h1:kETrAMYZq6WVGPa8IIixL0CaEcIUNi+1WX7grUoi3y8=
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -560,6 +582,7 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220531201128-c960675eff93 h1:MYimHLfoXEpOhqd/zgoA/uoXzHB86AEky4LAx5ij9xA= golang.org/x/net v0.0.0-20220531201128-c960675eff93 h1:MYimHLfoXEpOhqd/zgoA/uoXzHB86AEky4LAx5ij9xA=
golang.org/x/net v0.0.0-20220531201128-c960675eff93/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220531201128-c960675eff93/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
@@ -597,6 +620,7 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -671,7 +695,6 @@ golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
@@ -699,8 +722,10 @@ golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWc
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
@@ -713,7 +738,6 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
@@ -788,9 +812,10 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8= google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w=
google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -801,11 +826,13 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 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-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -834,8 +861,9 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 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-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/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= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
@@ -856,8 +884,8 @@ k8s.io/klog/v2 v2.40.1 h1:P4RRucWk/lFOlDdkAr3mc7iWFkgKrZY9qZMAgek06S4=
k8s.io/klog/v2 v2.40.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/klog/v2 v2.40.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw=
k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc= k8s.io/utils v0.0.0-20220706174534-f6158b442e7c h1:hFZO68mv/0xe8+V0gRT9BAq3/31cKjjeVv4nScriuBk=
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20220706174534-f6158b442e7c/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

View File

@@ -23,7 +23,7 @@
> >
> `GOPROXY=https://goproxy.cn/,direct go install github.com/zeromicro/go-zero/tools/goctl@latest` > `GOPROXY=https://goproxy.cn/,direct go install github.com/zeromicro/go-zero/tools/goctl@latest`
> >
> `goctl migrate —verbose —version v1.3.4` > `goctl migrate —verbose —version v1.4.0`
## 0. go-zero 介绍 ## 0. go-zero 介绍
@@ -116,7 +116,7 @@ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/zeromicro
1. 安装 goctl 工具 1. 安装 goctl 工具
`goctl` 读作 `go control`,不要读成 `go C-T-L``goctl` 的意思是不要被代码控制,而是要去控制它。其中的 `go` 不是指 `golang`。在设计 `goctl` 之初,我就希望通过 `` 来解放我们的双手👈 `goctl` 读作 `go control`,不要读成 `go C-T-L``goctl` 的意思是不要被代码控制,而是要去控制它。其中的 `go` 不是指 `golang`。在设计 `goctl` 之初,我就希望通过 `工具` 来解放我们的双手👈
```shell ```shell
# Go 1.15 及之前版本 # Go 1.15 及之前版本
@@ -283,6 +283,11 @@ go-zero 已被许多公司用于生产部署,接入场景如在线教育、电
>68. 得物 >68. 得物
>69. 鼎翰文化股份有限公司 >69. 鼎翰文化股份有限公司
>70. 茶码纹化(云南)科技发展有限公司 >70. 茶码纹化(云南)科技发展有限公司
>71. 湖南度思信息技术有限公司
>72. 深圳圆度
>73. 武汉沃柒科技有限公司(茄椒)
>74. 驭势科技
>75. 叮当跳动
如果贵公司也已使用 go-zero欢迎在 [登记地址](https://github.com/zeromicro/go-zero/issues/602) 登记,仅仅为了推广,不做其它用途。 如果贵公司也已使用 go-zero欢迎在 [登记地址](https://github.com/zeromicro/go-zero/issues/602) 登记,仅仅为了推广,不做其它用途。

View File

@@ -21,7 +21,7 @@ English | [简体中文](readme-cn.md)
> >
> `go install github.com/zeromicro/go-zero/tools/goctl@latest` > `go install github.com/zeromicro/go-zero/tools/goctl@latest`
> >
> `goctl migrate —verbose —version v1.3.4` > `goctl migrate —verbose —version v1.4.0`
## 0. what is go-zero ## 0. what is go-zero
@@ -237,7 +237,7 @@ go get -u github.com/zeromicro/go-zero
## 8. Documents ## 8. Documents
* [Documents](https://go-zero.dev/en/) * [Documents](https://go-zero.dev/)
* [Rapid development of microservice systems](https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl-en.md) * [Rapid development of microservice systems](https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl-en.md)
* [Rapid development of microservice systems - multiple RPCs](https://github.com/zeromicro/zero-doc/blob/main/docs/zero/bookstore-en.md) * [Rapid development of microservice systems - multiple RPCs](https://github.com/zeromicro/zero-doc/blob/main/docs/zero/bookstore-en.md)
* [Examples](https://github.com/zeromicro/zero-examples) * [Examples](https://github.com/zeromicro/zero-examples)
@@ -258,3 +258,7 @@ go-zero enlisted in the [CNCF Cloud Native Landscape](https://landscape.cncf.io/
## Give a Star! ⭐ ## Give a Star! ⭐
If you like or are using this project to learn or start your solution, please give it a star. Thanks! If you like or are using this project to learn or start your solution, please give it a star. Thanks!
## Buy me a coffee
<a href="https://www.buymeacoffee.com/kevwan" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

109
rest/chain/chain.go Normal file
View File

@@ -0,0 +1,109 @@
package chain
// This is a modified version of https://github.com/justinas/alice
// The original code is licensed under the MIT license.
// It's modified for couple reasons:
// - Added the Chain interface
// - Added support for the Chain.Prepend(...) method
import "net/http"
type (
// Chain defines a chain of middleware.
Chain interface {
Append(middlewares ...Middleware) Chain
Prepend(middlewares ...Middleware) Chain
Then(h http.Handler) http.Handler
ThenFunc(fn http.HandlerFunc) http.Handler
}
// Middleware is an HTTP middleware.
Middleware func(http.Handler) http.Handler
// chain acts as a list of http.Handler middlewares.
// chain is effectively immutable:
// once created, it will always hold
// the same set of middlewares in the same order.
chain struct {
middlewares []Middleware
}
)
// New creates a new Chain, memorizing the given list of middleware middlewares.
// New serves no other function, middlewares are only called upon a call to Then() or ThenFunc().
func New(middlewares ...Middleware) Chain {
return chain{middlewares: append(([]Middleware)(nil), middlewares...)}
}
// Append extends a chain, adding the specified middlewares as the last ones in the request flow.
//
// c := chain.New(m1, m2)
// c.Append(m3, m4)
// // requests in c go m1 -> m2 -> m3 -> m4
func (c chain) Append(middlewares ...Middleware) Chain {
return chain{middlewares: join(c.middlewares, middlewares)}
}
// Prepend extends a chain by adding the specified chain as the first one in the request flow.
//
// c := chain.New(m3, m4)
// c1 := chain.New(m1, m2)
// c.Prepend(c1)
// // requests in c go m1 -> m2 -> m3 -> m4
func (c chain) Prepend(middlewares ...Middleware) Chain {
return chain{middlewares: join(middlewares, c.middlewares)}
}
// Then chains the middleware and returns the final http.Handler.
// New(m1, m2, m3).Then(h)
// is equivalent to:
// m1(m2(m3(h)))
// When the request comes in, it will be passed to m1, then m2, then m3
// and finally, the given handler
// (assuming every middleware calls the following one).
//
// A chain can be safely reused by calling Then() several times.
// stdStack := chain.New(ratelimitHandler, csrfHandler)
// indexPipe = stdStack.Then(indexHandler)
// authPipe = stdStack.Then(authHandler)
// Note that middlewares are called on every call to Then() or ThenFunc()
// and thus several instances of the same middleware will be created
// when a chain is reused in this way.
// For proper middleware, this should cause no problems.
//
// Then() treats nil as http.DefaultServeMux.
func (c chain) Then(h http.Handler) http.Handler {
if h == nil {
h = http.DefaultServeMux
}
for i := range c.middlewares {
h = c.middlewares[len(c.middlewares)-1-i](h)
}
return h
}
// ThenFunc works identically to Then, but takes
// a HandlerFunc instead of a Handler.
//
// The following two statements are equivalent:
// c.Then(http.HandlerFunc(fn))
// c.ThenFunc(fn)
//
// ThenFunc provides all the guarantees of Then.
func (c chain) ThenFunc(fn http.HandlerFunc) http.Handler {
// This nil check cannot be removed due to the "nil is not nil" common mistake in Go.
// Required due to: https://stackoverflow.com/questions/33426977/how-to-golang-check-a-variable-is-nil
if fn == nil {
return c.Then(nil)
}
return c.Then(fn)
}
func join(a, b []Middleware) []Middleware {
mids := make([]Middleware, 0, len(a)+len(b))
mids = append(mids, a...)
mids = append(mids, b...)
return mids
}

126
rest/chain/chain_test.go Normal file
View File

@@ -0,0 +1,126 @@
package chain
import (
"net/http"
"net/http/httptest"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
// A constructor for middleware
// that writes its own "tag" into the RW and does nothing else.
// Useful in checking if a chain is behaving in the right order.
func tagMiddleware(tag string) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(tag))
h.ServeHTTP(w, r)
})
}
}
// Not recommended (https://golang.org/pkg/reflect/#Value.Pointer),
// but the best we can do.
func funcsEqual(f1, f2 interface{}) bool {
val1 := reflect.ValueOf(f1)
val2 := reflect.ValueOf(f2)
return val1.Pointer() == val2.Pointer()
}
var testApp = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("app\n"))
})
func TestNew(t *testing.T) {
c1 := func(h http.Handler) http.Handler {
return nil
}
c2 := func(h http.Handler) http.Handler {
return http.StripPrefix("potato", nil)
}
slice := []Middleware{c1, c2}
c := New(slice...)
for k := range slice {
assert.True(t, funcsEqual(c.(chain).middlewares[k], slice[k]),
"New does not add constructors correctly")
}
}
func TestThenWorksWithNoMiddleware(t *testing.T) {
assert.True(t, funcsEqual(New().Then(testApp), testApp),
"Then does not work with no middleware")
}
func TestThenTreatsNilAsDefaultServeMux(t *testing.T) {
assert.Equal(t, http.DefaultServeMux, New().Then(nil),
"Then does not treat nil as DefaultServeMux")
}
func TestThenFuncTreatsNilAsDefaultServeMux(t *testing.T) {
assert.Equal(t, http.DefaultServeMux, New().ThenFunc(nil),
"ThenFunc does not treat nil as DefaultServeMux")
}
func TestThenFuncConstructsHandlerFunc(t *testing.T) {
fn := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
})
chained := New().ThenFunc(fn)
rec := httptest.NewRecorder()
chained.ServeHTTP(rec, (*http.Request)(nil))
assert.Equal(t, reflect.TypeOf((http.HandlerFunc)(nil)), reflect.TypeOf(chained),
"ThenFunc does not construct HandlerFunc")
}
func TestThenOrdersHandlersCorrectly(t *testing.T) {
t1 := tagMiddleware("t1\n")
t2 := tagMiddleware("t2\n")
t3 := tagMiddleware("t3\n")
chained := New(t1, t2, t3).Then(testApp)
w := httptest.NewRecorder()
r, err := http.NewRequest("GET", "/", nil)
if err != nil {
t.Fatal(err)
}
chained.ServeHTTP(w, r)
assert.Equal(t, "t1\nt2\nt3\napp\n", w.Body.String(),
"Then does not order handlers correctly")
}
func TestAppendAddsHandlersCorrectly(t *testing.T) {
c := New(tagMiddleware("t1\n"), tagMiddleware("t2\n"))
c = c.Append(tagMiddleware("t3\n"), tagMiddleware("t4\n"))
h := c.Then(testApp)
w := httptest.NewRecorder()
r, err := http.NewRequest("GET", "/", nil)
assert.Nil(t, err)
h.ServeHTTP(w, r)
assert.Equal(t, "t1\nt2\nt3\nt4\napp\n", w.Body.String(),
"Append does not add handlers correctly")
}
func TestExtendAddsHandlersCorrectly(t *testing.T) {
c := New(tagMiddleware("t3\n"), tagMiddleware("t4\n"))
c = c.Prepend(tagMiddleware("t1\n"), tagMiddleware("t2\n"))
h := c.Then(testApp)
w := httptest.NewRecorder()
r, err := http.NewRequest("GET", "/", nil)
assert.Nil(t, err)
h.ServeHTTP(w, r)
assert.Equal(t, "t1\nt2\nt3\nt4\napp\n", w.Body.String(),
"Extend does not add handlers in correctly")
}

View File

@@ -8,10 +8,10 @@ import (
"sort" "sort"
"time" "time"
"github.com/justinas/alice"
"github.com/zeromicro/go-zero/core/codec" "github.com/zeromicro/go-zero/core/codec"
"github.com/zeromicro/go-zero/core/load" "github.com/zeromicro/go-zero/core/load"
"github.com/zeromicro/go-zero/core/stat" "github.com/zeromicro/go-zero/core/stat"
"github.com/zeromicro/go-zero/rest/chain"
"github.com/zeromicro/go-zero/rest/handler" "github.com/zeromicro/go-zero/rest/handler"
"github.com/zeromicro/go-zero/rest/httpx" "github.com/zeromicro/go-zero/rest/httpx"
"github.com/zeromicro/go-zero/rest/internal" "github.com/zeromicro/go-zero/rest/internal"
@@ -29,6 +29,7 @@ type engine struct {
routes []featuredRoutes routes []featuredRoutes
unauthorizedCallback handler.UnauthorizedCallback unauthorizedCallback handler.UnauthorizedCallback
unsignedCallback handler.UnsignedCallback unsignedCallback handler.UnsignedCallback
chain chain.Chain
middlewares []Middleware middlewares []Middleware
shedder load.Shedder shedder load.Shedder
priorityShedder load.Shedder priorityShedder load.Shedder
@@ -52,20 +53,20 @@ func (ng *engine) addRoutes(r featuredRoutes) {
ng.routes = append(ng.routes, r) ng.routes = append(ng.routes, r)
} }
func (ng *engine) appendAuthHandler(fr featuredRoutes, chain alice.Chain, func (ng *engine) appendAuthHandler(fr featuredRoutes, chn chain.Chain,
verifier func(alice.Chain) alice.Chain) alice.Chain { verifier func(chain.Chain) chain.Chain) chain.Chain {
if fr.jwt.enabled { if fr.jwt.enabled {
if len(fr.jwt.prevSecret) == 0 { if len(fr.jwt.prevSecret) == 0 {
chain = chain.Append(handler.Authorize(fr.jwt.secret, chn = chn.Append(handler.Authorize(fr.jwt.secret,
handler.WithUnauthorizedCallback(ng.unauthorizedCallback))) handler.WithUnauthorizedCallback(ng.unauthorizedCallback)))
} else { } else {
chain = chain.Append(handler.Authorize(fr.jwt.secret, chn = chn.Append(handler.Authorize(fr.jwt.secret,
handler.WithPrevSecret(fr.jwt.prevSecret), handler.WithPrevSecret(fr.jwt.prevSecret),
handler.WithUnauthorizedCallback(ng.unauthorizedCallback))) handler.WithUnauthorizedCallback(ng.unauthorizedCallback)))
} }
} }
return verifier(chain) return verifier(chn)
} }
func (ng *engine) bindFeaturedRoutes(router httpx.Router, fr featuredRoutes, metrics *stat.Metrics) error { func (ng *engine) bindFeaturedRoutes(router httpx.Router, fr featuredRoutes, metrics *stat.Metrics) error {
@@ -84,26 +85,30 @@ func (ng *engine) bindFeaturedRoutes(router httpx.Router, fr featuredRoutes, met
} }
func (ng *engine) bindRoute(fr featuredRoutes, router httpx.Router, metrics *stat.Metrics, func (ng *engine) bindRoute(fr featuredRoutes, router httpx.Router, metrics *stat.Metrics,
route Route, verifier func(chain alice.Chain) alice.Chain) error { route Route, verifier func(chain.Chain) chain.Chain) error {
chain := alice.New( chn := ng.chain
handler.TracingHandler(ng.conf.Name, route.Path), if chn == nil {
ng.getLogHandler(), chn = chain.New(
handler.PrometheusHandler(route.Path), handler.TracingHandler(ng.conf.Name, route.Path),
handler.MaxConns(ng.conf.MaxConns), ng.getLogHandler(),
handler.BreakerHandler(route.Method, route.Path, metrics), handler.PrometheusHandler(route.Path),
handler.SheddingHandler(ng.getShedder(fr.priority), metrics), handler.MaxConns(ng.conf.MaxConns),
handler.TimeoutHandler(ng.checkedTimeout(fr.timeout)), handler.BreakerHandler(route.Method, route.Path, metrics),
handler.RecoverHandler, handler.SheddingHandler(ng.getShedder(fr.priority), metrics),
handler.MetricHandler(metrics), handler.TimeoutHandler(ng.checkedTimeout(fr.timeout)),
handler.MaxBytesHandler(ng.checkedMaxBytes(fr.maxBytes)), handler.RecoverHandler,
handler.GunzipHandler, handler.MetricHandler(metrics),
) handler.MaxBytesHandler(ng.checkedMaxBytes(fr.maxBytes)),
chain = ng.appendAuthHandler(fr, chain, verifier) handler.GunzipHandler,
)
}
chn = ng.appendAuthHandler(fr, chn, verifier)
for _, middleware := range ng.middlewares { for _, middleware := range ng.middlewares {
chain = chain.Append(convertMiddleware(middleware)) chn = chn.Append(convertMiddleware(middleware))
} }
handle := chain.ThenFunc(route.Handler) handle := chn.ThenFunc(route.Handler)
return router.Handle(route.Method, route.Path, handle) return router.Handle(route.Method, route.Path, handle)
} }
@@ -167,16 +172,16 @@ func (ng *engine) getShedder(priority bool) load.Shedder {
// notFoundHandler returns a middleware that handles 404 not found requests. // notFoundHandler returns a middleware that handles 404 not found requests.
func (ng *engine) notFoundHandler(next http.Handler) http.Handler { func (ng *engine) notFoundHandler(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
chain := alice.New( chn := chain.New(
handler.TracingHandler(ng.conf.Name, ""), handler.TracingHandler(ng.conf.Name, ""),
ng.getLogHandler(), ng.getLogHandler(),
) )
var h http.Handler var h http.Handler
if next != nil { if next != nil {
h = chain.Then(next) h = chn.Then(next)
} else { } else {
h = chain.Then(http.NotFoundHandler()) h = chn.Then(http.NotFoundHandler())
} }
cw := response.NewHeaderOnceResponseWriter(w) cw := response.NewHeaderOnceResponseWriter(w)
@@ -214,10 +219,10 @@ func (ng *engine) setUnsignedCallback(callback handler.UnsignedCallback) {
ng.unsignedCallback = callback ng.unsignedCallback = callback
} }
func (ng *engine) signatureVerifier(signature signatureSetting) (func(chain alice.Chain) alice.Chain, error) { func (ng *engine) signatureVerifier(signature signatureSetting) (func(chain.Chain) chain.Chain, error) {
if !signature.enabled { if !signature.enabled {
return func(chain alice.Chain) alice.Chain { return func(chn chain.Chain) chain.Chain {
return chain return chn
}, nil }, nil
} }
@@ -226,8 +231,8 @@ func (ng *engine) signatureVerifier(signature signatureSetting) (func(chain alic
return nil, ErrSignatureConfig return nil, ErrSignatureConfig
} }
return func(chain alice.Chain) alice.Chain { return func(chn chain.Chain) chain.Chain {
return chain return chn
}, nil }, nil
} }
@@ -243,14 +248,13 @@ func (ng *engine) signatureVerifier(signature signatureSetting) (func(chain alic
decrypters[fingerprint] = decrypter decrypters[fingerprint] = decrypter
} }
return func(chain alice.Chain) alice.Chain { return func(chn chain.Chain) chain.Chain {
if ng.unsignedCallback != nil { if ng.unsignedCallback != nil {
return chain.Append(handler.ContentSecurityHandler( return chn.Append(handler.ContentSecurityHandler(
decrypters, signature.Expiry, signature.Strict, ng.unsignedCallback)) decrypters, signature.Expiry, signature.Strict, ng.unsignedCallback))
} }
return chain.Append(handler.ContentSecurityHandler( return chn.Append(handler.ContentSecurityHandler(decrypters, signature.Expiry, signature.Strict))
decrypters, signature.Expiry, signature.Strict))
}, nil }, nil
} }

View File

@@ -334,7 +334,7 @@ type mockedRouter struct{}
func (m mockedRouter) ServeHTTP(_ http.ResponseWriter, _ *http.Request) { func (m mockedRouter) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {
} }
func (m mockedRouter) Handle(_, _ string, _ http.Handler) error { func (m mockedRouter) Handle(_, _ string, handler http.Handler) error {
return errors.New("foo") return errors.New("foo")
} }

View File

@@ -7,13 +7,20 @@ import (
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"net/http/httptrace"
nurl "net/url" nurl "net/url"
"strings" "strings"
"github.com/zeromicro/go-zero/core/lang" "github.com/zeromicro/go-zero/core/lang"
"github.com/zeromicro/go-zero/core/mapping" "github.com/zeromicro/go-zero/core/mapping"
"github.com/zeromicro/go-zero/core/trace"
"github.com/zeromicro/go-zero/rest/httpc/internal" "github.com/zeromicro/go-zero/rest/httpc/internal"
"github.com/zeromicro/go-zero/rest/internal/header" "github.com/zeromicro/go-zero/rest/internal/header"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
oteltrace "go.opentelemetry.io/otel/trace"
) )
var interceptors = []internal.Interceptor{ var interceptors = []internal.Interceptor{
@@ -150,17 +157,47 @@ func fillPath(u *nurl.URL, val map[string]interface{}) error {
} }
func request(r *http.Request, cli client) (*http.Response, error) { func request(r *http.Request, cli client) (*http.Response, error) {
var respHandlers []internal.ResponseHandler tracer := otel.GetTracerProvider().Tracer(trace.TraceName)
for _, interceptor := range interceptors { propagator := otel.GetTextMapPropagator()
spanName := r.URL.Path
ctx, span := tracer.Start(
r.Context(),
spanName,
oteltrace.WithSpanKind(oteltrace.SpanKindClient),
oteltrace.WithAttributes(semconv.HTTPClientAttributesFromHTTPRequest(r)...),
)
defer span.End()
respHandlers := make([]internal.ResponseHandler, len(interceptors))
for i, interceptor := range interceptors {
var h internal.ResponseHandler var h internal.ResponseHandler
r, h = interceptor(r) r, h = interceptor(r)
respHandlers = append(respHandlers, h) respHandlers[i] = h
} }
clientTrace := httptrace.ContextClientTrace(ctx)
if clientTrace != nil {
ctx = httptrace.WithClientTrace(ctx, clientTrace)
}
r = r.WithContext(ctx)
span.SetAttributes(semconv.HTTPClientAttributesFromHTTPRequest(r)...)
propagator.Inject(ctx, propagation.HeaderCarrier(r.Header))
resp, err := cli.do(r) resp, err := cli.do(r)
for i := len(respHandlers) - 1; i >= 0; i-- { for i := len(respHandlers) - 1; i >= 0; i-- {
respHandlers[i](resp, err) respHandlers[i](resp, err)
} }
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
return resp, err
}
span.SetAttributes(semconv.HTTPAttributesFromHTTPStatusCode(resp.StatusCode)...)
span.SetStatus(semconv.SpanStatusFromHTTPStatusCode(resp.StatusCode))
return resp, err return resp, err
} }

View File

@@ -4,15 +4,25 @@ import (
"context" "context"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/http/httptrace"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
ztrace "github.com/zeromicro/go-zero/core/trace"
"github.com/zeromicro/go-zero/rest/httpx" "github.com/zeromicro/go-zero/rest/httpx"
"github.com/zeromicro/go-zero/rest/internal/header" "github.com/zeromicro/go-zero/rest/internal/header"
"github.com/zeromicro/go-zero/rest/router" "github.com/zeromicro/go-zero/rest/router"
"go.opentelemetry.io/otel/trace"
) )
func TestDoRequest(t *testing.T) { func TestDoRequest(t *testing.T) {
ztrace.StartAgent(ztrace.Config{
Name: "go-zero-test",
Endpoint: "http://localhost:14268/api/traces",
Batcher: "jaeger",
Sampler: 1.0,
})
svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
})) }))
defer svr.Close() defer svr.Close()
@@ -21,6 +31,8 @@ func TestDoRequest(t *testing.T) {
resp, err := DoRequest(req) resp, err := DoRequest(req)
assert.Nil(t, err) assert.Nil(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
spanContext := trace.SpanContextFromContext(resp.Request.Context())
assert.True(t, spanContext.IsValid())
} }
func TestDoRequest_NotFound(t *testing.T) { func TestDoRequest_NotFound(t *testing.T) {
@@ -187,3 +199,17 @@ func TestDo_Json(t *testing.T) {
_, err = Do(context.Background(), http.MethodPost, svr.URL+"/nodes/:key", data) _, err = Do(context.Background(), http.MethodPost, svr.URL+"/nodes/:key", data)
assert.NotNil(t, err) assert.NotNil(t, err)
} }
func TestDo_WithClientHttpTrace(t *testing.T) {
svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
defer svr.Close()
_, err := Do(httptrace.WithClientTrace(context.Background(),
&httptrace.ClientTrace{
DNSStart: func(info httptrace.DNSStartInfo) {
assert.Equal(t, "localhost", info.Host)
},
}), http.MethodGet, svr.URL, nil)
assert.Nil(t, err)
}

View File

@@ -18,13 +18,15 @@ func Parse(resp *http.Response, val interface{}) error {
return ParseJsonBody(resp, val) return ParseJsonBody(resp, val)
} }
// ParseHeaders parses the rsponse headers. // ParseHeaders parses the response headers.
func ParseHeaders(resp *http.Response, val interface{}) error { func ParseHeaders(resp *http.Response, val interface{}) error {
return encoding.ParseHeaders(resp.Header, val) return encoding.ParseHeaders(resp.Header, val)
} }
// ParseJsonBody parses the rsponse body, which should be in json content type. // ParseJsonBody parses the response body, which should be in json content type.
func ParseJsonBody(resp *http.Response, val interface{}) error { func ParseJsonBody(resp *http.Response, val interface{}) error {
defer resp.Body.Close()
if withJsonBody(resp) { if withJsonBody(resp) {
return mapping.UnmarshalJsonReader(resp.Body, val) return mapping.UnmarshalJsonReader(resp.Body, val)
} }

View File

@@ -49,24 +49,11 @@ func ParseHeaders(r *http.Request, v interface{}) error {
// ParseForm parses the form request. // ParseForm parses the form request.
func ParseForm(r *http.Request, v interface{}) error { func ParseForm(r *http.Request, v interface{}) error {
if err := r.ParseForm(); err != nil { params, err := GetFormValues(r)
if err != nil {
return err return err
} }
if err := r.ParseMultipartForm(maxMemory); err != nil {
if err != http.ErrNotMultipart {
return err
}
}
params := make(map[string]interface{}, len(r.Form))
for name := range r.Form {
formValue := r.Form.Get(name)
if len(formValue) > 0 {
params[name] = formValue
}
}
return formUnmarshaler.Unmarshal(params, v) return formUnmarshaler.Unmarshal(params, v)
} }

View File

@@ -6,6 +6,7 @@ import (
"sync" "sync"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/internal/errcode"
"github.com/zeromicro/go-zero/rest/internal/header" "github.com/zeromicro/go-zero/rest/internal/header"
) )
@@ -23,9 +24,14 @@ func Error(w http.ResponseWriter, err error, fns ...func(w http.ResponseWriter,
if handler == nil { if handler == nil {
if len(fns) > 0 { if len(fns) > 0 {
fns[0](w, err) fns[0](w, err)
} else if errcode.IsGrpcError(err) {
// don't unwrap error and get status.Message(),
// it hides the rpc error headers.
http.Error(w, err.Error(), errcode.CodeFromGrpcError(err))
} else { } else {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
} }
return return
} }

View File

@@ -8,6 +8,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
) )
type message struct { type message struct {
@@ -95,6 +97,16 @@ func TestError(t *testing.T) {
} }
} }
func TestErrorWithGrpcError(t *testing.T) {
w := tracedResponseWriter{
headers: make(map[string][]string),
}
Error(&w, status.Error(codes.Unavailable, "foo"))
assert.Equal(t, http.StatusServiceUnavailable, w.code)
assert.True(t, w.hasBody)
assert.True(t, strings.Contains(w.builder.String(), "foo"))
}
func TestErrorWithHandler(t *testing.T) { func TestErrorWithHandler(t *testing.T) {
w := tracedResponseWriter{ w := tracedResponseWriter{
headers: make(map[string][]string), headers: make(map[string][]string),

View File

@@ -4,6 +4,29 @@ import "net/http"
const xForwardedFor = "X-Forwarded-For" const xForwardedFor = "X-Forwarded-For"
// GetFormValues returns the form values.
func GetFormValues(r *http.Request) (map[string]interface{}, error) {
if err := r.ParseForm(); err != nil {
return nil, err
}
if err := r.ParseMultipartForm(maxMemory); err != nil {
if err != http.ErrNotMultipart {
return nil, err
}
}
params := make(map[string]interface{}, len(r.Form))
for name := range r.Form {
formValue := r.Form.Get(name)
if len(formValue) > 0 {
params[name] = formValue
}
}
return params, nil
}
// GetRemoteAddr returns the peer address, supports X-Forward-For. // GetRemoteAddr returns the peer address, supports X-Forward-For.
func GetRemoteAddr(r *http.Request) string { func GetRemoteAddr(r *http.Request) string {
v := r.Header.Get(xForwardedFor) v := r.Header.Get(xForwardedFor)

View File

@@ -38,3 +38,14 @@ func TestParseHeadersMulti(t *testing.T) {
assert.Equal(t, 1, val.Baz) assert.Equal(t, 1, val.Baz)
assert.True(t, val.Qux) assert.True(t, val.Qux)
} }
func TestParseHeadersArrayInt(t *testing.T) {
var val struct {
Foo []int `header:"foo"`
}
r := httptest.NewRequest(http.MethodGet, "/any", nil)
r.Header.Set("foo", "1")
r.Header.Add("foo", "2")
assert.Nil(t, ParseHeaders(r.Header, &val))
assert.Equal(t, []int{1, 2}, val.Foo)
}

View File

@@ -0,0 +1,55 @@
package errcode
import (
"net/http"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// CodeFromGrpcError converts the gRPC error to an HTTP status code.
// See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
func CodeFromGrpcError(err error) int {
code := status.Code(err)
switch code {
case codes.OK:
return http.StatusOK
case codes.InvalidArgument, codes.FailedPrecondition, codes.OutOfRange:
return http.StatusBadRequest
case codes.Unauthenticated:
return http.StatusUnauthorized
case codes.PermissionDenied:
return http.StatusForbidden
case codes.NotFound:
return http.StatusNotFound
case codes.Canceled:
return http.StatusRequestTimeout
case codes.AlreadyExists, codes.Aborted:
return http.StatusConflict
case codes.ResourceExhausted:
return http.StatusTooManyRequests
case codes.Internal, codes.DataLoss, codes.Unknown:
return http.StatusInternalServerError
case codes.Unimplemented:
return http.StatusNotImplemented
case codes.Unavailable:
return http.StatusServiceUnavailable
case codes.DeadlineExceeded:
return http.StatusGatewayTimeout
}
return http.StatusInternalServerError
}
// IsGrpcError checks if the error is a gRPC error.
func IsGrpcError(err error) bool {
if err == nil {
return false
}
_, ok := err.(interface {
GRPCStatus() *status.Status
})
return ok
}

View File

@@ -0,0 +1,123 @@
package errcode
import (
"errors"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func TestCodeFromGrpcError(t *testing.T) {
tests := []struct {
name string
code codes.Code
want int
}{
{
name: "OK",
code: codes.OK,
want: http.StatusOK,
},
{
name: "Invalid argument",
code: codes.InvalidArgument,
want: http.StatusBadRequest,
},
{
name: "Failed precondition",
code: codes.FailedPrecondition,
want: http.StatusBadRequest,
},
{
name: "Out of range",
code: codes.OutOfRange,
want: http.StatusBadRequest,
},
{
name: "Unauthorized",
code: codes.Unauthenticated,
want: http.StatusUnauthorized,
},
{
name: "Permission denied",
code: codes.PermissionDenied,
want: http.StatusForbidden,
},
{
name: "Not found",
code: codes.NotFound,
want: http.StatusNotFound,
},
{
name: "Canceled",
code: codes.Canceled,
want: http.StatusRequestTimeout,
},
{
name: "Already exists",
code: codes.AlreadyExists,
want: http.StatusConflict,
},
{
name: "Aborted",
code: codes.Aborted,
want: http.StatusConflict,
},
{
name: "Resource exhausted",
code: codes.ResourceExhausted,
want: http.StatusTooManyRequests,
},
{
name: "Internal",
code: codes.Internal,
want: http.StatusInternalServerError,
},
{
name: "Data loss",
code: codes.DataLoss,
want: http.StatusInternalServerError,
},
{
name: "Unknown",
code: codes.Unknown,
want: http.StatusInternalServerError,
},
{
name: "Unimplemented",
code: codes.Unimplemented,
want: http.StatusNotImplemented,
},
{
name: "Unavailable",
code: codes.Unavailable,
want: http.StatusServiceUnavailable,
},
{
name: "Deadline exceeded",
code: codes.DeadlineExceeded,
want: http.StatusGatewayTimeout,
},
{
name: "Beyond defined error",
code: codes.Code(^uint32(0)),
want: http.StatusInternalServerError,
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.want, CodeFromGrpcError(status.Error(test.code, "foo")))
})
}
}
func TestIsGrpcError(t *testing.T) {
assert.True(t, IsGrpcError(status.Error(codes.Unknown, "foo")))
assert.False(t, IsGrpcError(errors.New("foo")))
assert.False(t, IsGrpcError(nil))
}

View File

@@ -39,7 +39,7 @@ func start(host string, port int, handler http.Handler, run func(svr *http.Serve
} }
waitForCalled := proc.AddWrapUpListener(func() { waitForCalled := proc.AddWrapUpListener(func() {
if e := server.Shutdown(context.Background()); err != nil { if e := server.Shutdown(context.Background()); e != nil {
logx.Error(e) logx.Error(e)
} }
}) })

View File

@@ -8,6 +8,7 @@ import (
"time" "time"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/chain"
"github.com/zeromicro/go-zero/rest/handler" "github.com/zeromicro/go-zero/rest/handler"
"github.com/zeromicro/go-zero/rest/httpx" "github.com/zeromicro/go-zero/rest/httpx"
"github.com/zeromicro/go-zero/rest/internal/cors" "github.com/zeromicro/go-zero/rest/internal/cors"
@@ -78,6 +79,17 @@ func (s *Server) PrintRoutes() {
s.ngin.print() s.ngin.print()
} }
// Routes returns the HTTP routers that registered in the server.
func (s *Server) Routes() []Route {
var routes []Route
for _, r := range s.ngin.routes {
routes = append(routes, r.routes...)
}
return routes
}
// Start starts the Server. // Start starts the Server.
// Graceful shutdown is enabled by default. // Graceful shutdown is enabled by default.
// Use proc.SetTimeToForceQuit to customize the graceful shutdown period. // Use proc.SetTimeToForceQuit to customize the graceful shutdown period.
@@ -102,6 +114,14 @@ func ToMiddleware(handler func(next http.Handler) http.Handler) Middleware {
} }
} }
// WithChain returns a RunOption that uses the given chain to replace the default chain.
// JWT auth middleware and the middlewares that added by svr.Use() will be appended.
func WithChain(chn chain.Chain) RunOption {
return func(svr *Server) {
svr.ngin.chain = chn
}
}
// WithCors returns a func to enable CORS for given origin, or default to all origins (*). // WithCors returns a func to enable CORS for given origin, or default to all origins (*).
func WithCors(origin ...string) RunOption { func WithCors(origin ...string) RunOption {
return func(server *Server) { return func(server *Server) {

View File

@@ -9,12 +9,14 @@ import (
"net/http/httptest" "net/http/httptest"
"os" "os"
"strings" "strings"
"sync/atomic"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/chain"
"github.com/zeromicro/go-zero/rest/httpx" "github.com/zeromicro/go-zero/rest/httpx"
"github.com/zeromicro/go-zero/rest/router" "github.com/zeromicro/go-zero/rest/router"
) )
@@ -320,6 +322,7 @@ Port: 54321
rt := router.NewRouter() rt := router.NewRouter()
svr, err := NewServer(cnf, WithRouter(rt)) svr, err := NewServer(cnf, WithRouter(rt))
assert.Nil(t, err) assert.Nil(t, err)
defer svr.Stop()
opt := WithCors("local") opt := WithCors("local")
opt(svr) opt(svr)
@@ -408,3 +411,107 @@ Port: 54321
out := <-ch out := <-ch
assert.Equal(t, expect, out) assert.Equal(t, expect, out)
} }
func TestServer_Routes(t *testing.T) {
const (
configYaml = `
Name: foo
Port: 54321
`
expect = `GET /foo GET /bar GET /foo/:bar GET /foo/:bar/baz`
)
var cnf RestConf
assert.Nil(t, conf.LoadFromYamlBytes([]byte(configYaml), &cnf))
svr, err := NewServer(cnf)
assert.Nil(t, err)
svr.AddRoutes([]Route{
{
Method: http.MethodGet,
Path: "/foo",
Handler: http.NotFound,
},
{
Method: http.MethodGet,
Path: "/bar",
Handler: http.NotFound,
},
{
Method: http.MethodGet,
Path: "/foo/:bar",
Handler: http.NotFound,
},
{
Method: http.MethodGet,
Path: "/foo/:bar/baz",
Handler: http.NotFound,
},
})
routes := svr.Routes()
var buf strings.Builder
for i := 0; i < len(routes); i++ {
buf.WriteString(routes[i].Method)
buf.WriteString(" ")
buf.WriteString(routes[i].Path)
buf.WriteString(" ")
}
assert.Equal(t, expect, strings.Trim(buf.String(), " "))
}
func TestHandleError(t *testing.T) {
assert.NotPanics(t, func() {
handleError(nil)
handleError(http.ErrServerClosed)
})
}
func TestValidateSecret(t *testing.T) {
assert.Panics(t, func() {
validateSecret("short")
})
}
func TestServer_WithChain(t *testing.T) {
var called int32
middleware1 := func() func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
atomic.AddInt32(&called, 1)
next.ServeHTTP(w, r)
atomic.AddInt32(&called, 1)
})
}
}
middleware2 := func() func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
atomic.AddInt32(&called, 1)
next.ServeHTTP(w, r)
atomic.AddInt32(&called, 1)
})
}
}
server := MustNewServer(RestConf{}, WithChain(chain.New(middleware1(), middleware2())))
server.AddRoutes(
[]Route{
{
Method: http.MethodGet,
Path: "/",
Handler: func(_ http.ResponseWriter, _ *http.Request) {
atomic.AddInt32(&called, 1)
},
},
},
)
rt := router.NewRouter()
assert.Nil(t, server.ngin.bindRoutes(rt))
req, err := http.NewRequest(http.MethodGet, "/", nil)
assert.Nil(t, err)
rt.ServeHTTP(httptest.NewRecorder(), req)
assert.Equal(t, int32(5), atomic.LoadInt32(&called))
}

View File

@@ -95,9 +95,9 @@ func init() {
"higher priority") "higher priority")
Cmd.Flags().StringVar(&apigen.VarStringRemote, "remote", "", "The remote git repo of the"+ Cmd.Flags().StringVar(&apigen.VarStringRemote, "remote", "", "The remote git repo of the"+
" template, --home and --remote cannot be set at the same time, if they are, --remote has higher"+ " template, --home and --remote cannot be set at the same time, if they are, --remote has higher"+
" priority\n\tThe git repo directory must be consistent with the"+ " priority\nThe git repo directory must be consistent with the"+
" https://github.com/zeromicro/go-zero-template directory structure") " https://github.com/zeromicro/go-zero-template directory structure")
Cmd.Flags().StringVar(&apigen.VarStringBranch, "branch", "master", "The branch of the "+ Cmd.Flags().StringVar(&apigen.VarStringBranch, "branch", "", "The branch of the "+
"remote repo, it does work with --remote") "remote repo, it does work with --remote")
dartCmd.Flags().StringVar(&dartgen.VarStringDir, "dir", "", "The target dir") dartCmd.Flags().StringVar(&dartgen.VarStringDir, "dir", "", "The target dir")
@@ -122,9 +122,9 @@ func init() {
"has higher priority") "has higher priority")
goCmd.Flags().StringVar(&gogen.VarStringRemote, "remote", "", "The remote git repo "+ goCmd.Flags().StringVar(&gogen.VarStringRemote, "remote", "", "The remote git repo "+
"of the template, --home and --remote cannot be set at the same time, if they are, --remote"+ "of the template, --home and --remote cannot be set at the same time, if they are, --remote"+
" has higher priority\n\tThe git repo directory must be consistent with the "+ " has higher priority\nThe git repo directory must be consistent with the "+
"https://github.com/zeromicro/go-zero-template directory structure") "https://github.com/zeromicro/go-zero-template directory structure")
goCmd.Flags().StringVar(&gogen.VarStringBranch, "branch", "master", "The branch of "+ goCmd.Flags().StringVar(&gogen.VarStringBranch, "branch", "", "The branch of "+
"the remote repo, it does work with --remote") "the remote repo, it does work with --remote")
goCmd.Flags().StringVar(&gogen.VarStringStyle, "style", "gozero", "The file naming format,"+ goCmd.Flags().StringVar(&gogen.VarStringStyle, "style", "gozero", "The file naming format,"+
" see [https://github.com/zeromicro/go-zero/blob/master/tools/goctl/config/readme.md]") " see [https://github.com/zeromicro/go-zero/blob/master/tools/goctl/config/readme.md]")
@@ -143,7 +143,7 @@ func init() {
"of the template, --home and --remote cannot be set at the same time, if they are, --remote"+ "of the template, --home and --remote cannot be set at the same time, if they are, --remote"+
" has higher priority\n\tThe git repo directory must be consistent with the "+ " has higher priority\n\tThe git repo directory must be consistent with the "+
"https://github.com/zeromicro/go-zero-template directory structure") "https://github.com/zeromicro/go-zero-template directory structure")
newCmd.Flags().StringVar(&new.VarStringBranch, "branch", "master", "The branch of "+ newCmd.Flags().StringVar(&new.VarStringBranch, "branch", "", "The branch of "+
"the remote repo, it does work with --remote") "the remote repo, it does work with --remote")
newCmd.Flags().StringVar(&new.VarStringStyle, "style", "gozero", "The file naming format,"+ newCmd.Flags().StringVar(&new.VarStringStyle, "style", "gozero", "The file naming format,"+
" see [https://github.com/zeromicro/go-zero/blob/master/tools/goctl/config/readme.md]") " see [https://github.com/zeromicro/go-zero/blob/master/tools/goctl/config/readme.md]")

View File

@@ -18,6 +18,10 @@ import (
var markdownTemplate string var markdownTemplate string
func genDoc(api *spec.ApiSpec, dir, filename string) error { func genDoc(api *spec.ApiSpec, dir, filename string) error {
if len(api.Service.Routes()) == 0 {
return nil
}
fp, _, err := util.MaybeCreateFile(dir, "", filename) fp, _, err := util.MaybeCreateFile(dir, "", filename)
if err != nil { if err != nil {
return err return err
@@ -59,6 +63,7 @@ func genDoc(api *spec.ApiSpec, dir, filename string) error {
builder.Write(tmplBytes.Bytes()) builder.Write(tmplBytes.Bytes())
} }
_, err = fp.WriteString(strings.Replace(builder.String(), "&#34;", `"`, -1)) _, err = fp.WriteString(strings.Replace(builder.String(), "&#34;", `"`, -1))
return err return err
} }

View File

@@ -65,7 +65,7 @@ func Test_apiFormatReader_issue1721(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
filename := path.Join(subDir, "bar.api") filename := path.Join(subDir, "bar.api")
err = ioutil.WriteFile(filename, []byte(fmt.Sprintf(`import "%s"`, importedFilename)), 0644) err = ioutil.WriteFile(filename, []byte(fmt.Sprintf(`import "%s"`, importedFilename)), 0o644)
require.NoError(t, err) require.NoError(t, err)
f, err := os.Open(filename) f, err := os.Open(filename)

View File

@@ -0,0 +1,9 @@
package config
import {{.authImport}}
type Config struct {
rest.RestConf
{{.auth}}
{{.jwtTrans}}
}

View File

@@ -18,6 +18,7 @@ import (
"github.com/zeromicro/go-zero/tools/goctl/api/parser" "github.com/zeromicro/go-zero/tools/goctl/api/parser"
apiutil "github.com/zeromicro/go-zero/tools/goctl/api/util" apiutil "github.com/zeromicro/go-zero/tools/goctl/api/util"
"github.com/zeromicro/go-zero/tools/goctl/config" "github.com/zeromicro/go-zero/tools/goctl/config"
"github.com/zeromicro/go-zero/tools/goctl/pkg/golang"
"github.com/zeromicro/go-zero/tools/goctl/util" "github.com/zeromicro/go-zero/tools/goctl/util"
"github.com/zeromicro/go-zero/tools/goctl/util/pathx" "github.com/zeromicro/go-zero/tools/goctl/util/pathx"
) )
@@ -85,7 +86,7 @@ func DoGenProject(apiFile, dir, style string) error {
} }
logx.Must(pathx.MkdirIfNotExist(dir)) logx.Must(pathx.MkdirIfNotExist(dir))
rootPkg, err := getParentPackage(dir) rootPkg, err := golang.GetParentPackage(dir)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -1,6 +1,7 @@
package gogen package gogen
import ( import (
_ "embed"
"fmt" "fmt"
"strings" "strings"
@@ -11,17 +12,7 @@ import (
) )
const ( const (
configFile = "config" configFile = "config"
configTemplate = `package config
import {{.authImport}}
type Config struct {
rest.RestConf
{{.auth}}
{{.jwtTrans}}
}
`
jwtTemplate = ` struct { jwtTemplate = ` struct {
AccessSecret string AccessSecret string
@@ -35,6 +26,9 @@ type Config struct {
` `
) )
//go:embed config.tpl
var configTemplate string
func genConfig(dir string, cfg *config.Config, api *spec.ApiSpec) error { func genConfig(dir string, cfg *config.Config, api *spec.ApiSpec) error {
filename, err := format.FileNamingFormat(cfg.NamingFormat, configFile) filename, err := format.FileNamingFormat(cfg.NamingFormat, configFile)
if err != nil { if err != nil {

View File

@@ -8,11 +8,10 @@ import (
"github.com/zeromicro/go-zero/tools/goctl/api/spec" "github.com/zeromicro/go-zero/tools/goctl/api/spec"
"github.com/zeromicro/go-zero/tools/goctl/config" "github.com/zeromicro/go-zero/tools/goctl/config"
"github.com/zeromicro/go-zero/tools/goctl/internal/version" "github.com/zeromicro/go-zero/tools/goctl/pkg/golang"
"github.com/zeromicro/go-zero/tools/goctl/util" "github.com/zeromicro/go-zero/tools/goctl/util"
"github.com/zeromicro/go-zero/tools/goctl/util/format" "github.com/zeromicro/go-zero/tools/goctl/util/format"
"github.com/zeromicro/go-zero/tools/goctl/util/pathx" "github.com/zeromicro/go-zero/tools/goctl/util/pathx"
"github.com/zeromicro/go-zero/tools/goctl/vars"
) )
const defaultLogicPackage = "logic" const defaultLogicPackage = "logic"
@@ -21,16 +20,16 @@ const defaultLogicPackage = "logic"
var handlerTemplate string var handlerTemplate string
type handlerInfo struct { type handlerInfo struct {
PkgName string PkgName string
ImportPackages string ImportPackages string
HandlerName string ImportHttpxPackage string
RequestType string HandlerName string
LogicName string RequestType string
LogicType string LogicName string
Call string LogicType string
HasResp bool Call string
HasRequest bool HasResp bool
After1_1_10 bool HasRequest bool
} }
func genHandler(dir, rootPkg string, cfg *config.Config, group spec.Group, route spec.Route) error { func genHandler(dir, rootPkg string, cfg *config.Config, group spec.Group, route spec.Route) error {
@@ -42,7 +41,7 @@ func genHandler(dir, rootPkg string, cfg *config.Config, group spec.Group, route
handler = strings.Title(handler) handler = strings.Title(handler)
logicName = pkgName logicName = pkgName
} }
parentPkg, err := getParentPackage(dir) parentPkg, err := golang.GetParentPackage(dir)
if err != nil { if err != nil {
return err return err
} }
@@ -61,7 +60,8 @@ func genHandler(dir, rootPkg string, cfg *config.Config, group spec.Group, route
} }
func doGenToFile(dir, handler string, cfg *config.Config, group spec.Group, func doGenToFile(dir, handler string, cfg *config.Config, group spec.Group,
route spec.Route, handleObj handlerInfo) error { route spec.Route, handleObj handlerInfo,
) error {
filename, err := format.FileNamingFormat(cfg.NamingFormat, handler) filename, err := format.FileNamingFormat(cfg.NamingFormat, handler)
if err != nil { if err != nil {
return err return err
@@ -92,20 +92,14 @@ func genHandlers(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) err
} }
func genHandlerImports(group spec.Group, route spec.Route, parentPkg string) string { func genHandlerImports(group spec.Group, route spec.Route, parentPkg string) string {
var imports []string imports := []string{
imports = append(imports, fmt.Sprintf("\"%s\"", fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, getLogicFolderPath(group, route))),
pathx.JoinPackages(parentPkg, getLogicFolderPath(group, route)))) fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir)),
imports = append(imports, fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir))) }
if len(route.RequestTypeName()) > 0 { if len(route.RequestTypeName()) > 0 {
imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, typesDir))) imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, typesDir)))
} }
currentVersion := version.GetGoctlVersion()
// todo(anqiansong): This will be removed after a certain number of production versions of goctl (probably 5)
if !version.IsVersionGreaterThan(currentVersion, "1.1.10") {
imports = append(imports, fmt.Sprintf("\"%s/rest/httpx\"", vars.ProjectOpenSourceURL))
}
return strings.Join(imports, "\n\t") return strings.Join(imports, "\n\t")
} }
@@ -114,6 +108,7 @@ func getHandlerBaseName(route spec.Route) (string, error) {
handler = strings.TrimSpace(handler) handler = strings.TrimSpace(handler)
handler = strings.TrimSuffix(handler, "handler") handler = strings.TrimSuffix(handler, "handler")
handler = strings.TrimSuffix(handler, "Handler") handler = strings.TrimSuffix(handler, "Handler")
return handler, nil return handler, nil
} }
@@ -128,6 +123,7 @@ func getHandlerFolderPath(group spec.Group, route spec.Route) string {
folder = strings.TrimPrefix(folder, "/") folder = strings.TrimPrefix(folder, "/")
folder = strings.TrimSuffix(folder, "/") folder = strings.TrimSuffix(folder, "/")
return path.Join(handlerDir, folder) return path.Join(handlerDir, folder)
} }

View File

@@ -3,16 +3,14 @@ package gogen
import ( import (
"bytes" "bytes"
"fmt" "fmt"
goformat "go/format"
"io" "io"
"path/filepath"
"strings" "strings"
"text/template" "text/template"
"github.com/zeromicro/go-zero/core/collection" "github.com/zeromicro/go-zero/core/collection"
"github.com/zeromicro/go-zero/tools/goctl/api/spec" "github.com/zeromicro/go-zero/tools/goctl/api/spec"
"github.com/zeromicro/go-zero/tools/goctl/api/util" "github.com/zeromicro/go-zero/tools/goctl/api/util"
"github.com/zeromicro/go-zero/tools/goctl/util/ctx" "github.com/zeromicro/go-zero/tools/goctl/pkg/golang"
"github.com/zeromicro/go-zero/tools/goctl/util/pathx" "github.com/zeromicro/go-zero/tools/goctl/util/pathx"
) )
@@ -54,38 +52,11 @@ func genFile(c fileGenConfig) error {
return err return err
} }
code := formatCode(buffer.String()) code := golang.FormatCode(buffer.String())
_, err = fp.WriteString(code) _, err = fp.WriteString(code)
return err return err
} }
func getParentPackage(dir string) (string, error) {
abs, err := filepath.Abs(dir)
if err != nil {
return "", err
}
projectCtx, err := ctx.Prepare(abs)
if err != nil {
return "", err
}
// fix https://github.com/zeromicro/go-zero/issues/1058
wd := projectCtx.WorkDir
d := projectCtx.Dir
same, err := pathx.SameFile(wd, d)
if err != nil {
return "", err
}
trim := strings.TrimPrefix(projectCtx.WorkDir, projectCtx.Dir)
if same {
trim = strings.TrimPrefix(strings.ToLower(projectCtx.WorkDir), strings.ToLower(projectCtx.Dir))
}
return filepath.ToSlash(filepath.Join(projectCtx.Path, trim)), nil
}
func writeProperty(writer io.Writer, name, tag, comment string, tp spec.Type, indent int) error { func writeProperty(writer io.Writer, name, tag, comment string, tp spec.Type, indent int) error {
util.WriteIndent(writer, indent) util.WriteIndent(writer, indent)
var err error var err error
@@ -136,15 +107,6 @@ func getMiddleware(api *spec.ApiSpec) []string {
return result.KeysStr() return result.KeysStr()
} }
func formatCode(code string) string {
ret, err := goformat.Source([]byte(code))
if err != nil {
return code
}
return string(ret)
}
func responseGoTypeName(r spec.Route, pkg ...string) string { func responseGoTypeName(r spec.Route, pkg ...string) string {
if r.ResponseType == nil { if r.ResponseType == nil {
return "" return ""

View File

@@ -1,13 +1,13 @@
package gogen package gogen
const ( const (
interval = "internal/" internal = "internal/"
typesPacket = "types" typesPacket = "types"
configDir = interval + "config" configDir = internal + "config"
contextDir = interval + "svc" contextDir = internal + "svc"
handlerDir = interval + "handler" handlerDir = internal + "handler"
logicDir = interval + "logic" logicDir = internal + "logic"
middlewareDir = interval + "middleware" middlewareDir = internal + "middleware"
typesDir = interval + typesPacket typesDir = internal + typesPacket
groupProperty = "group" groupProperty = "group"
) )

View File

@@ -16,6 +16,10 @@ LINE_VALUE: ':' [ \t]* (STRING|(~[\r\n"`]*));
ID: Letter LetterOrDigit*; ID: Letter LetterOrDigit*;
LetterOrDigit
: Letter
| [0-9]
;
fragment ExponentPart fragment ExponentPart
: [eE] [+-]? Digits : [eE] [+-]? Digits
; ;
@@ -35,10 +39,6 @@ fragment Digits
: [0-9] ([0-9_]* [0-9])? : [0-9] ([0-9_]* [0-9])?
; ;
fragment LetterOrDigit
: Letter
| [0-9]
;
fragment Letter fragment Letter
: [a-zA-Z$_] // these are the "java letters" below 0x7F : [a-zA-Z$_] // these are the "java letters" below 0x7F
| ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate

View File

@@ -70,4 +70,5 @@ replybody: returnToken='returns' lp='(' dataType? rp=')';
kvLit: key=ID {checkKeyValue(p)}value=LINE_VALUE; kvLit: key=ID {checkKeyValue(p)}value=LINE_VALUE;
serviceName: (ID '-'?)+; serviceName: (ID '-'?)+;
path: (('/' (ID ('-' ID)*))|('/:' (ID ('-' ID)?)))+ | '/'; path: (('/' (pathItem ('-' pathItem)*))|('/:' (pathItem ('-' pathItem)?)))+ | '/';
pathItem: (ID|LetterOrDigit)+;

View File

@@ -210,7 +210,7 @@ func (a *Api) Format() error {
// Equal compares whether the element literals in two Api are equal // Equal compares whether the element literals in two Api are equal
func (a *Api) Equal(v interface{}) bool { func (a *Api) Equal(v interface{}) bool {
if v == nil { if v == nil || a == nil {
return false return false
} }

View File

@@ -232,20 +232,27 @@ func (p *Parser) invoke(linePrefix, content string) (v *Api, err error) {
// storeVerificationInfo stores information for verification // storeVerificationInfo stores information for verification
func (p *Parser) storeVerificationInfo(api *Api) { func (p *Parser) storeVerificationInfo(api *Api) {
routeMap := func(list []*ServiceRoute) { routeMap := func(list []*ServiceRoute, prefix string) {
for _, g := range list { for _, g := range list {
handler := g.GetHandler() handler := g.GetHandler()
if handler.IsNotNil() { if handler.IsNotNil() {
handlerName := handler.Text() handlerName := handler.Text()
p.handlerMap[handlerName] = Holder p.handlerMap[handlerName] = Holder
route := fmt.Sprintf("%s://%s", g.Route.Method.Text(), g.Route.Path.Text()) route := fmt.Sprintf("%s://%s", g.Route.Method.Text(), path.Join(prefix, g.Route.Path.Text()))
p.routeMap[route] = Holder p.routeMap[route] = Holder
} }
} }
} }
for _, each := range api.Service { for _, each := range api.Service {
routeMap(each.ServiceApi.ServiceRoute) var prefix string
if each.AtServer != nil {
pExp := each.AtServer.Kv.Get(prefixKey)
if pExp != nil {
prefix = pExp.Text()
}
}
routeMap(each.ServiceApi.ServiceRoute, prefix)
} }
for _, each := range api.Type { for _, each := range api.Type {
@@ -254,7 +261,6 @@ func (p *Parser) storeVerificationInfo(api *Api) {
} }
func (p *Parser) valid(nestedApi *Api) error { func (p *Parser) valid(nestedApi *Api) error {
if p.syntax != nil && nestedApi.Syntax != nil { if p.syntax != nil && nestedApi.Syntax != nil {
if p.syntax.Version.Text() != nestedApi.Syntax.Version.Text() { if p.syntax.Version.Text() != nestedApi.Syntax.Version.Text() {
syntaxToken := nestedApi.Syntax.Syntax syntaxToken := nestedApi.Syntax.Syntax

View File

@@ -25,13 +25,13 @@ func Test_ImportCycle(t *testing.T) {
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
mainPath := filepath.Join(dir, mainFilename) mainPath := filepath.Join(dir, mainFilename)
err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0777) err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0o777)
require.NoError(t, err) require.NoError(t, err)
subAPath := filepath.Join(dir, subAFilename) subAPath := filepath.Join(dir, subAFilename)
err = ioutil.WriteFile(subAPath, []byte(subASrc), 0777) err = ioutil.WriteFile(subAPath, []byte(subASrc), 0o777)
require.NoError(t, err) require.NoError(t, err)
subBPath := filepath.Join(dir, subBFilename) subBPath := filepath.Join(dir, subBFilename)
err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0777) err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0o777)
require.NoError(t, err) require.NoError(t, err)
_, err = NewParser().Parse(mainPath) _, err = NewParser().Parse(mainPath)
@@ -55,13 +55,13 @@ func Test_MultiImportedShouldAllowed(t *testing.T) {
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
mainPath := filepath.Join(dir, mainFilename) mainPath := filepath.Join(dir, mainFilename)
err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0777) err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0o777)
require.NoError(t, err) require.NoError(t, err)
subAPath := filepath.Join(dir, subAFilename) subAPath := filepath.Join(dir, subAFilename)
err = ioutil.WriteFile(subAPath, []byte(subASrc), 0777) err = ioutil.WriteFile(subAPath, []byte(subASrc), 0o777)
require.NoError(t, err) require.NoError(t, err)
subBPath := filepath.Join(dir, subBFilename) subBPath := filepath.Join(dir, subBFilename)
err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0777) err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0o777)
require.NoError(t, err) require.NoError(t, err)
_, err = NewParser().Parse(mainPath) _, err = NewParser().Parse(mainPath)
@@ -84,13 +84,13 @@ func Test_RedundantDeclarationShouldNotBeAllowed(t *testing.T) {
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
mainPath := filepath.Join(dir, mainFilename) mainPath := filepath.Join(dir, mainFilename)
err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0777) err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0o777)
require.NoError(t, err) require.NoError(t, err)
subAPath := filepath.Join(dir, subAFilename) subAPath := filepath.Join(dir, subAFilename)
err = ioutil.WriteFile(subAPath, []byte(subASrc), 0777) err = ioutil.WriteFile(subAPath, []byte(subASrc), 0o777)
require.NoError(t, err) require.NoError(t, err)
subBPath := filepath.Join(dir, subBFilename) subBPath := filepath.Join(dir, subBFilename)
err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0777) err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0o777)
require.NoError(t, err) require.NoError(t, err)
_, err = NewParser().Parse(mainPath) _, err = NewParser().Parse(mainPath)

View File

@@ -152,3 +152,7 @@ func (v *BaseApiParserVisitor) VisitServiceName(ctx *ServiceNameContext) interfa
func (v *BaseApiParserVisitor) VisitPath(ctx *PathContext) interface{} { func (v *BaseApiParserVisitor) VisitPath(ctx *PathContext) interface{} {
return v.VisitChildren(ctx) return v.VisitChildren(ctx)
} }
func (v *BaseApiParserVisitor) VisitPathItem(ctx *PathItemContext) interface{} {
return v.VisitChildren(ctx)
}

View File

@@ -8,13 +8,11 @@ import (
) )
// Suppress unused import error // Suppress unused import error
var ( var _ = fmt.Printf
_ = fmt.Printf var _ = unicode.IsLetter
_ = unicode.IsLetter
)
var serializedLexerAtn = []uint16{ var serializedLexerAtn = []uint16{
3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 26, 276, 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 27, 276,
8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7,
9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12,
4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4,
@@ -36,114 +34,115 @@ var serializedLexerAtn = []uint16{
23, 13, 23, 14, 23, 187, 3, 23, 3, 23, 3, 24, 3, 24, 7, 24, 194, 10, 24, 23, 13, 23, 14, 23, 187, 3, 23, 3, 23, 3, 24, 3, 24, 7, 24, 194, 10, 24,
12, 24, 14, 24, 197, 11, 24, 3, 24, 3, 24, 7, 24, 201, 10, 24, 12, 24, 12, 24, 14, 24, 197, 11, 24, 3, 24, 3, 24, 7, 24, 201, 10, 24, 12, 24,
14, 24, 204, 11, 24, 5, 24, 206, 10, 24, 3, 25, 3, 25, 7, 25, 210, 10, 14, 24, 204, 11, 24, 5, 24, 206, 10, 24, 3, 25, 3, 25, 7, 25, 210, 10,
25, 12, 25, 14, 25, 213, 11, 25, 3, 26, 3, 26, 5, 26, 217, 10, 26, 3, 26, 25, 12, 25, 14, 25, 213, 11, 25, 3, 26, 3, 26, 5, 26, 217, 10, 26, 3, 27,
3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 5, 27, 225, 10, 27, 3, 27, 5, 27, 228, 3, 27, 5, 27, 221, 10, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 5,
10, 27, 3, 27, 3, 27, 3, 27, 6, 27, 233, 10, 27, 13, 27, 14, 27, 234, 3, 28, 229, 10, 28, 3, 28, 5, 28, 232, 10, 28, 3, 28, 3, 28, 3, 28, 6, 28,
27, 3, 27, 3, 27, 3, 27, 3, 27, 5, 27, 242, 10, 27, 3, 28, 3, 28, 3, 28, 237, 10, 28, 13, 28, 14, 28, 238, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 5,
7, 28, 247, 10, 28, 12, 28, 14, 28, 250, 11, 28, 3, 28, 5, 28, 253, 10, 28, 246, 10, 28, 3, 29, 3, 29, 3, 29, 7, 29, 251, 10, 29, 12, 29, 14, 29,
28, 3, 29, 3, 29, 3, 30, 3, 30, 7, 30, 259, 10, 30, 12, 30, 14, 30, 262, 254, 11, 29, 3, 29, 5, 29, 257, 10, 29, 3, 30, 3, 30, 3, 31, 3, 31, 7,
11, 30, 3, 30, 5, 30, 265, 10, 30, 3, 31, 3, 31, 5, 31, 269, 10, 31, 3, 31, 263, 10, 31, 12, 31, 14, 31, 266, 11, 31, 3, 31, 5, 31, 269, 10, 31,
32, 3, 32, 3, 32, 3, 32, 5, 32, 275, 10, 32, 3, 153, 2, 33, 3, 3, 5, 4, 3, 32, 3, 32, 3, 32, 3, 32, 5, 32, 275, 10, 32, 3, 153, 2, 33, 3, 3, 5,
7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25,
27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43,
45, 24, 47, 25, 49, 26, 51, 2, 53, 2, 55, 2, 57, 2, 59, 2, 61, 2, 63, 2, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 2, 55, 2, 57, 2, 59, 2, 61, 2,
3, 2, 20, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 12, 12, 15, 15, 4, 2, 36, 63, 2, 3, 2, 20, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 12, 12, 15, 15, 4,
36, 94, 94, 6, 2, 12, 12, 15, 15, 94, 94, 98, 98, 4, 2, 11, 11, 34, 34, 2, 36, 36, 94, 94, 6, 2, 12, 12, 15, 15, 94, 94, 98, 98, 4, 2, 11, 11,
6, 2, 12, 12, 15, 15, 36, 36, 98, 98, 4, 2, 71, 71, 103, 103, 4, 2, 45, 34, 34, 6, 2, 12, 12, 15, 15, 36, 36, 98, 98, 3, 2, 50, 59, 4, 2, 71, 71,
45, 47, 47, 10, 2, 36, 36, 41, 41, 94, 94, 100, 100, 104, 104, 112, 112, 103, 103, 4, 2, 45, 45, 47, 47, 10, 2, 36, 36, 41, 41, 94, 94, 100, 100,
116, 116, 118, 118, 3, 2, 50, 53, 3, 2, 50, 57, 5, 2, 50, 59, 67, 72, 99, 104, 104, 112, 112, 116, 116, 118, 118, 3, 2, 50, 53, 3, 2, 50, 57, 5,
104, 3, 2, 50, 59, 4, 2, 50, 59, 97, 97, 6, 2, 38, 38, 67, 92, 97, 97, 2, 50, 59, 67, 72, 99, 104, 4, 2, 50, 59, 97, 97, 6, 2, 38, 38, 67, 92,
99, 124, 4, 2, 2, 129, 55298, 56321, 3, 2, 55298, 56321, 3, 2, 56322, 57345, 97, 97, 99, 124, 4, 2, 2, 129, 55298, 56321, 3, 2, 55298, 56321, 3, 2,
2, 293, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 56322, 57345, 2, 294, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2,
2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2,
3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3,
25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31,
2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2,
2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2,
2, 2, 2, 49, 3, 2, 2, 2, 3, 65, 3, 2, 2, 2, 5, 67, 3, 2, 2, 2, 7, 69, 3, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 3, 65, 3, 2, 2,
2, 2, 2, 9, 71, 3, 2, 2, 2, 11, 73, 3, 2, 2, 2, 13, 75, 3, 2, 2, 2, 15, 2, 5, 67, 3, 2, 2, 2, 7, 69, 3, 2, 2, 2, 9, 71, 3, 2, 2, 2, 11, 73, 3,
77, 3, 2, 2, 2, 17, 87, 3, 2, 2, 2, 19, 89, 3, 2, 2, 2, 21, 91, 3, 2, 2, 2, 2, 2, 13, 75, 3, 2, 2, 2, 15, 77, 3, 2, 2, 2, 17, 87, 3, 2, 2, 2, 19,
2, 23, 99, 3, 2, 2, 2, 25, 101, 3, 2, 2, 2, 27, 103, 3, 2, 2, 2, 29, 106, 89, 3, 2, 2, 2, 21, 91, 3, 2, 2, 2, 23, 99, 3, 2, 2, 2, 25, 101, 3, 2,
3, 2, 2, 2, 31, 111, 3, 2, 2, 2, 33, 120, 3, 2, 2, 2, 35, 132, 3, 2, 2, 2, 2, 27, 103, 3, 2, 2, 2, 29, 106, 3, 2, 2, 2, 31, 111, 3, 2, 2, 2, 33,
2, 37, 141, 3, 2, 2, 2, 39, 147, 3, 2, 2, 2, 41, 161, 3, 2, 2, 2, 43, 172, 120, 3, 2, 2, 2, 35, 132, 3, 2, 2, 2, 37, 141, 3, 2, 2, 2, 39, 147, 3,
3, 2, 2, 2, 45, 182, 3, 2, 2, 2, 47, 191, 3, 2, 2, 2, 49, 207, 3, 2, 2, 2, 2, 2, 41, 161, 3, 2, 2, 2, 43, 172, 3, 2, 2, 2, 45, 182, 3, 2, 2, 2,
2, 51, 214, 3, 2, 2, 2, 53, 241, 3, 2, 2, 2, 55, 243, 3, 2, 2, 2, 57, 254, 47, 191, 3, 2, 2, 2, 49, 207, 3, 2, 2, 2, 51, 216, 3, 2, 2, 2, 53, 218,
3, 2, 2, 2, 59, 256, 3, 2, 2, 2, 61, 268, 3, 2, 2, 2, 63, 274, 3, 2, 2, 3, 2, 2, 2, 55, 245, 3, 2, 2, 2, 57, 247, 3, 2, 2, 2, 59, 258, 3, 2, 2,
2, 65, 66, 7, 63, 2, 2, 66, 4, 3, 2, 2, 2, 67, 68, 7, 42, 2, 2, 68, 6, 2, 61, 260, 3, 2, 2, 2, 63, 274, 3, 2, 2, 2, 65, 66, 7, 63, 2, 2, 66, 4,
3, 2, 2, 2, 69, 70, 7, 43, 2, 2, 70, 8, 3, 2, 2, 2, 71, 72, 7, 125, 2, 3, 2, 2, 2, 67, 68, 7, 42, 2, 2, 68, 6, 3, 2, 2, 2, 69, 70, 7, 43, 2, 2,
2, 72, 10, 3, 2, 2, 2, 73, 74, 7, 127, 2, 2, 74, 12, 3, 2, 2, 2, 75, 76, 70, 8, 3, 2, 2, 2, 71, 72, 7, 125, 2, 2, 72, 10, 3, 2, 2, 2, 73, 74, 7,
7, 44, 2, 2, 76, 14, 3, 2, 2, 2, 77, 78, 7, 118, 2, 2, 78, 79, 7, 107, 127, 2, 2, 74, 12, 3, 2, 2, 2, 75, 76, 7, 44, 2, 2, 76, 14, 3, 2, 2, 2,
2, 2, 79, 80, 7, 111, 2, 2, 80, 81, 7, 103, 2, 2, 81, 82, 7, 48, 2, 2, 77, 78, 7, 118, 2, 2, 78, 79, 7, 107, 2, 2, 79, 80, 7, 111, 2, 2, 80, 81,
82, 83, 7, 86, 2, 2, 83, 84, 7, 107, 2, 2, 84, 85, 7, 111, 2, 2, 85, 86, 7, 103, 2, 2, 81, 82, 7, 48, 2, 2, 82, 83, 7, 86, 2, 2, 83, 84, 7, 107,
7, 103, 2, 2, 86, 16, 3, 2, 2, 2, 87, 88, 7, 93, 2, 2, 88, 18, 3, 2, 2, 2, 2, 84, 85, 7, 111, 2, 2, 85, 86, 7, 103, 2, 2, 86, 16, 3, 2, 2, 2, 87,
2, 89, 90, 7, 95, 2, 2, 90, 20, 3, 2, 2, 2, 91, 92, 7, 116, 2, 2, 92, 93, 88, 7, 93, 2, 2, 88, 18, 3, 2, 2, 2, 89, 90, 7, 95, 2, 2, 90, 20, 3, 2,
7, 103, 2, 2, 93, 94, 7, 118, 2, 2, 94, 95, 7, 119, 2, 2, 95, 96, 7, 116, 2, 2, 91, 92, 7, 116, 2, 2, 92, 93, 7, 103, 2, 2, 93, 94, 7, 118, 2, 2,
2, 2, 96, 97, 7, 112, 2, 2, 97, 98, 7, 117, 2, 2, 98, 22, 3, 2, 2, 2, 99, 94, 95, 7, 119, 2, 2, 95, 96, 7, 116, 2, 2, 96, 97, 7, 112, 2, 2, 97, 98,
100, 7, 47, 2, 2, 100, 24, 3, 2, 2, 2, 101, 102, 7, 49, 2, 2, 102, 26, 7, 117, 2, 2, 98, 22, 3, 2, 2, 2, 99, 100, 7, 47, 2, 2, 100, 24, 3, 2,
3, 2, 2, 2, 103, 104, 7, 49, 2, 2, 104, 105, 7, 60, 2, 2, 105, 28, 3, 2, 2, 2, 101, 102, 7, 49, 2, 2, 102, 26, 3, 2, 2, 2, 103, 104, 7, 49, 2, 2,
2, 2, 106, 107, 7, 66, 2, 2, 107, 108, 7, 102, 2, 2, 108, 109, 7, 113, 104, 105, 7, 60, 2, 2, 105, 28, 3, 2, 2, 2, 106, 107, 7, 66, 2, 2, 107,
2, 2, 109, 110, 7, 101, 2, 2, 110, 30, 3, 2, 2, 2, 111, 112, 7, 66, 2, 108, 7, 102, 2, 2, 108, 109, 7, 113, 2, 2, 109, 110, 7, 101, 2, 2, 110,
2, 112, 113, 7, 106, 2, 2, 113, 114, 7, 99, 2, 2, 114, 115, 7, 112, 2, 30, 3, 2, 2, 2, 111, 112, 7, 66, 2, 2, 112, 113, 7, 106, 2, 2, 113, 114,
2, 115, 116, 7, 102, 2, 2, 116, 117, 7, 110, 2, 2, 117, 118, 7, 103, 2, 7, 99, 2, 2, 114, 115, 7, 112, 2, 2, 115, 116, 7, 102, 2, 2, 116, 117,
2, 118, 119, 7, 116, 2, 2, 119, 32, 3, 2, 2, 2, 120, 121, 7, 107, 2, 2, 7, 110, 2, 2, 117, 118, 7, 103, 2, 2, 118, 119, 7, 116, 2, 2, 119, 32,
121, 122, 7, 112, 2, 2, 122, 123, 7, 118, 2, 2, 123, 124, 7, 103, 2, 2, 3, 2, 2, 2, 120, 121, 7, 107, 2, 2, 121, 122, 7, 112, 2, 2, 122, 123, 7,
124, 125, 7, 116, 2, 2, 125, 126, 7, 104, 2, 2, 126, 127, 7, 99, 2, 2, 118, 2, 2, 123, 124, 7, 103, 2, 2, 124, 125, 7, 116, 2, 2, 125, 126, 7,
127, 128, 7, 101, 2, 2, 128, 129, 7, 103, 2, 2, 129, 130, 7, 125, 2, 2, 104, 2, 2, 126, 127, 7, 99, 2, 2, 127, 128, 7, 101, 2, 2, 128, 129, 7,
130, 131, 7, 127, 2, 2, 131, 34, 3, 2, 2, 2, 132, 133, 7, 66, 2, 2, 133, 103, 2, 2, 129, 130, 7, 125, 2, 2, 130, 131, 7, 127, 2, 2, 131, 34, 3,
134, 7, 117, 2, 2, 134, 135, 7, 103, 2, 2, 135, 136, 7, 116, 2, 2, 136, 2, 2, 2, 132, 133, 7, 66, 2, 2, 133, 134, 7, 117, 2, 2, 134, 135, 7, 103,
137, 7, 120, 2, 2, 137, 138, 7, 103, 2, 2, 138, 139, 7, 116, 2, 2, 139, 2, 2, 135, 136, 7, 116, 2, 2, 136, 137, 7, 120, 2, 2, 137, 138, 7, 103,
36, 3, 2, 2, 2, 140, 142, 9, 2, 2, 2, 141, 140, 3, 2, 2, 2, 142, 143, 3, 2, 2, 138, 139, 7, 116, 2, 2, 139, 36, 3, 2, 2, 2, 140, 142, 9, 2, 2, 2,
2, 2, 2, 143, 141, 3, 2, 2, 2, 143, 144, 3, 2, 2, 2, 144, 145, 3, 2, 2, 141, 140, 3, 2, 2, 2, 142, 143, 3, 2, 2, 2, 143, 141, 3, 2, 2, 2, 143,
2, 145, 146, 8, 19, 2, 2, 146, 38, 3, 2, 2, 2, 147, 148, 7, 49, 2, 2, 148, 144, 3, 2, 2, 2, 144, 145, 3, 2, 2, 2, 145, 146, 8, 19, 2, 2, 146, 38,
149, 7, 44, 2, 2, 149, 153, 3, 2, 2, 2, 150, 152, 11, 2, 2, 2, 151, 150, 3, 2, 2, 2, 147, 148, 7, 49, 2, 2, 148, 149, 7, 44, 2, 2, 149, 153, 3,
3, 2, 2, 2, 152, 155, 3, 2, 2, 2, 153, 154, 3, 2, 2, 2, 153, 151, 3, 2, 2, 2, 2, 150, 152, 11, 2, 2, 2, 151, 150, 3, 2, 2, 2, 152, 155, 3, 2, 2,
2, 2, 154, 156, 3, 2, 2, 2, 155, 153, 3, 2, 2, 2, 156, 157, 7, 44, 2, 2, 2, 153, 154, 3, 2, 2, 2, 153, 151, 3, 2, 2, 2, 154, 156, 3, 2, 2, 2, 155,
157, 158, 7, 49, 2, 2, 158, 159, 3, 2, 2, 2, 159, 160, 8, 20, 3, 2, 160, 153, 3, 2, 2, 2, 156, 157, 7, 44, 2, 2, 157, 158, 7, 49, 2, 2, 158, 159,
40, 3, 2, 2, 2, 161, 162, 7, 49, 2, 2, 162, 163, 7, 49, 2, 2, 163, 167, 3, 2, 2, 2, 159, 160, 8, 20, 3, 2, 160, 40, 3, 2, 2, 2, 161, 162, 7, 49,
3, 2, 2, 2, 164, 166, 10, 3, 2, 2, 165, 164, 3, 2, 2, 2, 166, 169, 3, 2, 2, 2, 162, 163, 7, 49, 2, 2, 163, 167, 3, 2, 2, 2, 164, 166, 10, 3, 2,
2, 2, 167, 165, 3, 2, 2, 2, 167, 168, 3, 2, 2, 2, 168, 170, 3, 2, 2, 2, 2, 165, 164, 3, 2, 2, 2, 166, 169, 3, 2, 2, 2, 167, 165, 3, 2, 2, 2, 167,
169, 167, 3, 2, 2, 2, 170, 171, 8, 21, 3, 2, 171, 42, 3, 2, 2, 2, 172, 168, 3, 2, 2, 2, 168, 170, 3, 2, 2, 2, 169, 167, 3, 2, 2, 2, 170, 171,
177, 7, 36, 2, 2, 173, 176, 10, 4, 2, 2, 174, 176, 5, 53, 27, 2, 175, 173, 8, 21, 3, 2, 171, 42, 3, 2, 2, 2, 172, 177, 7, 36, 2, 2, 173, 176, 10,
3, 2, 2, 2, 175, 174, 3, 2, 2, 2, 176, 179, 3, 2, 2, 2, 177, 175, 3, 2, 4, 2, 2, 174, 176, 5, 55, 28, 2, 175, 173, 3, 2, 2, 2, 175, 174, 3, 2,
2, 2, 177, 178, 3, 2, 2, 2, 178, 180, 3, 2, 2, 2, 179, 177, 3, 2, 2, 2, 2, 2, 176, 179, 3, 2, 2, 2, 177, 175, 3, 2, 2, 2, 177, 178, 3, 2, 2, 2,
180, 181, 7, 36, 2, 2, 181, 44, 3, 2, 2, 2, 182, 185, 7, 98, 2, 2, 183, 178, 180, 3, 2, 2, 2, 179, 177, 3, 2, 2, 2, 180, 181, 7, 36, 2, 2, 181,
186, 10, 5, 2, 2, 184, 186, 5, 53, 27, 2, 185, 183, 3, 2, 2, 2, 185, 184, 44, 3, 2, 2, 2, 182, 185, 7, 98, 2, 2, 183, 186, 10, 5, 2, 2, 184, 186,
3, 2, 2, 2, 186, 187, 3, 2, 2, 2, 187, 185, 3, 2, 2, 2, 187, 188, 3, 2, 5, 55, 28, 2, 185, 183, 3, 2, 2, 2, 185, 184, 3, 2, 2, 2, 186, 187, 3,
2, 2, 188, 189, 3, 2, 2, 2, 189, 190, 7, 98, 2, 2, 190, 46, 3, 2, 2, 2, 2, 2, 2, 187, 185, 3, 2, 2, 2, 187, 188, 3, 2, 2, 2, 188, 189, 3, 2, 2,
191, 195, 7, 60, 2, 2, 192, 194, 9, 6, 2, 2, 193, 192, 3, 2, 2, 2, 194, 2, 189, 190, 7, 98, 2, 2, 190, 46, 3, 2, 2, 2, 191, 195, 7, 60, 2, 2, 192,
197, 3, 2, 2, 2, 195, 193, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 205, 194, 9, 6, 2, 2, 193, 192, 3, 2, 2, 2, 194, 197, 3, 2, 2, 2, 195, 193,
3, 2, 2, 2, 197, 195, 3, 2, 2, 2, 198, 206, 5, 43, 22, 2, 199, 201, 10, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 205, 3, 2, 2, 2, 197, 195, 3, 2,
7, 2, 2, 200, 199, 3, 2, 2, 2, 201, 204, 3, 2, 2, 2, 202, 200, 3, 2, 2, 2, 2, 198, 206, 5, 43, 22, 2, 199, 201, 10, 7, 2, 2, 200, 199, 3, 2, 2,
2, 202, 203, 3, 2, 2, 2, 203, 206, 3, 2, 2, 2, 204, 202, 3, 2, 2, 2, 205, 2, 201, 204, 3, 2, 2, 2, 202, 200, 3, 2, 2, 2, 202, 203, 3, 2, 2, 2, 203,
198, 3, 2, 2, 2, 205, 202, 3, 2, 2, 2, 206, 48, 3, 2, 2, 2, 207, 211, 5, 206, 3, 2, 2, 2, 204, 202, 3, 2, 2, 2, 205, 198, 3, 2, 2, 2, 205, 202,
63, 32, 2, 208, 210, 5, 61, 31, 2, 209, 208, 3, 2, 2, 2, 210, 213, 3, 2, 3, 2, 2, 2, 206, 48, 3, 2, 2, 2, 207, 211, 5, 63, 32, 2, 208, 210, 5, 51,
2, 2, 211, 209, 3, 2, 2, 2, 211, 212, 3, 2, 2, 2, 212, 50, 3, 2, 2, 2, 26, 2, 209, 208, 3, 2, 2, 2, 210, 213, 3, 2, 2, 2, 211, 209, 3, 2, 2, 2,
213, 211, 3, 2, 2, 2, 214, 216, 9, 8, 2, 2, 215, 217, 9, 9, 2, 2, 216, 211, 212, 3, 2, 2, 2, 212, 50, 3, 2, 2, 2, 213, 211, 3, 2, 2, 2, 214, 217,
215, 3, 2, 2, 2, 216, 217, 3, 2, 2, 2, 217, 218, 3, 2, 2, 2, 218, 219, 5, 63, 32, 2, 215, 217, 9, 8, 2, 2, 216, 214, 3, 2, 2, 2, 216, 215, 3,
5, 59, 30, 2, 219, 52, 3, 2, 2, 2, 220, 221, 7, 94, 2, 2, 221, 242, 9, 2, 2, 2, 217, 52, 3, 2, 2, 2, 218, 220, 9, 9, 2, 2, 219, 221, 9, 10, 2,
10, 2, 2, 222, 227, 7, 94, 2, 2, 223, 225, 9, 11, 2, 2, 224, 223, 3, 2, 2, 220, 219, 3, 2, 2, 2, 220, 221, 3, 2, 2, 2, 221, 222, 3, 2, 2, 2, 222,
2, 2, 224, 225, 3, 2, 2, 2, 225, 226, 3, 2, 2, 2, 226, 228, 9, 12, 2, 2, 223, 5, 61, 31, 2, 223, 54, 3, 2, 2, 2, 224, 225, 7, 94, 2, 2, 225, 246,
227, 224, 3, 2, 2, 2, 227, 228, 3, 2, 2, 2, 228, 229, 3, 2, 2, 2, 229, 9, 11, 2, 2, 226, 231, 7, 94, 2, 2, 227, 229, 9, 12, 2, 2, 228, 227, 3,
242, 9, 12, 2, 2, 230, 232, 7, 94, 2, 2, 231, 233, 7, 119, 2, 2, 232, 231, 2, 2, 2, 228, 229, 3, 2, 2, 2, 229, 230, 3, 2, 2, 2, 230, 232, 9, 13, 2,
3, 2, 2, 2, 233, 234, 3, 2, 2, 2, 234, 232, 3, 2, 2, 2, 234, 235, 3, 2, 2, 231, 228, 3, 2, 2, 2, 231, 232, 3, 2, 2, 2, 232, 233, 3, 2, 2, 2, 233,
2, 2, 235, 236, 3, 2, 2, 2, 236, 237, 5, 57, 29, 2, 237, 238, 5, 57, 29, 246, 9, 13, 2, 2, 234, 236, 7, 94, 2, 2, 235, 237, 7, 119, 2, 2, 236, 235,
2, 238, 239, 5, 57, 29, 2, 239, 240, 5, 57, 29, 2, 240, 242, 3, 2, 2, 2, 3, 2, 2, 2, 237, 238, 3, 2, 2, 2, 238, 236, 3, 2, 2, 2, 238, 239, 3, 2,
241, 220, 3, 2, 2, 2, 241, 222, 3, 2, 2, 2, 241, 230, 3, 2, 2, 2, 242, 2, 2, 239, 240, 3, 2, 2, 2, 240, 241, 5, 59, 30, 2, 241, 242, 5, 59, 30,
54, 3, 2, 2, 2, 243, 252, 5, 57, 29, 2, 244, 247, 5, 57, 29, 2, 245, 247, 2, 242, 243, 5, 59, 30, 2, 243, 244, 5, 59, 30, 2, 244, 246, 3, 2, 2, 2,
7, 97, 2, 2, 246, 244, 3, 2, 2, 2, 246, 245, 3, 2, 2, 2, 247, 250, 3, 2, 245, 224, 3, 2, 2, 2, 245, 226, 3, 2, 2, 2, 245, 234, 3, 2, 2, 2, 246,
2, 2, 248, 246, 3, 2, 2, 2, 248, 249, 3, 2, 2, 2, 249, 251, 3, 2, 2, 2, 56, 3, 2, 2, 2, 247, 256, 5, 59, 30, 2, 248, 251, 5, 59, 30, 2, 249, 251,
250, 248, 3, 2, 2, 2, 251, 253, 5, 57, 29, 2, 252, 248, 3, 2, 2, 2, 252, 7, 97, 2, 2, 250, 248, 3, 2, 2, 2, 250, 249, 3, 2, 2, 2, 251, 254, 3, 2,
253, 3, 2, 2, 2, 253, 56, 3, 2, 2, 2, 254, 255, 9, 13, 2, 2, 255, 58, 3, 2, 2, 252, 250, 3, 2, 2, 2, 252, 253, 3, 2, 2, 2, 253, 255, 3, 2, 2, 2,
2, 2, 2, 256, 264, 9, 14, 2, 2, 257, 259, 9, 15, 2, 2, 258, 257, 3, 2, 254, 252, 3, 2, 2, 2, 255, 257, 5, 59, 30, 2, 256, 252, 3, 2, 2, 2, 256,
2, 2, 259, 262, 3, 2, 2, 2, 260, 258, 3, 2, 2, 2, 260, 261, 3, 2, 2, 2, 257, 3, 2, 2, 2, 257, 58, 3, 2, 2, 2, 258, 259, 9, 14, 2, 2, 259, 60, 3,
261, 263, 3, 2, 2, 2, 262, 260, 3, 2, 2, 2, 263, 265, 9, 14, 2, 2, 264, 2, 2, 2, 260, 268, 9, 8, 2, 2, 261, 263, 9, 15, 2, 2, 262, 261, 3, 2, 2,
260, 3, 2, 2, 2, 264, 265, 3, 2, 2, 2, 265, 60, 3, 2, 2, 2, 266, 269, 5, 2, 263, 266, 3, 2, 2, 2, 264, 262, 3, 2, 2, 2, 264, 265, 3, 2, 2, 2, 265,
63, 32, 2, 267, 269, 9, 14, 2, 2, 268, 266, 3, 2, 2, 2, 268, 267, 3, 2, 267, 3, 2, 2, 2, 266, 264, 3, 2, 2, 2, 267, 269, 9, 8, 2, 2, 268, 264,
2, 2, 269, 62, 3, 2, 2, 2, 270, 275, 9, 16, 2, 2, 271, 275, 10, 17, 2, 3, 2, 2, 2, 268, 269, 3, 2, 2, 2, 269, 62, 3, 2, 2, 2, 270, 275, 9, 16,
2, 272, 273, 9, 18, 2, 2, 273, 275, 9, 19, 2, 2, 274, 270, 3, 2, 2, 2, 2, 2, 271, 275, 10, 17, 2, 2, 272, 273, 9, 18, 2, 2, 273, 275, 9, 19, 2,
274, 271, 3, 2, 2, 2, 274, 272, 3, 2, 2, 2, 275, 64, 3, 2, 2, 2, 26, 2, 2, 274, 270, 3, 2, 2, 2, 274, 271, 3, 2, 2, 2, 274, 272, 3, 2, 2, 2, 275,
143, 153, 167, 175, 177, 185, 187, 195, 202, 205, 211, 216, 224, 227, 234, 64, 3, 2, 2, 2, 26, 2, 143, 153, 167, 175, 177, 185, 187, 195, 202, 205,
241, 246, 248, 252, 260, 264, 268, 274, 4, 2, 3, 2, 2, 90, 2, 211, 216, 220, 228, 231, 238, 245, 250, 252, 256, 264, 268, 274, 4, 2,
3, 2, 2, 90, 2,
} }
var lexerChannelNames = []string{ var lexerChannelNames = []string{
@@ -163,15 +162,15 @@ var lexerLiteralNames = []string{
var lexerSymbolicNames = []string{ var lexerSymbolicNames = []string{
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "ATDOC", "ATHANDLER", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "ATDOC", "ATHANDLER",
"INTERFACE", "ATSERVER", "WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING", "INTERFACE", "ATSERVER", "WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING",
"LINE_VALUE", "ID", "LINE_VALUE", "ID", "LetterOrDigit",
} }
var lexerRuleNames = []string{ var lexerRuleNames = []string{
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
"T__9", "T__10", "T__11", "T__12", "ATDOC", "ATHANDLER", "INTERFACE", "ATSERVER", "T__9", "T__10", "T__11", "T__12", "ATDOC", "ATHANDLER", "INTERFACE", "ATSERVER",
"WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING", "LINE_VALUE", "WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING", "LINE_VALUE",
"ID", "ExponentPart", "EscapeSequence", "HexDigits", "HexDigit", "Digits", "ID", "LetterOrDigit", "ExponentPart", "EscapeSequence", "HexDigits", "HexDigit",
"LetterOrDigit", "Letter", "Digits", "Letter",
} }
type ApiParserLexer struct { type ApiParserLexer struct {
@@ -211,30 +210,31 @@ func NewApiParserLexer(input antlr.CharStream) *ApiParserLexer {
// ApiParserLexer tokens. // ApiParserLexer tokens.
const ( const (
ApiParserLexerT__0 = 1 ApiParserLexerT__0 = 1
ApiParserLexerT__1 = 2 ApiParserLexerT__1 = 2
ApiParserLexerT__2 = 3 ApiParserLexerT__2 = 3
ApiParserLexerT__3 = 4 ApiParserLexerT__3 = 4
ApiParserLexerT__4 = 5 ApiParserLexerT__4 = 5
ApiParserLexerT__5 = 6 ApiParserLexerT__5 = 6
ApiParserLexerT__6 = 7 ApiParserLexerT__6 = 7
ApiParserLexerT__7 = 8 ApiParserLexerT__7 = 8
ApiParserLexerT__8 = 9 ApiParserLexerT__8 = 9
ApiParserLexerT__9 = 10 ApiParserLexerT__9 = 10
ApiParserLexerT__10 = 11 ApiParserLexerT__10 = 11
ApiParserLexerT__11 = 12 ApiParserLexerT__11 = 12
ApiParserLexerT__12 = 13 ApiParserLexerT__12 = 13
ApiParserLexerATDOC = 14 ApiParserLexerATDOC = 14
ApiParserLexerATHANDLER = 15 ApiParserLexerATHANDLER = 15
ApiParserLexerINTERFACE = 16 ApiParserLexerINTERFACE = 16
ApiParserLexerATSERVER = 17 ApiParserLexerATSERVER = 17
ApiParserLexerWS = 18 ApiParserLexerWS = 18
ApiParserLexerCOMMENT = 19 ApiParserLexerCOMMENT = 19
ApiParserLexerLINE_COMMENT = 20 ApiParserLexerLINE_COMMENT = 20
ApiParserLexerSTRING = 21 ApiParserLexerSTRING = 21
ApiParserLexerRAW_STRING = 22 ApiParserLexerRAW_STRING = 22
ApiParserLexerLINE_VALUE = 23 ApiParserLexerLINE_VALUE = 23
ApiParserLexerID = 24 ApiParserLexerID = 24
ApiParserLexerLetterOrDigit = 25
) )
const COMEMNTS = 88 const COMEMNTS = 88

View File

@@ -1,5 +1,4 @@
package api package api // ApiParser
import ( import (
"fmt" "fmt"
"reflect" "reflect"
@@ -9,177 +8,176 @@ import (
) )
// Suppress unused import errors // Suppress unused import errors
var ( var _ = fmt.Printf
_ = fmt.Printf var _ = reflect.Copy
_ = reflect.Copy var _ = strconv.Itoa
_ = strconv.Itoa
)
var parserATN = []uint16{ var parserATN = []uint16{
3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 26, 349, 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 27, 356,
4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7,
4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13,
9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9,
18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23,
4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4,
29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34,
9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 3, 2, 7, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9,
2, 78, 10, 2, 12, 2, 14, 2, 81, 11, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 39, 3, 2, 7, 2, 80, 10, 2, 12, 2, 14, 2, 83, 11, 2, 3, 3, 3, 3, 3, 3, 3,
3, 88, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 5, 5, 98, 3, 3, 3, 5, 3, 90, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3,
10, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 6, 7, 108, 10, 7, 5, 5, 5, 100, 10, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 6,
13, 7, 14, 7, 109, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 10, 3, 7, 110, 10, 7, 13, 7, 14, 7, 111, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3,
10, 3, 10, 3, 10, 6, 10, 123, 10, 10, 13, 10, 14, 10, 124, 3, 10, 3, 10, 9, 3, 10, 3, 10, 3, 10, 3, 10, 6, 10, 125, 10, 10, 13, 10, 14, 10, 126,
3, 11, 3, 11, 5, 11, 131, 10, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 3, 10, 3, 10, 3, 11, 3, 11, 5, 11, 133, 10, 11, 3, 12, 3, 12, 3, 12, 3,
13, 3, 13, 3, 13, 7, 13, 141, 10, 13, 12, 13, 14, 13, 144, 11, 13, 3, 13, 12, 3, 13, 3, 13, 3, 13, 3, 13, 7, 13, 143, 10, 13, 12, 13, 14, 13, 146,
3, 13, 3, 14, 3, 14, 5, 14, 150, 10, 14, 3, 15, 3, 15, 5, 15, 154, 10, 11, 13, 3, 13, 3, 13, 3, 14, 3, 14, 5, 14, 152, 10, 14, 3, 15, 3, 15, 5,
15, 3, 16, 3, 16, 3, 16, 5, 16, 159, 10, 16, 3, 16, 3, 16, 7, 16, 163, 15, 156, 10, 15, 3, 16, 3, 16, 3, 16, 5, 16, 161, 10, 16, 3, 16, 3, 16,
10, 16, 12, 16, 14, 16, 166, 11, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 7, 16, 165, 10, 16, 12, 16, 14, 16, 168, 11, 16, 3, 16, 3, 16, 3, 17, 3,
5, 17, 173, 10, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 5, 18, 180, 10, 17, 3, 17, 5, 17, 175, 10, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 5, 18,
18, 3, 18, 3, 18, 7, 18, 184, 10, 18, 12, 18, 14, 18, 187, 11, 18, 3, 18, 182, 10, 18, 3, 18, 3, 18, 7, 18, 186, 10, 18, 12, 18, 14, 18, 189, 11,
3, 18, 3, 19, 3, 19, 3, 19, 5, 19, 194, 10, 19, 3, 19, 3, 19, 3, 20, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 5, 19, 196, 10, 19, 3, 19, 3, 19,
20, 3, 20, 5, 20, 201, 10, 20, 3, 21, 3, 21, 3, 21, 3, 21, 5, 21, 207, 3, 20, 3, 20, 3, 20, 5, 20, 203, 10, 20, 3, 21, 3, 21, 3, 21, 3, 21, 5,
10, 21, 3, 22, 5, 22, 210, 10, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 21, 209, 10, 21, 3, 22, 5, 22, 212, 10, 22, 3, 22, 3, 22, 3, 23, 3, 23,
23, 3, 23, 3, 23, 3, 23, 3, 23, 5, 23, 222, 10, 23, 3, 24, 3, 24, 3, 24, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 5, 23, 224, 10, 23, 3, 24, 3,
3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25,
26, 3, 26, 3, 26, 3, 27, 5, 27, 241, 10, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 5, 27, 243, 10, 27, 3, 27, 3, 27, 3,
3, 28, 6, 28, 248, 10, 28, 13, 28, 14, 28, 249, 3, 28, 3, 28, 3, 29, 3, 28, 3, 28, 3, 28, 6, 28, 250, 10, 28, 13, 28, 14, 28, 251, 3, 28, 3, 28,
29, 3, 29, 3, 29, 3, 29, 7, 29, 259, 10, 29, 12, 29, 14, 29, 262, 11, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 7, 29, 261, 10, 29, 12, 29, 14, 29,
3, 29, 3, 29, 3, 30, 5, 30, 267, 10, 30, 3, 30, 3, 30, 5, 30, 271, 10, 264, 11, 29, 3, 29, 3, 29, 3, 30, 5, 30, 269, 10, 30, 3, 30, 3, 30, 5,
30, 3, 30, 3, 30, 3, 31, 3, 31, 5, 31, 277, 10, 31, 3, 31, 6, 31, 280, 30, 273, 10, 30, 3, 30, 3, 30, 3, 31, 3, 31, 5, 31, 279, 10, 31, 3, 31,
10, 31, 13, 31, 14, 31, 281, 3, 31, 5, 31, 285, 10, 31, 3, 31, 5, 31, 288, 6, 31, 282, 10, 31, 13, 31, 14, 31, 283, 3, 31, 5, 31, 287, 10, 31, 3,
10, 31, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33, 5, 33, 297, 10, 31, 5, 31, 290, 10, 31, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33,
33, 3, 33, 5, 33, 300, 10, 33, 3, 34, 3, 34, 5, 34, 304, 10, 34, 3, 34, 5, 33, 299, 10, 33, 3, 33, 5, 33, 302, 10, 33, 3, 34, 3, 34, 5, 34, 306,
3, 34, 3, 35, 3, 35, 3, 35, 5, 35, 311, 10, 35, 3, 35, 3, 35, 3, 36, 3, 10, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 5, 35, 313, 10, 35, 3, 35, 3,
36, 3, 36, 3, 36, 3, 37, 3, 37, 5, 37, 321, 10, 37, 6, 37, 323, 10, 37, 35, 3, 36, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 5, 37, 323, 10, 37, 6, 37,
13, 37, 14, 37, 324, 3, 38, 3, 38, 3, 38, 3, 38, 7, 38, 331, 10, 38, 12, 325, 10, 37, 13, 37, 14, 37, 326, 3, 38, 3, 38, 3, 38, 3, 38, 7, 38, 333,
38, 14, 38, 334, 11, 38, 3, 38, 3, 38, 3, 38, 3, 38, 5, 38, 340, 10, 38, 10, 38, 12, 38, 14, 38, 336, 11, 38, 3, 38, 3, 38, 3, 38, 3, 38, 5, 38,
6, 38, 342, 10, 38, 13, 38, 14, 38, 343, 3, 38, 5, 38, 347, 10, 38, 3, 342, 10, 38, 6, 38, 344, 10, 38, 13, 38, 14, 38, 345, 3, 38, 5, 38, 349,
38, 2, 2, 39, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 10, 38, 3, 39, 6, 39, 352, 10, 39, 13, 39, 14, 39, 353, 3, 39, 2, 2, 40,
34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
70, 72, 74, 2, 2, 2, 358, 2, 79, 3, 2, 2, 2, 4, 87, 3, 2, 2, 2, 6, 89, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74,
3, 2, 2, 2, 8, 97, 3, 2, 2, 2, 10, 99, 3, 2, 2, 2, 12, 103, 3, 2, 2, 2, 76, 2, 3, 3, 2, 26, 27, 2, 365, 2, 81, 3, 2, 2, 2, 4, 89, 3, 2, 2, 2, 6,
14, 113, 3, 2, 2, 2, 16, 115, 3, 2, 2, 2, 18, 118, 3, 2, 2, 2, 20, 130, 91, 3, 2, 2, 2, 8, 99, 3, 2, 2, 2, 10, 101, 3, 2, 2, 2, 12, 105, 3, 2,
3, 2, 2, 2, 22, 132, 3, 2, 2, 2, 24, 136, 3, 2, 2, 2, 26, 149, 3, 2, 2, 2, 2, 14, 115, 3, 2, 2, 2, 16, 117, 3, 2, 2, 2, 18, 120, 3, 2, 2, 2, 20,
2, 28, 153, 3, 2, 2, 2, 30, 155, 3, 2, 2, 2, 32, 169, 3, 2, 2, 2, 34, 176, 132, 3, 2, 2, 2, 22, 134, 3, 2, 2, 2, 24, 138, 3, 2, 2, 2, 26, 151, 3,
3, 2, 2, 2, 36, 190, 3, 2, 2, 2, 38, 200, 3, 2, 2, 2, 40, 202, 3, 2, 2, 2, 2, 2, 28, 155, 3, 2, 2, 2, 30, 157, 3, 2, 2, 2, 32, 171, 3, 2, 2, 2,
2, 42, 209, 3, 2, 2, 2, 44, 221, 3, 2, 2, 2, 46, 223, 3, 2, 2, 2, 48, 227, 34, 178, 3, 2, 2, 2, 36, 192, 3, 2, 2, 2, 38, 202, 3, 2, 2, 2, 40, 204,
3, 2, 2, 2, 50, 235, 3, 2, 2, 2, 52, 240, 3, 2, 2, 2, 54, 244, 3, 2, 2, 3, 2, 2, 2, 42, 211, 3, 2, 2, 2, 44, 223, 3, 2, 2, 2, 46, 225, 3, 2, 2,
2, 56, 253, 3, 2, 2, 2, 58, 266, 3, 2, 2, 2, 60, 274, 3, 2, 2, 2, 62, 289, 2, 48, 229, 3, 2, 2, 2, 50, 237, 3, 2, 2, 2, 52, 242, 3, 2, 2, 2, 54, 246,
3, 2, 2, 2, 64, 292, 3, 2, 2, 2, 66, 301, 3, 2, 2, 2, 68, 307, 3, 2, 2, 3, 2, 2, 2, 56, 255, 3, 2, 2, 2, 58, 268, 3, 2, 2, 2, 60, 276, 3, 2, 2,
2, 70, 314, 3, 2, 2, 2, 72, 322, 3, 2, 2, 2, 74, 346, 3, 2, 2, 2, 76, 78, 2, 62, 291, 3, 2, 2, 2, 64, 294, 3, 2, 2, 2, 66, 303, 3, 2, 2, 2, 68, 309,
5, 4, 3, 2, 77, 76, 3, 2, 2, 2, 78, 81, 3, 2, 2, 2, 79, 77, 3, 2, 2, 2, 3, 2, 2, 2, 70, 316, 3, 2, 2, 2, 72, 324, 3, 2, 2, 2, 74, 348, 3, 2, 2,
79, 80, 3, 2, 2, 2, 80, 3, 3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 82, 88, 5, 6, 2, 76, 351, 3, 2, 2, 2, 78, 80, 5, 4, 3, 2, 79, 78, 3, 2, 2, 2, 80, 83,
4, 2, 83, 88, 5, 8, 5, 2, 84, 88, 5, 18, 10, 2, 85, 88, 5, 20, 11, 2, 86, 3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 81, 82, 3, 2, 2, 2, 82, 3, 3, 2, 2, 2,
88, 5, 52, 27, 2, 87, 82, 3, 2, 2, 2, 87, 83, 3, 2, 2, 2, 87, 84, 3, 2, 83, 81, 3, 2, 2, 2, 84, 90, 5, 6, 4, 2, 85, 90, 5, 8, 5, 2, 86, 90, 5,
2, 2, 87, 85, 3, 2, 2, 2, 87, 86, 3, 2, 2, 2, 88, 5, 3, 2, 2, 2, 89, 90, 18, 10, 2, 87, 90, 5, 20, 11, 2, 88, 90, 5, 52, 27, 2, 89, 84, 3, 2, 2,
8, 4, 1, 2, 90, 91, 7, 26, 2, 2, 91, 92, 7, 3, 2, 2, 92, 93, 8, 4, 1, 2, 2, 89, 85, 3, 2, 2, 2, 89, 86, 3, 2, 2, 2, 89, 87, 3, 2, 2, 2, 89, 88,
93, 94, 7, 23, 2, 2, 94, 7, 3, 2, 2, 2, 95, 98, 5, 10, 6, 2, 96, 98, 5, 3, 2, 2, 2, 90, 5, 3, 2, 2, 2, 91, 92, 8, 4, 1, 2, 92, 93, 7, 26, 2, 2,
12, 7, 2, 97, 95, 3, 2, 2, 2, 97, 96, 3, 2, 2, 2, 98, 9, 3, 2, 2, 2, 99, 93, 94, 7, 3, 2, 2, 94, 95, 8, 4, 1, 2, 95, 96, 7, 23, 2, 2, 96, 7, 3,
100, 8, 6, 1, 2, 100, 101, 7, 26, 2, 2, 101, 102, 5, 16, 9, 2, 102, 11, 2, 2, 2, 97, 100, 5, 10, 6, 2, 98, 100, 5, 12, 7, 2, 99, 97, 3, 2, 2, 2,
3, 2, 2, 2, 103, 104, 8, 7, 1, 2, 104, 105, 7, 26, 2, 2, 105, 107, 7, 4, 99, 98, 3, 2, 2, 2, 100, 9, 3, 2, 2, 2, 101, 102, 8, 6, 1, 2, 102, 103,
2, 2, 106, 108, 5, 14, 8, 2, 107, 106, 3, 2, 2, 2, 108, 109, 3, 2, 2, 2, 7, 26, 2, 2, 103, 104, 5, 16, 9, 2, 104, 11, 3, 2, 2, 2, 105, 106, 8, 7,
109, 107, 3, 2, 2, 2, 109, 110, 3, 2, 2, 2, 110, 111, 3, 2, 2, 2, 111, 1, 2, 106, 107, 7, 26, 2, 2, 107, 109, 7, 4, 2, 2, 108, 110, 5, 14, 8,
112, 7, 5, 2, 2, 112, 13, 3, 2, 2, 2, 113, 114, 5, 16, 9, 2, 114, 15, 3, 2, 109, 108, 3, 2, 2, 2, 110, 111, 3, 2, 2, 2, 111, 109, 3, 2, 2, 2, 111,
2, 2, 2, 115, 116, 8, 9, 1, 2, 116, 117, 7, 23, 2, 2, 117, 17, 3, 2, 2, 112, 3, 2, 2, 2, 112, 113, 3, 2, 2, 2, 113, 114, 7, 5, 2, 2, 114, 13, 3,
2, 118, 119, 8, 10, 1, 2, 119, 120, 7, 26, 2, 2, 120, 122, 7, 4, 2, 2, 2, 2, 2, 115, 116, 5, 16, 9, 2, 116, 15, 3, 2, 2, 2, 117, 118, 8, 9, 1,
121, 123, 5, 70, 36, 2, 122, 121, 3, 2, 2, 2, 123, 124, 3, 2, 2, 2, 124, 2, 118, 119, 7, 23, 2, 2, 119, 17, 3, 2, 2, 2, 120, 121, 8, 10, 1, 2, 121,
122, 3, 2, 2, 2, 124, 125, 3, 2, 2, 2, 125, 126, 3, 2, 2, 2, 126, 127, 122, 7, 26, 2, 2, 122, 124, 7, 4, 2, 2, 123, 125, 5, 70, 36, 2, 124, 123,
7, 5, 2, 2, 127, 19, 3, 2, 2, 2, 128, 131, 5, 22, 12, 2, 129, 131, 5, 24, 3, 2, 2, 2, 125, 126, 3, 2, 2, 2, 126, 124, 3, 2, 2, 2, 126, 127, 3, 2,
13, 2, 130, 128, 3, 2, 2, 2, 130, 129, 3, 2, 2, 2, 131, 21, 3, 2, 2, 2, 2, 2, 127, 128, 3, 2, 2, 2, 128, 129, 7, 5, 2, 2, 129, 19, 3, 2, 2, 2,
132, 133, 8, 12, 1, 2, 133, 134, 7, 26, 2, 2, 134, 135, 5, 26, 14, 2, 135, 130, 133, 5, 22, 12, 2, 131, 133, 5, 24, 13, 2, 132, 130, 3, 2, 2, 2, 132,
23, 3, 2, 2, 2, 136, 137, 8, 13, 1, 2, 137, 138, 7, 26, 2, 2, 138, 142, 131, 3, 2, 2, 2, 133, 21, 3, 2, 2, 2, 134, 135, 8, 12, 1, 2, 135, 136,
7, 4, 2, 2, 139, 141, 5, 28, 15, 2, 140, 139, 3, 2, 2, 2, 141, 144, 3, 7, 26, 2, 2, 136, 137, 5, 26, 14, 2, 137, 23, 3, 2, 2, 2, 138, 139, 8,
2, 2, 2, 142, 140, 3, 2, 2, 2, 142, 143, 3, 2, 2, 2, 143, 145, 3, 2, 2, 13, 1, 2, 139, 140, 7, 26, 2, 2, 140, 144, 7, 4, 2, 2, 141, 143, 5, 28,
2, 144, 142, 3, 2, 2, 2, 145, 146, 7, 5, 2, 2, 146, 25, 3, 2, 2, 2, 147, 15, 2, 142, 141, 3, 2, 2, 2, 143, 146, 3, 2, 2, 2, 144, 142, 3, 2, 2, 2,
150, 5, 30, 16, 2, 148, 150, 5, 32, 17, 2, 149, 147, 3, 2, 2, 2, 149, 148, 144, 145, 3, 2, 2, 2, 145, 147, 3, 2, 2, 2, 146, 144, 3, 2, 2, 2, 147,
3, 2, 2, 2, 150, 27, 3, 2, 2, 2, 151, 154, 5, 34, 18, 2, 152, 154, 5, 36, 148, 7, 5, 2, 2, 148, 25, 3, 2, 2, 2, 149, 152, 5, 30, 16, 2, 150, 152,
19, 2, 153, 151, 3, 2, 2, 2, 153, 152, 3, 2, 2, 2, 154, 29, 3, 2, 2, 2, 5, 32, 17, 2, 151, 149, 3, 2, 2, 2, 151, 150, 3, 2, 2, 2, 152, 27, 3, 2,
155, 156, 8, 16, 1, 2, 156, 158, 7, 26, 2, 2, 157, 159, 7, 26, 2, 2, 158, 2, 2, 153, 156, 5, 34, 18, 2, 154, 156, 5, 36, 19, 2, 155, 153, 3, 2, 2,
157, 3, 2, 2, 2, 158, 159, 3, 2, 2, 2, 159, 160, 3, 2, 2, 2, 160, 164, 2, 155, 154, 3, 2, 2, 2, 156, 29, 3, 2, 2, 2, 157, 158, 8, 16, 1, 2, 158,
7, 6, 2, 2, 161, 163, 5, 38, 20, 2, 162, 161, 3, 2, 2, 2, 163, 166, 3, 160, 7, 26, 2, 2, 159, 161, 7, 26, 2, 2, 160, 159, 3, 2, 2, 2, 160, 161,
2, 2, 2, 164, 162, 3, 2, 2, 2, 164, 165, 3, 2, 2, 2, 165, 167, 3, 2, 2, 3, 2, 2, 2, 161, 162, 3, 2, 2, 2, 162, 166, 7, 6, 2, 2, 163, 165, 5, 38,
2, 166, 164, 3, 2, 2, 2, 167, 168, 7, 7, 2, 2, 168, 31, 3, 2, 2, 2, 169, 20, 2, 164, 163, 3, 2, 2, 2, 165, 168, 3, 2, 2, 2, 166, 164, 3, 2, 2, 2,
170, 8, 17, 1, 2, 170, 172, 7, 26, 2, 2, 171, 173, 7, 3, 2, 2, 172, 171, 166, 167, 3, 2, 2, 2, 167, 169, 3, 2, 2, 2, 168, 166, 3, 2, 2, 2, 169,
3, 2, 2, 2, 172, 173, 3, 2, 2, 2, 173, 174, 3, 2, 2, 2, 174, 175, 5, 44, 170, 7, 7, 2, 2, 170, 31, 3, 2, 2, 2, 171, 172, 8, 17, 1, 2, 172, 174,
23, 2, 175, 33, 3, 2, 2, 2, 176, 177, 8, 18, 1, 2, 177, 179, 7, 26, 2, 7, 26, 2, 2, 173, 175, 7, 3, 2, 2, 174, 173, 3, 2, 2, 2, 174, 175, 3, 2,
2, 178, 180, 7, 26, 2, 2, 179, 178, 3, 2, 2, 2, 179, 180, 3, 2, 2, 2, 180, 2, 2, 175, 176, 3, 2, 2, 2, 176, 177, 5, 44, 23, 2, 177, 33, 3, 2, 2, 2,
181, 3, 2, 2, 2, 181, 185, 7, 6, 2, 2, 182, 184, 5, 38, 20, 2, 183, 182, 178, 179, 8, 18, 1, 2, 179, 181, 7, 26, 2, 2, 180, 182, 7, 26, 2, 2, 181,
3, 2, 2, 2, 184, 187, 3, 2, 2, 2, 185, 183, 3, 2, 2, 2, 185, 186, 3, 2, 180, 3, 2, 2, 2, 181, 182, 3, 2, 2, 2, 182, 183, 3, 2, 2, 2, 183, 187,
2, 2, 186, 188, 3, 2, 2, 2, 187, 185, 3, 2, 2, 2, 188, 189, 7, 7, 2, 2, 7, 6, 2, 2, 184, 186, 5, 38, 20, 2, 185, 184, 3, 2, 2, 2, 186, 189, 3,
189, 35, 3, 2, 2, 2, 190, 191, 8, 19, 1, 2, 191, 193, 7, 26, 2, 2, 192, 2, 2, 2, 187, 185, 3, 2, 2, 2, 187, 188, 3, 2, 2, 2, 188, 190, 3, 2, 2,
194, 7, 3, 2, 2, 193, 192, 3, 2, 2, 2, 193, 194, 3, 2, 2, 2, 194, 195, 2, 189, 187, 3, 2, 2, 2, 190, 191, 7, 7, 2, 2, 191, 35, 3, 2, 2, 2, 192,
3, 2, 2, 2, 195, 196, 5, 44, 23, 2, 196, 37, 3, 2, 2, 2, 197, 198, 6, 20, 193, 8, 19, 1, 2, 193, 195, 7, 26, 2, 2, 194, 196, 7, 3, 2, 2, 195, 194,
2, 2, 198, 201, 5, 40, 21, 2, 199, 201, 5, 42, 22, 2, 200, 197, 3, 2, 2, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 197, 3, 2, 2, 2, 197, 198, 5, 44,
2, 200, 199, 3, 2, 2, 2, 201, 39, 3, 2, 2, 2, 202, 203, 8, 21, 1, 2, 203, 23, 2, 198, 37, 3, 2, 2, 2, 199, 200, 6, 20, 2, 2, 200, 203, 5, 40, 21,
204, 7, 26, 2, 2, 204, 206, 5, 44, 23, 2, 205, 207, 7, 24, 2, 2, 206, 205, 2, 201, 203, 5, 42, 22, 2, 202, 199, 3, 2, 2, 2, 202, 201, 3, 2, 2, 2,
3, 2, 2, 2, 206, 207, 3, 2, 2, 2, 207, 41, 3, 2, 2, 2, 208, 210, 7, 8, 203, 39, 3, 2, 2, 2, 204, 205, 8, 21, 1, 2, 205, 206, 7, 26, 2, 2, 206,
2, 2, 209, 208, 3, 2, 2, 2, 209, 210, 3, 2, 2, 2, 210, 211, 3, 2, 2, 2, 208, 5, 44, 23, 2, 207, 209, 7, 24, 2, 2, 208, 207, 3, 2, 2, 2, 208, 209,
211, 212, 7, 26, 2, 2, 212, 43, 3, 2, 2, 2, 213, 214, 8, 23, 1, 2, 214, 3, 2, 2, 2, 209, 41, 3, 2, 2, 2, 210, 212, 7, 8, 2, 2, 211, 210, 3, 2,
222, 7, 26, 2, 2, 215, 222, 5, 48, 25, 2, 216, 222, 5, 50, 26, 2, 217, 2, 2, 211, 212, 3, 2, 2, 2, 212, 213, 3, 2, 2, 2, 213, 214, 7, 26, 2, 2,
222, 7, 18, 2, 2, 218, 222, 7, 9, 2, 2, 219, 222, 5, 46, 24, 2, 220, 222, 214, 43, 3, 2, 2, 2, 215, 216, 8, 23, 1, 2, 216, 224, 7, 26, 2, 2, 217,
5, 30, 16, 2, 221, 213, 3, 2, 2, 2, 221, 215, 3, 2, 2, 2, 221, 216, 3, 224, 5, 48, 25, 2, 218, 224, 5, 50, 26, 2, 219, 224, 7, 18, 2, 2, 220,
2, 2, 2, 221, 217, 3, 2, 2, 2, 221, 218, 3, 2, 2, 2, 221, 219, 3, 2, 2, 224, 7, 9, 2, 2, 221, 224, 5, 46, 24, 2, 222, 224, 5, 30, 16, 2, 223, 215,
2, 221, 220, 3, 2, 2, 2, 222, 45, 3, 2, 2, 2, 223, 224, 7, 8, 2, 2, 224, 3, 2, 2, 2, 223, 217, 3, 2, 2, 2, 223, 218, 3, 2, 2, 2, 223, 219, 3, 2,
225, 8, 24, 1, 2, 225, 226, 7, 26, 2, 2, 226, 47, 3, 2, 2, 2, 227, 228, 2, 2, 223, 220, 3, 2, 2, 2, 223, 221, 3, 2, 2, 2, 223, 222, 3, 2, 2, 2,
8, 25, 1, 2, 228, 229, 7, 26, 2, 2, 229, 230, 7, 10, 2, 2, 230, 231, 8, 224, 45, 3, 2, 2, 2, 225, 226, 7, 8, 2, 2, 226, 227, 8, 24, 1, 2, 227,
25, 1, 2, 231, 232, 7, 26, 2, 2, 232, 233, 7, 11, 2, 2, 233, 234, 5, 44, 228, 7, 26, 2, 2, 228, 47, 3, 2, 2, 2, 229, 230, 8, 25, 1, 2, 230, 231,
23, 2, 234, 49, 3, 2, 2, 2, 235, 236, 7, 10, 2, 2, 236, 237, 7, 11, 2, 7, 26, 2, 2, 231, 232, 7, 10, 2, 2, 232, 233, 8, 25, 1, 2, 233, 234, 7,
2, 237, 238, 5, 44, 23, 2, 238, 51, 3, 2, 2, 2, 239, 241, 5, 54, 28, 2, 26, 2, 2, 234, 235, 7, 11, 2, 2, 235, 236, 5, 44, 23, 2, 236, 49, 3, 2,
240, 239, 3, 2, 2, 2, 240, 241, 3, 2, 2, 2, 241, 242, 3, 2, 2, 2, 242, 2, 2, 237, 238, 7, 10, 2, 2, 238, 239, 7, 11, 2, 2, 239, 240, 5, 44, 23,
243, 5, 56, 29, 2, 243, 53, 3, 2, 2, 2, 244, 245, 7, 19, 2, 2, 245, 247, 2, 240, 51, 3, 2, 2, 2, 241, 243, 5, 54, 28, 2, 242, 241, 3, 2, 2, 2, 242,
7, 4, 2, 2, 246, 248, 5, 70, 36, 2, 247, 246, 3, 2, 2, 2, 248, 249, 3, 243, 3, 2, 2, 2, 243, 244, 3, 2, 2, 2, 244, 245, 5, 56, 29, 2, 245, 53,
2, 2, 2, 249, 247, 3, 2, 2, 2, 249, 250, 3, 2, 2, 2, 250, 251, 3, 2, 2, 3, 2, 2, 2, 246, 247, 7, 19, 2, 2, 247, 249, 7, 4, 2, 2, 248, 250, 5, 70,
2, 251, 252, 7, 5, 2, 2, 252, 55, 3, 2, 2, 2, 253, 254, 8, 29, 1, 2, 254, 36, 2, 249, 248, 3, 2, 2, 2, 250, 251, 3, 2, 2, 2, 251, 249, 3, 2, 2, 2,
255, 7, 26, 2, 2, 255, 256, 5, 72, 37, 2, 256, 260, 7, 6, 2, 2, 257, 259, 251, 252, 3, 2, 2, 2, 252, 253, 3, 2, 2, 2, 253, 254, 7, 5, 2, 2, 254,
5, 58, 30, 2, 258, 257, 3, 2, 2, 2, 259, 262, 3, 2, 2, 2, 260, 258, 3, 55, 3, 2, 2, 2, 255, 256, 8, 29, 1, 2, 256, 257, 7, 26, 2, 2, 257, 258,
2, 2, 2, 260, 261, 3, 2, 2, 2, 261, 263, 3, 2, 2, 2, 262, 260, 3, 2, 2, 5, 72, 37, 2, 258, 262, 7, 6, 2, 2, 259, 261, 5, 58, 30, 2, 260, 259, 3,
2, 263, 264, 7, 7, 2, 2, 264, 57, 3, 2, 2, 2, 265, 267, 5, 60, 31, 2, 266, 2, 2, 2, 261, 264, 3, 2, 2, 2, 262, 260, 3, 2, 2, 2, 262, 263, 3, 2, 2,
265, 3, 2, 2, 2, 266, 267, 3, 2, 2, 2, 267, 270, 3, 2, 2, 2, 268, 271, 2, 263, 265, 3, 2, 2, 2, 264, 262, 3, 2, 2, 2, 265, 266, 7, 7, 2, 2, 266,
5, 54, 28, 2, 269, 271, 5, 62, 32, 2, 270, 268, 3, 2, 2, 2, 270, 269, 3, 57, 3, 2, 2, 2, 267, 269, 5, 60, 31, 2, 268, 267, 3, 2, 2, 2, 268, 269,
2, 2, 2, 271, 272, 3, 2, 2, 2, 272, 273, 5, 64, 33, 2, 273, 59, 3, 2, 2, 3, 2, 2, 2, 269, 272, 3, 2, 2, 2, 270, 273, 5, 54, 28, 2, 271, 273, 5,
2, 274, 276, 7, 16, 2, 2, 275, 277, 7, 4, 2, 2, 276, 275, 3, 2, 2, 2, 276, 62, 32, 2, 272, 270, 3, 2, 2, 2, 272, 271, 3, 2, 2, 2, 273, 274, 3, 2,
277, 3, 2, 2, 2, 277, 284, 3, 2, 2, 2, 278, 280, 5, 70, 36, 2, 279, 278, 2, 2, 274, 275, 5, 64, 33, 2, 275, 59, 3, 2, 2, 2, 276, 278, 7, 16, 2,
3, 2, 2, 2, 280, 281, 3, 2, 2, 2, 281, 279, 3, 2, 2, 2, 281, 282, 3, 2, 2, 277, 279, 7, 4, 2, 2, 278, 277, 3, 2, 2, 2, 278, 279, 3, 2, 2, 2, 279,
2, 2, 282, 285, 3, 2, 2, 2, 283, 285, 7, 23, 2, 2, 284, 279, 3, 2, 2, 2, 286, 3, 2, 2, 2, 280, 282, 5, 70, 36, 2, 281, 280, 3, 2, 2, 2, 282, 283,
284, 283, 3, 2, 2, 2, 285, 287, 3, 2, 2, 2, 286, 288, 7, 5, 2, 2, 287, 3, 2, 2, 2, 283, 281, 3, 2, 2, 2, 283, 284, 3, 2, 2, 2, 284, 287, 3, 2,
286, 3, 2, 2, 2, 287, 288, 3, 2, 2, 2, 288, 61, 3, 2, 2, 2, 289, 290, 7, 2, 2, 285, 287, 7, 23, 2, 2, 286, 281, 3, 2, 2, 2, 286, 285, 3, 2, 2, 2,
17, 2, 2, 290, 291, 7, 26, 2, 2, 291, 63, 3, 2, 2, 2, 292, 293, 8, 33, 287, 289, 3, 2, 2, 2, 288, 290, 7, 5, 2, 2, 289, 288, 3, 2, 2, 2, 289,
1, 2, 293, 294, 7, 26, 2, 2, 294, 296, 5, 74, 38, 2, 295, 297, 5, 66, 34, 290, 3, 2, 2, 2, 290, 61, 3, 2, 2, 2, 291, 292, 7, 17, 2, 2, 292, 293,
2, 296, 295, 3, 2, 2, 2, 296, 297, 3, 2, 2, 2, 297, 299, 3, 2, 2, 2, 298, 7, 26, 2, 2, 293, 63, 3, 2, 2, 2, 294, 295, 8, 33, 1, 2, 295, 296, 7, 26,
300, 5, 68, 35, 2, 299, 298, 3, 2, 2, 2, 299, 300, 3, 2, 2, 2, 300, 65, 2, 2, 296, 298, 5, 74, 38, 2, 297, 299, 5, 66, 34, 2, 298, 297, 3, 2, 2,
3, 2, 2, 2, 301, 303, 7, 4, 2, 2, 302, 304, 7, 26, 2, 2, 303, 302, 3, 2, 2, 298, 299, 3, 2, 2, 2, 299, 301, 3, 2, 2, 2, 300, 302, 5, 68, 35, 2,
2, 2, 303, 304, 3, 2, 2, 2, 304, 305, 3, 2, 2, 2, 305, 306, 7, 5, 2, 2, 301, 300, 3, 2, 2, 2, 301, 302, 3, 2, 2, 2, 302, 65, 3, 2, 2, 2, 303, 305,
306, 67, 3, 2, 2, 2, 307, 308, 7, 12, 2, 2, 308, 310, 7, 4, 2, 2, 309, 7, 4, 2, 2, 304, 306, 7, 26, 2, 2, 305, 304, 3, 2, 2, 2, 305, 306, 3, 2,
311, 5, 44, 23, 2, 310, 309, 3, 2, 2, 2, 310, 311, 3, 2, 2, 2, 311, 312, 2, 2, 306, 307, 3, 2, 2, 2, 307, 308, 7, 5, 2, 2, 308, 67, 3, 2, 2, 2,
3, 2, 2, 2, 312, 313, 7, 5, 2, 2, 313, 69, 3, 2, 2, 2, 314, 315, 7, 26, 309, 310, 7, 12, 2, 2, 310, 312, 7, 4, 2, 2, 311, 313, 5, 44, 23, 2, 312,
2, 2, 315, 316, 8, 36, 1, 2, 316, 317, 7, 25, 2, 2, 317, 71, 3, 2, 2, 2, 311, 3, 2, 2, 2, 312, 313, 3, 2, 2, 2, 313, 314, 3, 2, 2, 2, 314, 315,
318, 320, 7, 26, 2, 2, 319, 321, 7, 13, 2, 2, 320, 319, 3, 2, 2, 2, 320, 7, 5, 2, 2, 315, 69, 3, 2, 2, 2, 316, 317, 7, 26, 2, 2, 317, 318, 8, 36,
321, 3, 2, 2, 2, 321, 323, 3, 2, 2, 2, 322, 318, 3, 2, 2, 2, 323, 324, 1, 2, 318, 319, 7, 25, 2, 2, 319, 71, 3, 2, 2, 2, 320, 322, 7, 26, 2, 2,
3, 2, 2, 2, 324, 322, 3, 2, 2, 2, 324, 325, 3, 2, 2, 2, 325, 73, 3, 2, 321, 323, 7, 13, 2, 2, 322, 321, 3, 2, 2, 2, 322, 323, 3, 2, 2, 2, 323,
2, 2, 326, 327, 7, 14, 2, 2, 327, 332, 7, 26, 2, 2, 328, 329, 7, 13, 2, 325, 3, 2, 2, 2, 324, 320, 3, 2, 2, 2, 325, 326, 3, 2, 2, 2, 326, 324,
2, 329, 331, 7, 26, 2, 2, 330, 328, 3, 2, 2, 2, 331, 334, 3, 2, 2, 2, 332, 3, 2, 2, 2, 326, 327, 3, 2, 2, 2, 327, 73, 3, 2, 2, 2, 328, 329, 7, 14,
330, 3, 2, 2, 2, 332, 333, 3, 2, 2, 2, 333, 342, 3, 2, 2, 2, 334, 332, 2, 2, 329, 334, 5, 76, 39, 2, 330, 331, 7, 13, 2, 2, 331, 333, 5, 76, 39,
3, 2, 2, 2, 335, 336, 7, 15, 2, 2, 336, 339, 7, 26, 2, 2, 337, 338, 7, 2, 332, 330, 3, 2, 2, 2, 333, 336, 3, 2, 2, 2, 334, 332, 3, 2, 2, 2, 334,
13, 2, 2, 338, 340, 7, 26, 2, 2, 339, 337, 3, 2, 2, 2, 339, 340, 3, 2, 335, 3, 2, 2, 2, 335, 344, 3, 2, 2, 2, 336, 334, 3, 2, 2, 2, 337, 338,
2, 2, 340, 342, 3, 2, 2, 2, 341, 326, 3, 2, 2, 2, 341, 335, 3, 2, 2, 2, 7, 15, 2, 2, 338, 341, 5, 76, 39, 2, 339, 340, 7, 13, 2, 2, 340, 342, 5,
342, 343, 3, 2, 2, 2, 343, 341, 3, 2, 2, 2, 343, 344, 3, 2, 2, 2, 344, 76, 39, 2, 341, 339, 3, 2, 2, 2, 341, 342, 3, 2, 2, 2, 342, 344, 3, 2,
347, 3, 2, 2, 2, 345, 347, 7, 14, 2, 2, 346, 341, 3, 2, 2, 2, 346, 345, 2, 2, 343, 328, 3, 2, 2, 2, 343, 337, 3, 2, 2, 2, 344, 345, 3, 2, 2, 2,
3, 2, 2, 2, 347, 75, 3, 2, 2, 2, 41, 79, 87, 97, 109, 124, 130, 142, 149, 345, 343, 3, 2, 2, 2, 345, 346, 3, 2, 2, 2, 346, 349, 3, 2, 2, 2, 347,
153, 158, 164, 172, 179, 185, 193, 200, 206, 209, 221, 240, 249, 260, 266, 349, 7, 14, 2, 2, 348, 343, 3, 2, 2, 2, 348, 347, 3, 2, 2, 2, 349, 75,
270, 276, 281, 284, 287, 296, 299, 303, 310, 320, 324, 332, 339, 341, 343, 3, 2, 2, 2, 350, 352, 9, 2, 2, 2, 351, 350, 3, 2, 2, 2, 352, 353, 3, 2,
346, 2, 2, 353, 351, 3, 2, 2, 2, 353, 354, 3, 2, 2, 2, 354, 77, 3, 2, 2, 2,
42, 81, 89, 99, 111, 126, 132, 144, 151, 155, 160, 166, 174, 181, 187,
195, 202, 208, 211, 223, 242, 251, 262, 268, 272, 278, 283, 286, 289, 298,
301, 305, 312, 322, 326, 334, 341, 343, 345, 348, 353,
} }
var literalNames = []string{ var literalNames = []string{
"", "'='", "'('", "')'", "'{'", "'}'", "'*'", "'time.Time'", "'['", "']'", "", "'='", "'('", "')'", "'{'", "'}'", "'*'", "'time.Time'", "'['", "']'",
"'returns'", "'-'", "'/'", "'/:'", "'@doc'", "'@handler'", "'interface{}'", "'returns'", "'-'", "'/'", "'/:'", "'@doc'", "'@handler'", "'interface{}'",
"'@server'", "'@server'",
} }
var symbolicNames = []string{ var symbolicNames = []string{
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "ATDOC", "ATHANDLER", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "ATDOC", "ATHANDLER",
"INTERFACE", "ATSERVER", "WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING", "INTERFACE", "ATSERVER", "WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING",
"LINE_VALUE", "ID", "LINE_VALUE", "ID", "LetterOrDigit",
} }
var ruleNames = []string{ var ruleNames = []string{
@@ -189,6 +187,7 @@ var ruleNames = []string{
"field", "normalField", "anonymousFiled", "dataType", "pointerType", "mapType", "field", "normalField", "anonymousFiled", "dataType", "pointerType", "mapType",
"arrayType", "serviceSpec", "atServer", "serviceApi", "serviceRoute", "atDoc", "arrayType", "serviceSpec", "atServer", "serviceApi", "serviceRoute", "atDoc",
"atHandler", "route", "body", "replybody", "kvLit", "serviceName", "path", "atHandler", "route", "body", "replybody", "kvLit", "serviceName", "path",
"pathItem",
} }
type ApiParserParser struct { type ApiParserParser struct {
@@ -222,31 +221,32 @@ func NewApiParserParser(input antlr.TokenStream) *ApiParserParser {
// ApiParserParser tokens. // ApiParserParser tokens.
const ( const (
ApiParserParserEOF = antlr.TokenEOF ApiParserParserEOF = antlr.TokenEOF
ApiParserParserT__0 = 1 ApiParserParserT__0 = 1
ApiParserParserT__1 = 2 ApiParserParserT__1 = 2
ApiParserParserT__2 = 3 ApiParserParserT__2 = 3
ApiParserParserT__3 = 4 ApiParserParserT__3 = 4
ApiParserParserT__4 = 5 ApiParserParserT__4 = 5
ApiParserParserT__5 = 6 ApiParserParserT__5 = 6
ApiParserParserT__6 = 7 ApiParserParserT__6 = 7
ApiParserParserT__7 = 8 ApiParserParserT__7 = 8
ApiParserParserT__8 = 9 ApiParserParserT__8 = 9
ApiParserParserT__9 = 10 ApiParserParserT__9 = 10
ApiParserParserT__10 = 11 ApiParserParserT__10 = 11
ApiParserParserT__11 = 12 ApiParserParserT__11 = 12
ApiParserParserT__12 = 13 ApiParserParserT__12 = 13
ApiParserParserATDOC = 14 ApiParserParserATDOC = 14
ApiParserParserATHANDLER = 15 ApiParserParserATHANDLER = 15
ApiParserParserINTERFACE = 16 ApiParserParserINTERFACE = 16
ApiParserParserATSERVER = 17 ApiParserParserATSERVER = 17
ApiParserParserWS = 18 ApiParserParserWS = 18
ApiParserParserCOMMENT = 19 ApiParserParserCOMMENT = 19
ApiParserParserLINE_COMMENT = 20 ApiParserParserLINE_COMMENT = 20
ApiParserParserSTRING = 21 ApiParserParserSTRING = 21
ApiParserParserRAW_STRING = 22 ApiParserParserRAW_STRING = 22
ApiParserParserLINE_VALUE = 23 ApiParserParserLINE_VALUE = 23
ApiParserParserID = 24 ApiParserParserID = 24
ApiParserParserLetterOrDigit = 25
) )
// ApiParserParser rules. // ApiParserParser rules.
@@ -288,6 +288,7 @@ const (
ApiParserParserRULE_kvLit = 34 ApiParserParserRULE_kvLit = 34
ApiParserParserRULE_serviceName = 35 ApiParserParserRULE_serviceName = 35
ApiParserParserRULE_path = 36 ApiParserParserRULE_path = 36
ApiParserParserRULE_pathItem = 37
) )
// IApiContext is an interface to support dynamic dispatch. // IApiContext is an interface to support dynamic dispatch.
@@ -307,7 +308,7 @@ type ApiContext struct {
} }
func NewEmptyApiContext() *ApiContext { func NewEmptyApiContext() *ApiContext {
p := new(ApiContext) var p = new(ApiContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_api p.RuleIndex = ApiParserParserRULE_api
return p return p
@@ -316,7 +317,7 @@ func NewEmptyApiContext() *ApiContext {
func (*ApiContext) IsApiContext() {} func (*ApiContext) IsApiContext() {}
func NewApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ApiContext { func NewApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ApiContext {
p := new(ApiContext) var p = new(ApiContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -329,8 +330,8 @@ func NewApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invoking
func (s *ApiContext) GetParser() antlr.Parser { return s.parser } func (s *ApiContext) GetParser() antlr.Parser { return s.parser }
func (s *ApiContext) AllSpec() []ISpecContext { func (s *ApiContext) AllSpec() []ISpecContext {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*ISpecContext)(nil)).Elem()) var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ISpecContext)(nil)).Elem())
tst := make([]ISpecContext, len(ts)) var tst = make([]ISpecContext, len(ts))
for i, t := range ts { for i, t := range ts {
if t != nil { if t != nil {
@@ -342,7 +343,7 @@ func (s *ApiContext) AllSpec() []ISpecContext {
} }
func (s *ApiContext) Spec(i int) ISpecContext { func (s *ApiContext) Spec(i int) ISpecContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ISpecContext)(nil)).Elem(), i) var t = s.GetTypedRuleContext(reflect.TypeOf((*ISpecContext)(nil)).Elem(), i)
if t == nil { if t == nil {
return nil return nil
@@ -391,17 +392,17 @@ func (p *ApiParserParser) Api() (localctx IApiContext) {
}() }()
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
p.SetState(77) p.SetState(79)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
for _la == ApiParserParserATSERVER || _la == ApiParserParserID { for _la == ApiParserParserATSERVER || _la == ApiParserParserID {
{ {
p.SetState(74) p.SetState(76)
p.Spec() p.Spec()
} }
p.SetState(79) p.SetState(81)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
} }
@@ -426,7 +427,7 @@ type SpecContext struct {
} }
func NewEmptySpecContext() *SpecContext { func NewEmptySpecContext() *SpecContext {
p := new(SpecContext) var p = new(SpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_spec p.RuleIndex = ApiParserParserRULE_spec
return p return p
@@ -435,7 +436,7 @@ func NewEmptySpecContext() *SpecContext {
func (*SpecContext) IsSpecContext() {} func (*SpecContext) IsSpecContext() {}
func NewSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SpecContext { func NewSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SpecContext {
p := new(SpecContext) var p = new(SpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -448,7 +449,7 @@ func NewSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokin
func (s *SpecContext) GetParser() antlr.Parser { return s.parser } func (s *SpecContext) GetParser() antlr.Parser { return s.parser }
func (s *SpecContext) SyntaxLit() ISyntaxLitContext { func (s *SpecContext) SyntaxLit() ISyntaxLitContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ISyntaxLitContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*ISyntaxLitContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -458,7 +459,7 @@ func (s *SpecContext) SyntaxLit() ISyntaxLitContext {
} }
func (s *SpecContext) ImportSpec() IImportSpecContext { func (s *SpecContext) ImportSpec() IImportSpecContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportSpecContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportSpecContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -468,7 +469,7 @@ func (s *SpecContext) ImportSpec() IImportSpecContext {
} }
func (s *SpecContext) InfoSpec() IInfoSpecContext { func (s *SpecContext) InfoSpec() IInfoSpecContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IInfoSpecContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IInfoSpecContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -478,7 +479,7 @@ func (s *SpecContext) InfoSpec() IInfoSpecContext {
} }
func (s *SpecContext) TypeSpec() ITypeSpecContext { func (s *SpecContext) TypeSpec() ITypeSpecContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeSpecContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeSpecContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -488,7 +489,7 @@ func (s *SpecContext) TypeSpec() ITypeSpecContext {
} }
func (s *SpecContext) ServiceSpec() IServiceSpecContext { func (s *SpecContext) ServiceSpec() IServiceSpecContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceSpecContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceSpecContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -535,41 +536,41 @@ func (p *ApiParserParser) Spec() (localctx ISpecContext) {
} }
}() }()
p.SetState(85) p.SetState(87)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 1, p.GetParserRuleContext()) { switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 1, p.GetParserRuleContext()) {
case 1: case 1:
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(80) p.SetState(82)
p.SyntaxLit() p.SyntaxLit()
} }
case 2: case 2:
p.EnterOuterAlt(localctx, 2) p.EnterOuterAlt(localctx, 2)
{ {
p.SetState(81) p.SetState(83)
p.ImportSpec() p.ImportSpec()
} }
case 3: case 3:
p.EnterOuterAlt(localctx, 3) p.EnterOuterAlt(localctx, 3)
{ {
p.SetState(82) p.SetState(84)
p.InfoSpec() p.InfoSpec()
} }
case 4: case 4:
p.EnterOuterAlt(localctx, 4) p.EnterOuterAlt(localctx, 4)
{ {
p.SetState(83) p.SetState(85)
p.TypeSpec() p.TypeSpec()
} }
case 5: case 5:
p.EnterOuterAlt(localctx, 5) p.EnterOuterAlt(localctx, 5)
{ {
p.SetState(84) p.SetState(86)
p.ServiceSpec() p.ServiceSpec()
} }
@@ -616,7 +617,7 @@ type SyntaxLitContext struct {
} }
func NewEmptySyntaxLitContext() *SyntaxLitContext { func NewEmptySyntaxLitContext() *SyntaxLitContext {
p := new(SyntaxLitContext) var p = new(SyntaxLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_syntaxLit p.RuleIndex = ApiParserParserRULE_syntaxLit
return p return p
@@ -625,7 +626,7 @@ func NewEmptySyntaxLitContext() *SyntaxLitContext {
func (*SyntaxLitContext) IsSyntaxLitContext() {} func (*SyntaxLitContext) IsSyntaxLitContext() {}
func NewSyntaxLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SyntaxLitContext { func NewSyntaxLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SyntaxLitContext {
p := new(SyntaxLitContext) var p = new(SyntaxLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -634,3 +635,21 @@ func NewSyntaxLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, in
return p return p
} }
func (s *SyntaxLitContext) GetParser() antlr.Parser { return s.parser }
func (s *SyntaxLitContext) GetSyntaxToken() antlr.Token { return s.syntaxToken }
func (s *SyntaxLitContext) GetAssign() antlr.Token { return s.assign }
func (s *SyntaxLitContext) GetVersion() antlr.Token { return s.version }
func (s *SyntaxLitContext) SetSyntaxToken(v antlr.Token) { s.syntaxToken = v }
func (s *SyntaxLitContext) SetAssign(v antlr.Token) { s.assign = v }
func (s *SyntaxLitContext) SetVersion(v antlr.Token) { s.version = v }
func (s *SyntaxLitContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}

View File

@@ -10,24 +10,6 @@ import (
// The apiparser_parser.go file was split into multiple files because it // The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation. // was too large and caused a possible memory overflow during goctl installation.
func (s *SyntaxLitContext) GetParser() antlr.Parser { return s.parser }
func (s *SyntaxLitContext) GetSyntaxToken() antlr.Token { return s.syntaxToken }
func (s *SyntaxLitContext) GetAssign() antlr.Token { return s.assign }
func (s *SyntaxLitContext) GetVersion() antlr.Token { return s.version }
func (s *SyntaxLitContext) SetSyntaxToken(v antlr.Token) { s.syntaxToken = v }
func (s *SyntaxLitContext) SetAssign(v antlr.Token) { s.assign = v }
func (s *SyntaxLitContext) SetVersion(v antlr.Token) { s.version = v }
func (s *SyntaxLitContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *SyntaxLitContext) STRING() antlr.TerminalNode { func (s *SyntaxLitContext) STRING() antlr.TerminalNode {
return s.GetToken(ApiParserParserSTRING, 0) return s.GetToken(ApiParserParserSTRING, 0)
} }
@@ -73,24 +55,24 @@ func (p *ApiParserParser) SyntaxLit() (localctx ISyntaxLitContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
match(p, "syntax") match(p, "syntax")
{ {
p.SetState(88) p.SetState(90)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*SyntaxLitContext).syntaxToken = _m localctx.(*SyntaxLitContext).syntaxToken = _m
} }
{ {
p.SetState(89) p.SetState(91)
_m := p.Match(ApiParserParserT__0) var _m = p.Match(ApiParserParserT__0)
localctx.(*SyntaxLitContext).assign = _m localctx.(*SyntaxLitContext).assign = _m
} }
checkVersion(p) checkVersion(p)
{ {
p.SetState(91) p.SetState(93)
_m := p.Match(ApiParserParserSTRING) var _m = p.Match(ApiParserParserSTRING)
localctx.(*SyntaxLitContext).version = _m localctx.(*SyntaxLitContext).version = _m
} }
@@ -115,7 +97,7 @@ type ImportSpecContext struct {
} }
func NewEmptyImportSpecContext() *ImportSpecContext { func NewEmptyImportSpecContext() *ImportSpecContext {
p := new(ImportSpecContext) var p = new(ImportSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_importSpec p.RuleIndex = ApiParserParserRULE_importSpec
return p return p
@@ -124,7 +106,7 @@ func NewEmptyImportSpecContext() *ImportSpecContext {
func (*ImportSpecContext) IsImportSpecContext() {} func (*ImportSpecContext) IsImportSpecContext() {}
func NewImportSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportSpecContext { func NewImportSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportSpecContext {
p := new(ImportSpecContext) var p = new(ImportSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -137,7 +119,7 @@ func NewImportSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, i
func (s *ImportSpecContext) GetParser() antlr.Parser { return s.parser } func (s *ImportSpecContext) GetParser() antlr.Parser { return s.parser }
func (s *ImportSpecContext) ImportLit() IImportLitContext { func (s *ImportSpecContext) ImportLit() IImportLitContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportLitContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportLitContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -147,7 +129,7 @@ func (s *ImportSpecContext) ImportLit() IImportLitContext {
} }
func (s *ImportSpecContext) ImportBlock() IImportBlockContext { func (s *ImportSpecContext) ImportBlock() IImportBlockContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -194,20 +176,20 @@ func (p *ApiParserParser) ImportSpec() (localctx IImportSpecContext) {
} }
}() }()
p.SetState(95) p.SetState(97)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 2, p.GetParserRuleContext()) { switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 2, p.GetParserRuleContext()) {
case 1: case 1:
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(93) p.SetState(95)
p.ImportLit() p.ImportLit()
} }
case 2: case 2:
p.EnterOuterAlt(localctx, 2) p.EnterOuterAlt(localctx, 2)
{ {
p.SetState(94) p.SetState(96)
p.ImportBlock() p.ImportBlock()
} }
@@ -240,7 +222,7 @@ type ImportLitContext struct {
} }
func NewEmptyImportLitContext() *ImportLitContext { func NewEmptyImportLitContext() *ImportLitContext {
p := new(ImportLitContext) var p = new(ImportLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_importLit p.RuleIndex = ApiParserParserRULE_importLit
return p return p
@@ -249,7 +231,7 @@ func NewEmptyImportLitContext() *ImportLitContext {
func (*ImportLitContext) IsImportLitContext() {} func (*ImportLitContext) IsImportLitContext() {}
func NewImportLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportLitContext { func NewImportLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportLitContext {
p := new(ImportLitContext) var p = new(ImportLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -266,7 +248,7 @@ func (s *ImportLitContext) GetImportToken() antlr.Token { return s.importToken }
func (s *ImportLitContext) SetImportToken(v antlr.Token) { s.importToken = v } func (s *ImportLitContext) SetImportToken(v antlr.Token) { s.importToken = v }
func (s *ImportLitContext) ImportValue() IImportValueContext { func (s *ImportLitContext) ImportValue() IImportValueContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -320,14 +302,14 @@ func (p *ApiParserParser) ImportLit() (localctx IImportLitContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
match(p, "import") match(p, "import")
{ {
p.SetState(98) p.SetState(100)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*ImportLitContext).importToken = _m localctx.(*ImportLitContext).importToken = _m
} }
{ {
p.SetState(99) p.SetState(101)
p.ImportValue() p.ImportValue()
} }
@@ -358,7 +340,7 @@ type ImportBlockContext struct {
} }
func NewEmptyImportBlockContext() *ImportBlockContext { func NewEmptyImportBlockContext() *ImportBlockContext {
p := new(ImportBlockContext) var p = new(ImportBlockContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_importBlock p.RuleIndex = ApiParserParserRULE_importBlock
return p return p
@@ -367,7 +349,7 @@ func NewEmptyImportBlockContext() *ImportBlockContext {
func (*ImportBlockContext) IsImportBlockContext() {} func (*ImportBlockContext) IsImportBlockContext() {}
func NewImportBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockContext { func NewImportBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockContext {
p := new(ImportBlockContext) var p = new(ImportBlockContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -388,8 +370,8 @@ func (s *ImportBlockContext) ID() antlr.TerminalNode {
} }
func (s *ImportBlockContext) AllImportBlockValue() []IImportBlockValueContext { func (s *ImportBlockContext) AllImportBlockValue() []IImportBlockValueContext {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem()) var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem())
tst := make([]IImportBlockValueContext, len(ts)) var tst = make([]IImportBlockValueContext, len(ts))
for i, t := range ts { for i, t := range ts {
if t != nil { if t != nil {
@@ -401,7 +383,7 @@ func (s *ImportBlockContext) AllImportBlockValue() []IImportBlockValueContext {
} }
func (s *ImportBlockContext) ImportBlockValue(i int) IImportBlockValueContext { func (s *ImportBlockContext) ImportBlockValue(i int) IImportBlockValueContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem(), i) var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem(), i)
if t == nil { if t == nil {
return nil return nil
@@ -452,31 +434,32 @@ func (p *ApiParserParser) ImportBlock() (localctx IImportBlockContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
match(p, "import") match(p, "import")
{ {
p.SetState(102) p.SetState(104)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*ImportBlockContext).importToken = _m localctx.(*ImportBlockContext).importToken = _m
} }
{ {
p.SetState(103) p.SetState(105)
p.Match(ApiParserParserT__1) p.Match(ApiParserParserT__1)
} }
p.SetState(105) p.SetState(107)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
for ok := true; ok; ok = _la == ApiParserParserSTRING { for ok := true; ok; ok = _la == ApiParserParserSTRING {
{ {
p.SetState(104) p.SetState(106)
p.ImportBlockValue() p.ImportBlockValue()
} }
p.SetState(107) p.SetState(109)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
} }
{ {
p.SetState(109) p.SetState(111)
p.Match(ApiParserParserT__2) p.Match(ApiParserParserT__2)
} }
@@ -500,7 +483,7 @@ type ImportBlockValueContext struct {
} }
func NewEmptyImportBlockValueContext() *ImportBlockValueContext { func NewEmptyImportBlockValueContext() *ImportBlockValueContext {
p := new(ImportBlockValueContext) var p = new(ImportBlockValueContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_importBlockValue p.RuleIndex = ApiParserParserRULE_importBlockValue
return p return p
@@ -509,7 +492,7 @@ func NewEmptyImportBlockValueContext() *ImportBlockValueContext {
func (*ImportBlockValueContext) IsImportBlockValueContext() {} func (*ImportBlockValueContext) IsImportBlockValueContext() {}
func NewImportBlockValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockValueContext { func NewImportBlockValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockValueContext {
p := new(ImportBlockValueContext) var p = new(ImportBlockValueContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -522,7 +505,7 @@ func NewImportBlockValueContext(parser antlr.Parser, parent antlr.ParserRuleCont
func (s *ImportBlockValueContext) GetParser() antlr.Parser { return s.parser } func (s *ImportBlockValueContext) GetParser() antlr.Parser { return s.parser }
func (s *ImportBlockValueContext) ImportValue() IImportValueContext { func (s *ImportBlockValueContext) ImportValue() IImportValueContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -571,7 +554,7 @@ func (p *ApiParserParser) ImportBlockValue() (localctx IImportBlockValueContext)
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(111) p.SetState(113)
p.ImportValue() p.ImportValue()
} }
@@ -595,7 +578,7 @@ type ImportValueContext struct {
} }
func NewEmptyImportValueContext() *ImportValueContext { func NewEmptyImportValueContext() *ImportValueContext {
p := new(ImportValueContext) var p = new(ImportValueContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_importValue p.RuleIndex = ApiParserParserRULE_importValue
return p return p
@@ -604,7 +587,7 @@ func NewEmptyImportValueContext() *ImportValueContext {
func (*ImportValueContext) IsImportValueContext() {} func (*ImportValueContext) IsImportValueContext() {}
func NewImportValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportValueContext { func NewImportValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportValueContext {
p := new(ImportValueContext) var p = new(ImportValueContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -613,3 +596,86 @@ func NewImportValueContext(parser antlr.Parser, parent antlr.ParserRuleContext,
return p return p
} }
func (s *ImportValueContext) GetParser() antlr.Parser { return s.parser }
func (s *ImportValueContext) STRING() antlr.TerminalNode {
return s.GetToken(ApiParserParserSTRING, 0)
}
func (s *ImportValueContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ImportValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ImportValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitImportValue(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ImportValue() (localctx IImportValueContext) {
localctx = NewImportValueContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 14, ApiParserParserRULE_importValue)
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
checkImportValue(p)
{
p.SetState(116)
p.Match(ApiParserParserSTRING)
}
return localctx
}
// IInfoSpecContext is an interface to support dynamic dispatch.
type IInfoSpecContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetInfoToken returns the infoToken token.
GetInfoToken() antlr.Token
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetInfoToken sets the infoToken token.
SetInfoToken(antlr.Token)
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsInfoSpecContext differentiates from other interfaces.
IsInfoSpecContext()
}

View File

@@ -10,89 +10,6 @@ import (
// The apiparser_parser.go file was split into multiple files because it // The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation. // was too large and caused a possible memory overflow during goctl installation.
func (s *ImportValueContext) GetParser() antlr.Parser { return s.parser }
func (s *ImportValueContext) STRING() antlr.TerminalNode {
return s.GetToken(ApiParserParserSTRING, 0)
}
func (s *ImportValueContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ImportValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ImportValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitImportValue(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ImportValue() (localctx IImportValueContext) {
localctx = NewImportValueContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 14, ApiParserParserRULE_importValue)
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
checkImportValue(p)
{
p.SetState(114)
p.Match(ApiParserParserSTRING)
}
return localctx
}
// IInfoSpecContext is an interface to support dynamic dispatch.
type IInfoSpecContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetInfoToken returns the infoToken token.
GetInfoToken() antlr.Token
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetInfoToken sets the infoToken token.
SetInfoToken(antlr.Token)
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsInfoSpecContext differentiates from other interfaces.
IsInfoSpecContext()
}
type InfoSpecContext struct { type InfoSpecContext struct {
*antlr.BaseParserRuleContext *antlr.BaseParserRuleContext
parser antlr.Parser parser antlr.Parser
@@ -102,7 +19,7 @@ type InfoSpecContext struct {
} }
func NewEmptyInfoSpecContext() *InfoSpecContext { func NewEmptyInfoSpecContext() *InfoSpecContext {
p := new(InfoSpecContext) var p = new(InfoSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_infoSpec p.RuleIndex = ApiParserParserRULE_infoSpec
return p return p
@@ -111,7 +28,7 @@ func NewEmptyInfoSpecContext() *InfoSpecContext {
func (*InfoSpecContext) IsInfoSpecContext() {} func (*InfoSpecContext) IsInfoSpecContext() {}
func NewInfoSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InfoSpecContext { func NewInfoSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InfoSpecContext {
p := new(InfoSpecContext) var p = new(InfoSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -140,8 +57,8 @@ func (s *InfoSpecContext) ID() antlr.TerminalNode {
} }
func (s *InfoSpecContext) AllKvLit() []IKvLitContext { func (s *InfoSpecContext) AllKvLit() []IKvLitContext {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem()) var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem())
tst := make([]IKvLitContext, len(ts)) var tst = make([]IKvLitContext, len(ts))
for i, t := range ts { for i, t := range ts {
if t != nil { if t != nil {
@@ -153,7 +70,7 @@ func (s *InfoSpecContext) AllKvLit() []IKvLitContext {
} }
func (s *InfoSpecContext) KvLit(i int) IKvLitContext { func (s *InfoSpecContext) KvLit(i int) IKvLitContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i) var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
if t == nil { if t == nil {
return nil return nil
@@ -204,36 +121,37 @@ func (p *ApiParserParser) InfoSpec() (localctx IInfoSpecContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
match(p, "info") match(p, "info")
{ {
p.SetState(117) p.SetState(119)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*InfoSpecContext).infoToken = _m localctx.(*InfoSpecContext).infoToken = _m
} }
{ {
p.SetState(118) p.SetState(120)
_m := p.Match(ApiParserParserT__1) var _m = p.Match(ApiParserParserT__1)
localctx.(*InfoSpecContext).lp = _m localctx.(*InfoSpecContext).lp = _m
} }
p.SetState(120) p.SetState(122)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
for ok := true; ok; ok = _la == ApiParserParserID { for ok := true; ok; ok = _la == ApiParserParserID {
{ {
p.SetState(119) p.SetState(121)
p.KvLit() p.KvLit()
} }
p.SetState(122) p.SetState(124)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
} }
{ {
p.SetState(124) p.SetState(126)
_m := p.Match(ApiParserParserT__2) var _m = p.Match(ApiParserParserT__2)
localctx.(*InfoSpecContext).rp = _m localctx.(*InfoSpecContext).rp = _m
} }
@@ -258,7 +176,7 @@ type TypeSpecContext struct {
} }
func NewEmptyTypeSpecContext() *TypeSpecContext { func NewEmptyTypeSpecContext() *TypeSpecContext {
p := new(TypeSpecContext) var p = new(TypeSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeSpec p.RuleIndex = ApiParserParserRULE_typeSpec
return p return p
@@ -267,7 +185,7 @@ func NewEmptyTypeSpecContext() *TypeSpecContext {
func (*TypeSpecContext) IsTypeSpecContext() {} func (*TypeSpecContext) IsTypeSpecContext() {}
func NewTypeSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeSpecContext { func NewTypeSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeSpecContext {
p := new(TypeSpecContext) var p = new(TypeSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -280,7 +198,7 @@ func NewTypeSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, inv
func (s *TypeSpecContext) GetParser() antlr.Parser { return s.parser } func (s *TypeSpecContext) GetParser() antlr.Parser { return s.parser }
func (s *TypeSpecContext) TypeLit() ITypeLitContext { func (s *TypeSpecContext) TypeLit() ITypeLitContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -290,7 +208,7 @@ func (s *TypeSpecContext) TypeLit() ITypeLitContext {
} }
func (s *TypeSpecContext) TypeBlock() ITypeBlockContext { func (s *TypeSpecContext) TypeBlock() ITypeBlockContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -337,20 +255,20 @@ func (p *ApiParserParser) TypeSpec() (localctx ITypeSpecContext) {
} }
}() }()
p.SetState(128) p.SetState(130)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 5, p.GetParserRuleContext()) { switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 5, p.GetParserRuleContext()) {
case 1: case 1:
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(126) p.SetState(128)
p.TypeLit() p.TypeLit()
} }
case 2: case 2:
p.EnterOuterAlt(localctx, 2) p.EnterOuterAlt(localctx, 2)
{ {
p.SetState(127) p.SetState(129)
p.TypeBlock() p.TypeBlock()
} }
@@ -383,7 +301,7 @@ type TypeLitContext struct {
} }
func NewEmptyTypeLitContext() *TypeLitContext { func NewEmptyTypeLitContext() *TypeLitContext {
p := new(TypeLitContext) var p = new(TypeLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeLit p.RuleIndex = ApiParserParserRULE_typeLit
return p return p
@@ -392,7 +310,7 @@ func NewEmptyTypeLitContext() *TypeLitContext {
func (*TypeLitContext) IsTypeLitContext() {} func (*TypeLitContext) IsTypeLitContext() {}
func NewTypeLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitContext { func NewTypeLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitContext {
p := new(TypeLitContext) var p = new(TypeLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -409,7 +327,7 @@ func (s *TypeLitContext) GetTypeToken() antlr.Token { return s.typeToken }
func (s *TypeLitContext) SetTypeToken(v antlr.Token) { s.typeToken = v } func (s *TypeLitContext) SetTypeToken(v antlr.Token) { s.typeToken = v }
func (s *TypeLitContext) TypeLitBody() ITypeLitBodyContext { func (s *TypeLitContext) TypeLitBody() ITypeLitBodyContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitBodyContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitBodyContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -463,14 +381,14 @@ func (p *ApiParserParser) TypeLit() (localctx ITypeLitContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
match(p, "type") match(p, "type")
{ {
p.SetState(131) p.SetState(133)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*TypeLitContext).typeToken = _m localctx.(*TypeLitContext).typeToken = _m
} }
{ {
p.SetState(132) p.SetState(134)
p.TypeLitBody() p.TypeLitBody()
} }
@@ -515,7 +433,7 @@ type TypeBlockContext struct {
} }
func NewEmptyTypeBlockContext() *TypeBlockContext { func NewEmptyTypeBlockContext() *TypeBlockContext {
p := new(TypeBlockContext) var p = new(TypeBlockContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeBlock p.RuleIndex = ApiParserParserRULE_typeBlock
return p return p
@@ -524,7 +442,7 @@ func NewEmptyTypeBlockContext() *TypeBlockContext {
func (*TypeBlockContext) IsTypeBlockContext() {} func (*TypeBlockContext) IsTypeBlockContext() {}
func NewTypeBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockContext { func NewTypeBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockContext {
p := new(TypeBlockContext) var p = new(TypeBlockContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -553,8 +471,8 @@ func (s *TypeBlockContext) ID() antlr.TerminalNode {
} }
func (s *TypeBlockContext) AllTypeBlockBody() []ITypeBlockBodyContext { func (s *TypeBlockContext) AllTypeBlockBody() []ITypeBlockBodyContext {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem()) var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem())
tst := make([]ITypeBlockBodyContext, len(ts)) var tst = make([]ITypeBlockBodyContext, len(ts))
for i, t := range ts { for i, t := range ts {
if t != nil { if t != nil {
@@ -566,7 +484,7 @@ func (s *TypeBlockContext) AllTypeBlockBody() []ITypeBlockBodyContext {
} }
func (s *TypeBlockContext) TypeBlockBody(i int) ITypeBlockBodyContext { func (s *TypeBlockContext) TypeBlockBody(i int) ITypeBlockBodyContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem(), i) var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem(), i)
if t == nil { if t == nil {
return nil return nil
@@ -617,40 +535,158 @@ func (p *ApiParserParser) TypeBlock() (localctx ITypeBlockContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
match(p, "type") match(p, "type")
{ {
p.SetState(135) p.SetState(137)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*TypeBlockContext).typeToken = _m localctx.(*TypeBlockContext).typeToken = _m
} }
{ {
p.SetState(136) p.SetState(138)
_m := p.Match(ApiParserParserT__1) var _m = p.Match(ApiParserParserT__1)
localctx.(*TypeBlockContext).lp = _m localctx.(*TypeBlockContext).lp = _m
} }
p.SetState(140) p.SetState(142)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
for _la == ApiParserParserID { for _la == ApiParserParserID {
{ {
p.SetState(137) p.SetState(139)
p.TypeBlockBody() p.TypeBlockBody()
} }
p.SetState(142) p.SetState(144)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
} }
{ {
p.SetState(143) p.SetState(145)
_m := p.Match(ApiParserParserT__2) var _m = p.Match(ApiParserParserT__2)
localctx.(*TypeBlockContext).rp = _m localctx.(*TypeBlockContext).rp = _m
} }
return localctx return localctx
} }
// ITypeLitBodyContext is an interface to support dynamic dispatch.
type ITypeLitBodyContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsTypeLitBodyContext differentiates from other interfaces.
IsTypeLitBodyContext()
}
type TypeLitBodyContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
}
func NewEmptyTypeLitBodyContext() *TypeLitBodyContext {
var p = new(TypeLitBodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeLitBody
return p
}
func (*TypeLitBodyContext) IsTypeLitBodyContext() {}
func NewTypeLitBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitBodyContext {
var p = new(TypeLitBodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_typeLitBody
return p
}
func (s *TypeLitBodyContext) GetParser() antlr.Parser { return s.parser }
func (s *TypeLitBodyContext) TypeStruct() ITypeStructContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(ITypeStructContext)
}
func (s *TypeLitBodyContext) TypeAlias() ITypeAliasContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeAliasContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(ITypeAliasContext)
}
func (s *TypeLitBodyContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *TypeLitBodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *TypeLitBodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitTypeLitBody(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) TypeLitBody() (localctx ITypeLitBodyContext) {
localctx = NewTypeLitBodyContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 24, ApiParserParserRULE_typeLitBody)
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.SetState(149)
p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 7, p.GetParserRuleContext()) {
case 1:
p.EnterOuterAlt(localctx, 1)
{
p.SetState(147)
p.TypeStruct()
}
case 2:
p.EnterOuterAlt(localctx, 2)
{
p.SetState(148)
p.TypeAlias()
}
}
return localctx
}

View File

@@ -10,124 +10,6 @@ import (
// The apiparser_parser.go file was split into multiple files because it // The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation. // was too large and caused a possible memory overflow during goctl installation.
// ITypeLitBodyContext is an interface to support dynamic dispatch.
type ITypeLitBodyContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsTypeLitBodyContext differentiates from other interfaces.
IsTypeLitBodyContext()
}
type TypeLitBodyContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
}
func NewEmptyTypeLitBodyContext() *TypeLitBodyContext {
p := new(TypeLitBodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeLitBody
return p
}
func (*TypeLitBodyContext) IsTypeLitBodyContext() {}
func NewTypeLitBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitBodyContext {
p := new(TypeLitBodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_typeLitBody
return p
}
func (s *TypeLitBodyContext) GetParser() antlr.Parser { return s.parser }
func (s *TypeLitBodyContext) TypeStruct() ITypeStructContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(ITypeStructContext)
}
func (s *TypeLitBodyContext) TypeAlias() ITypeAliasContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeAliasContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(ITypeAliasContext)
}
func (s *TypeLitBodyContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *TypeLitBodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *TypeLitBodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitTypeLitBody(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) TypeLitBody() (localctx ITypeLitBodyContext) {
localctx = NewTypeLitBodyContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 24, ApiParserParserRULE_typeLitBody)
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.SetState(147)
p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 7, p.GetParserRuleContext()) {
case 1:
p.EnterOuterAlt(localctx, 1)
{
p.SetState(145)
p.TypeStruct()
}
case 2:
p.EnterOuterAlt(localctx, 2)
{
p.SetState(146)
p.TypeAlias()
}
}
return localctx
}
// ITypeBlockBodyContext is an interface to support dynamic dispatch. // ITypeBlockBodyContext is an interface to support dynamic dispatch.
type ITypeBlockBodyContext interface { type ITypeBlockBodyContext interface {
antlr.ParserRuleContext antlr.ParserRuleContext
@@ -145,7 +27,7 @@ type TypeBlockBodyContext struct {
} }
func NewEmptyTypeBlockBodyContext() *TypeBlockBodyContext { func NewEmptyTypeBlockBodyContext() *TypeBlockBodyContext {
p := new(TypeBlockBodyContext) var p = new(TypeBlockBodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeBlockBody p.RuleIndex = ApiParserParserRULE_typeBlockBody
return p return p
@@ -154,7 +36,7 @@ func NewEmptyTypeBlockBodyContext() *TypeBlockBodyContext {
func (*TypeBlockBodyContext) IsTypeBlockBodyContext() {} func (*TypeBlockBodyContext) IsTypeBlockBodyContext() {}
func NewTypeBlockBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockBodyContext { func NewTypeBlockBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockBodyContext {
p := new(TypeBlockBodyContext) var p = new(TypeBlockBodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -167,7 +49,7 @@ func NewTypeBlockBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext
func (s *TypeBlockBodyContext) GetParser() antlr.Parser { return s.parser } func (s *TypeBlockBodyContext) GetParser() antlr.Parser { return s.parser }
func (s *TypeBlockBodyContext) TypeBlockStruct() ITypeBlockStructContext { func (s *TypeBlockBodyContext) TypeBlockStruct() ITypeBlockStructContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockStructContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockStructContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -177,7 +59,7 @@ func (s *TypeBlockBodyContext) TypeBlockStruct() ITypeBlockStructContext {
} }
func (s *TypeBlockBodyContext) TypeBlockAlias() ITypeBlockAliasContext { func (s *TypeBlockBodyContext) TypeBlockAlias() ITypeBlockAliasContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockAliasContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockAliasContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -224,20 +106,20 @@ func (p *ApiParserParser) TypeBlockBody() (localctx ITypeBlockBodyContext) {
} }
}() }()
p.SetState(151) p.SetState(153)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 8, p.GetParserRuleContext()) { switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 8, p.GetParserRuleContext()) {
case 1: case 1:
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(149) p.SetState(151)
p.TypeBlockStruct() p.TypeBlockStruct()
} }
case 2: case 2:
p.EnterOuterAlt(localctx, 2) p.EnterOuterAlt(localctx, 2)
{ {
p.SetState(150) p.SetState(152)
p.TypeBlockAlias() p.TypeBlockAlias()
} }
@@ -291,7 +173,7 @@ type TypeStructContext struct {
} }
func NewEmptyTypeStructContext() *TypeStructContext { func NewEmptyTypeStructContext() *TypeStructContext {
p := new(TypeStructContext) var p = new(TypeStructContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeStruct p.RuleIndex = ApiParserParserRULE_typeStruct
return p return p
@@ -300,7 +182,7 @@ func NewEmptyTypeStructContext() *TypeStructContext {
func (*TypeStructContext) IsTypeStructContext() {} func (*TypeStructContext) IsTypeStructContext() {}
func NewTypeStructContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeStructContext { func NewTypeStructContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeStructContext {
p := new(TypeStructContext) var p = new(TypeStructContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -337,8 +219,8 @@ func (s *TypeStructContext) ID(i int) antlr.TerminalNode {
} }
func (s *TypeStructContext) AllField() []IFieldContext { func (s *TypeStructContext) AllField() []IFieldContext {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem()) var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem())
tst := make([]IFieldContext, len(ts)) var tst = make([]IFieldContext, len(ts))
for i, t := range ts { for i, t := range ts {
if t != nil { if t != nil {
@@ -350,7 +232,7 @@ func (s *TypeStructContext) AllField() []IFieldContext {
} }
func (s *TypeStructContext) Field(i int) IFieldContext { func (s *TypeStructContext) Field(i int) IFieldContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i) var t = s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i)
if t == nil { if t == nil {
return nil return nil
@@ -403,51 +285,53 @@ func (p *ApiParserParser) TypeStruct() (localctx ITypeStructContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
checkKeyword(p) checkKeyword(p)
{ {
p.SetState(154) p.SetState(156)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*TypeStructContext).structName = _m localctx.(*TypeStructContext).structName = _m
} }
p.SetState(156) p.SetState(158)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
if _la == ApiParserParserID { if _la == ApiParserParserID {
{ {
p.SetState(155) p.SetState(157)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*TypeStructContext).structToken = _m localctx.(*TypeStructContext).structToken = _m
} }
} }
{ {
p.SetState(158) p.SetState(160)
_m := p.Match(ApiParserParserT__3) var _m = p.Match(ApiParserParserT__3)
localctx.(*TypeStructContext).lbrace = _m localctx.(*TypeStructContext).lbrace = _m
} }
p.SetState(162) p.SetState(164)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext()) _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext())
for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { for _alt != 2 && _alt != antlr.ATNInvalidAltNumber {
if _alt == 1 { if _alt == 1 {
{ {
p.SetState(159) p.SetState(161)
p.Field() p.Field()
} }
} }
p.SetState(164) p.SetState(166)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext()) _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext())
} }
{ {
p.SetState(165) p.SetState(167)
_m := p.Match(ApiParserParserT__4) var _m = p.Match(ApiParserParserT__4)
localctx.(*TypeStructContext).rbrace = _m localctx.(*TypeStructContext).rbrace = _m
} }
@@ -486,7 +370,7 @@ type TypeAliasContext struct {
} }
func NewEmptyTypeAliasContext() *TypeAliasContext { func NewEmptyTypeAliasContext() *TypeAliasContext {
p := new(TypeAliasContext) var p = new(TypeAliasContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeAlias p.RuleIndex = ApiParserParserRULE_typeAlias
return p return p
@@ -495,7 +379,7 @@ func NewEmptyTypeAliasContext() *TypeAliasContext {
func (*TypeAliasContext) IsTypeAliasContext() {} func (*TypeAliasContext) IsTypeAliasContext() {}
func NewTypeAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeAliasContext { func NewTypeAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeAliasContext {
p := new(TypeAliasContext) var p = new(TypeAliasContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -516,7 +400,7 @@ func (s *TypeAliasContext) SetAlias(v antlr.Token) { s.alias = v }
func (s *TypeAliasContext) SetAssign(v antlr.Token) { s.assign = v } func (s *TypeAliasContext) SetAssign(v antlr.Token) { s.assign = v }
func (s *TypeAliasContext) DataType() IDataTypeContext { func (s *TypeAliasContext) DataType() IDataTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -571,27 +455,28 @@ func (p *ApiParserParser) TypeAlias() (localctx ITypeAliasContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
checkKeyword(p) checkKeyword(p)
{ {
p.SetState(168) p.SetState(170)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*TypeAliasContext).alias = _m localctx.(*TypeAliasContext).alias = _m
} }
p.SetState(170) p.SetState(172)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__0 { if _la == ApiParserParserT__0 {
{ {
p.SetState(169) p.SetState(171)
_m := p.Match(ApiParserParserT__0) var _m = p.Match(ApiParserParserT__0)
localctx.(*TypeAliasContext).assign = _m localctx.(*TypeAliasContext).assign = _m
} }
} }
{ {
p.SetState(172) p.SetState(174)
p.DataType() p.DataType()
} }
@@ -632,3 +517,179 @@ type ITypeBlockStructContext interface {
// IsTypeBlockStructContext differentiates from other interfaces. // IsTypeBlockStructContext differentiates from other interfaces.
IsTypeBlockStructContext() IsTypeBlockStructContext()
} }
type TypeBlockStructContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
structName antlr.Token
structToken antlr.Token
lbrace antlr.Token
rbrace antlr.Token
}
func NewEmptyTypeBlockStructContext() *TypeBlockStructContext {
var p = new(TypeBlockStructContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeBlockStruct
return p
}
func (*TypeBlockStructContext) IsTypeBlockStructContext() {}
func NewTypeBlockStructContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockStructContext {
var p = new(TypeBlockStructContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_typeBlockStruct
return p
}
func (s *TypeBlockStructContext) GetParser() antlr.Parser { return s.parser }
func (s *TypeBlockStructContext) GetStructName() antlr.Token { return s.structName }
func (s *TypeBlockStructContext) GetStructToken() antlr.Token { return s.structToken }
func (s *TypeBlockStructContext) GetLbrace() antlr.Token { return s.lbrace }
func (s *TypeBlockStructContext) GetRbrace() antlr.Token { return s.rbrace }
func (s *TypeBlockStructContext) SetStructName(v antlr.Token) { s.structName = v }
func (s *TypeBlockStructContext) SetStructToken(v antlr.Token) { s.structToken = v }
func (s *TypeBlockStructContext) SetLbrace(v antlr.Token) { s.lbrace = v }
func (s *TypeBlockStructContext) SetRbrace(v antlr.Token) { s.rbrace = v }
func (s *TypeBlockStructContext) AllID() []antlr.TerminalNode {
return s.GetTokens(ApiParserParserID)
}
func (s *TypeBlockStructContext) ID(i int) antlr.TerminalNode {
return s.GetToken(ApiParserParserID, i)
}
func (s *TypeBlockStructContext) AllField() []IFieldContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem())
var tst = make([]IFieldContext, len(ts))
for i, t := range ts {
if t != nil {
tst[i] = t.(IFieldContext)
}
}
return tst
}
func (s *TypeBlockStructContext) Field(i int) IFieldContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i)
if t == nil {
return nil
}
return t.(IFieldContext)
}
func (s *TypeBlockStructContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *TypeBlockStructContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *TypeBlockStructContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitTypeBlockStruct(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) TypeBlockStruct() (localctx ITypeBlockStructContext) {
localctx = NewTypeBlockStructContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 32, ApiParserParserRULE_typeBlockStruct)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
var _alt int
p.EnterOuterAlt(localctx, 1)
checkKeyword(p)
{
p.SetState(177)
var _m = p.Match(ApiParserParserID)
localctx.(*TypeBlockStructContext).structName = _m
}
p.SetState(179)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserID {
{
p.SetState(178)
var _m = p.Match(ApiParserParserID)
localctx.(*TypeBlockStructContext).structToken = _m
}
}
{
p.SetState(181)
var _m = p.Match(ApiParserParserT__3)
localctx.(*TypeBlockStructContext).lbrace = _m
}
p.SetState(185)
p.GetErrorHandler().Sync(p)
_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 13, p.GetParserRuleContext())
for _alt != 2 && _alt != antlr.ATNInvalidAltNumber {
if _alt == 1 {
{
p.SetState(182)
p.Field()
}
}
p.SetState(187)
p.GetErrorHandler().Sync(p)
_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 13, p.GetParserRuleContext())
}
{
p.SetState(188)
var _m = p.Match(ApiParserParserT__4)
localctx.(*TypeBlockStructContext).rbrace = _m
}
return localctx
}

View File

@@ -10,180 +10,6 @@ import (
// The apiparser_parser.go file was split into multiple files because it // The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation. // was too large and caused a possible memory overflow during goctl installation.
type TypeBlockStructContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
structName antlr.Token
structToken antlr.Token
lbrace antlr.Token
rbrace antlr.Token
}
func NewEmptyTypeBlockStructContext() *TypeBlockStructContext {
p := new(TypeBlockStructContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeBlockStruct
return p
}
func (*TypeBlockStructContext) IsTypeBlockStructContext() {}
func NewTypeBlockStructContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockStructContext {
p := new(TypeBlockStructContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_typeBlockStruct
return p
}
func (s *TypeBlockStructContext) GetParser() antlr.Parser { return s.parser }
func (s *TypeBlockStructContext) GetStructName() antlr.Token { return s.structName }
func (s *TypeBlockStructContext) GetStructToken() antlr.Token { return s.structToken }
func (s *TypeBlockStructContext) GetLbrace() antlr.Token { return s.lbrace }
func (s *TypeBlockStructContext) GetRbrace() antlr.Token { return s.rbrace }
func (s *TypeBlockStructContext) SetStructName(v antlr.Token) { s.structName = v }
func (s *TypeBlockStructContext) SetStructToken(v antlr.Token) { s.structToken = v }
func (s *TypeBlockStructContext) SetLbrace(v antlr.Token) { s.lbrace = v }
func (s *TypeBlockStructContext) SetRbrace(v antlr.Token) { s.rbrace = v }
func (s *TypeBlockStructContext) AllID() []antlr.TerminalNode {
return s.GetTokens(ApiParserParserID)
}
func (s *TypeBlockStructContext) ID(i int) antlr.TerminalNode {
return s.GetToken(ApiParserParserID, i)
}
func (s *TypeBlockStructContext) AllField() []IFieldContext {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem())
tst := make([]IFieldContext, len(ts))
for i, t := range ts {
if t != nil {
tst[i] = t.(IFieldContext)
}
}
return tst
}
func (s *TypeBlockStructContext) Field(i int) IFieldContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i)
if t == nil {
return nil
}
return t.(IFieldContext)
}
func (s *TypeBlockStructContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *TypeBlockStructContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *TypeBlockStructContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitTypeBlockStruct(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) TypeBlockStruct() (localctx ITypeBlockStructContext) {
localctx = NewTypeBlockStructContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 32, ApiParserParserRULE_typeBlockStruct)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
var _alt int
p.EnterOuterAlt(localctx, 1)
checkKeyword(p)
{
p.SetState(175)
_m := p.Match(ApiParserParserID)
localctx.(*TypeBlockStructContext).structName = _m
}
p.SetState(177)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserID {
{
p.SetState(176)
_m := p.Match(ApiParserParserID)
localctx.(*TypeBlockStructContext).structToken = _m
}
}
{
p.SetState(179)
_m := p.Match(ApiParserParserT__3)
localctx.(*TypeBlockStructContext).lbrace = _m
}
p.SetState(183)
p.GetErrorHandler().Sync(p)
_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 13, p.GetParserRuleContext())
for _alt != 2 && _alt != antlr.ATNInvalidAltNumber {
if _alt == 1 {
{
p.SetState(180)
p.Field()
}
}
p.SetState(185)
p.GetErrorHandler().Sync(p)
_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 13, p.GetParserRuleContext())
}
{
p.SetState(186)
_m := p.Match(ApiParserParserT__4)
localctx.(*TypeBlockStructContext).rbrace = _m
}
return localctx
}
// ITypeBlockAliasContext is an interface to support dynamic dispatch. // ITypeBlockAliasContext is an interface to support dynamic dispatch.
type ITypeBlockAliasContext interface { type ITypeBlockAliasContext interface {
antlr.ParserRuleContext antlr.ParserRuleContext
@@ -215,7 +41,7 @@ type TypeBlockAliasContext struct {
} }
func NewEmptyTypeBlockAliasContext() *TypeBlockAliasContext { func NewEmptyTypeBlockAliasContext() *TypeBlockAliasContext {
p := new(TypeBlockAliasContext) var p = new(TypeBlockAliasContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_typeBlockAlias p.RuleIndex = ApiParserParserRULE_typeBlockAlias
return p return p
@@ -224,7 +50,7 @@ func NewEmptyTypeBlockAliasContext() *TypeBlockAliasContext {
func (*TypeBlockAliasContext) IsTypeBlockAliasContext() {} func (*TypeBlockAliasContext) IsTypeBlockAliasContext() {}
func NewTypeBlockAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockAliasContext { func NewTypeBlockAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockAliasContext {
p := new(TypeBlockAliasContext) var p = new(TypeBlockAliasContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -245,7 +71,7 @@ func (s *TypeBlockAliasContext) SetAlias(v antlr.Token) { s.alias = v }
func (s *TypeBlockAliasContext) SetAssign(v antlr.Token) { s.assign = v } func (s *TypeBlockAliasContext) SetAssign(v antlr.Token) { s.assign = v }
func (s *TypeBlockAliasContext) DataType() IDataTypeContext { func (s *TypeBlockAliasContext) DataType() IDataTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -300,27 +126,28 @@ func (p *ApiParserParser) TypeBlockAlias() (localctx ITypeBlockAliasContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
checkKeyword(p) checkKeyword(p)
{ {
p.SetState(189) p.SetState(191)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*TypeBlockAliasContext).alias = _m localctx.(*TypeBlockAliasContext).alias = _m
} }
p.SetState(191) p.SetState(193)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__0 { if _la == ApiParserParserT__0 {
{ {
p.SetState(190) p.SetState(192)
_m := p.Match(ApiParserParserT__0) var _m = p.Match(ApiParserParserT__0)
localctx.(*TypeBlockAliasContext).assign = _m localctx.(*TypeBlockAliasContext).assign = _m
} }
} }
{ {
p.SetState(193) p.SetState(195)
p.DataType() p.DataType()
} }
@@ -344,7 +171,7 @@ type FieldContext struct {
} }
func NewEmptyFieldContext() *FieldContext { func NewEmptyFieldContext() *FieldContext {
p := new(FieldContext) var p = new(FieldContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_field p.RuleIndex = ApiParserParserRULE_field
return p return p
@@ -353,7 +180,7 @@ func NewEmptyFieldContext() *FieldContext {
func (*FieldContext) IsFieldContext() {} func (*FieldContext) IsFieldContext() {}
func NewFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FieldContext { func NewFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FieldContext {
p := new(FieldContext) var p = new(FieldContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -366,7 +193,7 @@ func NewFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invoki
func (s *FieldContext) GetParser() antlr.Parser { return s.parser } func (s *FieldContext) GetParser() antlr.Parser { return s.parser }
func (s *FieldContext) NormalField() INormalFieldContext { func (s *FieldContext) NormalField() INormalFieldContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*INormalFieldContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*INormalFieldContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -376,7 +203,7 @@ func (s *FieldContext) NormalField() INormalFieldContext {
} }
func (s *FieldContext) AnonymousFiled() IAnonymousFiledContext { func (s *FieldContext) AnonymousFiled() IAnonymousFiledContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IAnonymousFiledContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IAnonymousFiledContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -423,25 +250,25 @@ func (p *ApiParserParser) Field() (localctx IFieldContext) {
} }
}() }()
p.SetState(198) p.SetState(200)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 15, p.GetParserRuleContext()) { switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 15, p.GetParserRuleContext()) {
case 1: case 1:
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
p.SetState(195) p.SetState(197)
if !(isNormal(p)) { if !(isNormal(p)) {
panic(antlr.NewFailedPredicateException(p, "isNormal(p)", "")) panic(antlr.NewFailedPredicateException(p, "isNormal(p)", ""))
} }
{ {
p.SetState(196) p.SetState(198)
p.NormalField() p.NormalField()
} }
case 2: case 2:
p.EnterOuterAlt(localctx, 2) p.EnterOuterAlt(localctx, 2)
{ {
p.SetState(197) p.SetState(199)
p.AnonymousFiled() p.AnonymousFiled()
} }
@@ -481,7 +308,7 @@ type NormalFieldContext struct {
} }
func NewEmptyNormalFieldContext() *NormalFieldContext { func NewEmptyNormalFieldContext() *NormalFieldContext {
p := new(NormalFieldContext) var p = new(NormalFieldContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_normalField p.RuleIndex = ApiParserParserRULE_normalField
return p return p
@@ -490,7 +317,7 @@ func NewEmptyNormalFieldContext() *NormalFieldContext {
func (*NormalFieldContext) IsNormalFieldContext() {} func (*NormalFieldContext) IsNormalFieldContext() {}
func NewNormalFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *NormalFieldContext { func NewNormalFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *NormalFieldContext {
p := new(NormalFieldContext) var p = new(NormalFieldContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -511,7 +338,7 @@ func (s *NormalFieldContext) SetFieldName(v antlr.Token) { s.fieldName = v }
func (s *NormalFieldContext) SetTag(v antlr.Token) { s.tag = v } func (s *NormalFieldContext) SetTag(v antlr.Token) { s.tag = v }
func (s *NormalFieldContext) DataType() IDataTypeContext { func (s *NormalFieldContext) DataType() IDataTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -569,27 +396,28 @@ func (p *ApiParserParser) NormalField() (localctx INormalFieldContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
checkKeyword(p) checkKeyword(p)
{ {
p.SetState(201) p.SetState(203)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*NormalFieldContext).fieldName = _m localctx.(*NormalFieldContext).fieldName = _m
} }
{ {
p.SetState(202) p.SetState(204)
p.DataType() p.DataType()
} }
p.SetState(204) p.SetState(206)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
if p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 16, p.GetParserRuleContext()) == 1 { if p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 16, p.GetParserRuleContext()) == 1 {
{ {
p.SetState(203) p.SetState(205)
_m := p.Match(ApiParserParserRAW_STRING) var _m = p.Match(ApiParserParserRAW_STRING)
localctx.(*NormalFieldContext).tag = _m localctx.(*NormalFieldContext).tag = _m
} }
} }
return localctx return localctx
@@ -611,3 +439,227 @@ type IAnonymousFiledContext interface {
// IsAnonymousFiledContext differentiates from other interfaces. // IsAnonymousFiledContext differentiates from other interfaces.
IsAnonymousFiledContext() IsAnonymousFiledContext()
} }
type AnonymousFiledContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
star antlr.Token
}
func NewEmptyAnonymousFiledContext() *AnonymousFiledContext {
var p = new(AnonymousFiledContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_anonymousFiled
return p
}
func (*AnonymousFiledContext) IsAnonymousFiledContext() {}
func NewAnonymousFiledContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AnonymousFiledContext {
var p = new(AnonymousFiledContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_anonymousFiled
return p
}
func (s *AnonymousFiledContext) GetParser() antlr.Parser { return s.parser }
func (s *AnonymousFiledContext) GetStar() antlr.Token { return s.star }
func (s *AnonymousFiledContext) SetStar(v antlr.Token) { s.star = v }
func (s *AnonymousFiledContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *AnonymousFiledContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *AnonymousFiledContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *AnonymousFiledContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitAnonymousFiled(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) AnonymousFiled() (localctx IAnonymousFiledContext) {
localctx = NewAnonymousFiledContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 40, ApiParserParserRULE_anonymousFiled)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
p.SetState(209)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__5 {
{
p.SetState(208)
var _m = p.Match(ApiParserParserT__5)
localctx.(*AnonymousFiledContext).star = _m
}
}
{
p.SetState(211)
p.Match(ApiParserParserID)
}
return localctx
}
// IDataTypeContext is an interface to support dynamic dispatch.
type IDataTypeContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetInter returns the inter token.
GetInter() antlr.Token
// GetTime returns the time token.
GetTime() antlr.Token
// SetInter sets the inter token.
SetInter(antlr.Token)
// SetTime sets the time token.
SetTime(antlr.Token)
// IsDataTypeContext differentiates from other interfaces.
IsDataTypeContext()
}
type DataTypeContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
inter antlr.Token
time antlr.Token
}
func NewEmptyDataTypeContext() *DataTypeContext {
var p = new(DataTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_dataType
return p
}
func (*DataTypeContext) IsDataTypeContext() {}
func NewDataTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DataTypeContext {
var p = new(DataTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_dataType
return p
}
func (s *DataTypeContext) GetParser() antlr.Parser { return s.parser }
func (s *DataTypeContext) GetInter() antlr.Token { return s.inter }
func (s *DataTypeContext) GetTime() antlr.Token { return s.time }
func (s *DataTypeContext) SetInter(v antlr.Token) { s.inter = v }
func (s *DataTypeContext) SetTime(v antlr.Token) { s.time = v }
func (s *DataTypeContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *DataTypeContext) MapType() IMapTypeContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IMapTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IMapTypeContext)
}
func (s *DataTypeContext) ArrayType() IArrayTypeContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IArrayTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IArrayTypeContext)
}
func (s *DataTypeContext) INTERFACE() antlr.TerminalNode {
return s.GetToken(ApiParserParserINTERFACE, 0)
}
func (s *DataTypeContext) PointerType() IPointerTypeContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IPointerTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IPointerTypeContext)
}
func (s *DataTypeContext) TypeStruct() ITypeStructContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(ITypeStructContext)
}
func (s *DataTypeContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *DataTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *DataTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitDataType(s)
default:
return t.VisitChildren(s)
}
}

View File

@@ -10,229 +10,6 @@ import (
// The apiparser_parser.go file was split into multiple files because it // The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation. // was too large and caused a possible memory overflow during goctl installation.
type AnonymousFiledContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
star antlr.Token
}
func NewEmptyAnonymousFiledContext() *AnonymousFiledContext {
p := new(AnonymousFiledContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_anonymousFiled
return p
}
func (*AnonymousFiledContext) IsAnonymousFiledContext() {}
func NewAnonymousFiledContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AnonymousFiledContext {
p := new(AnonymousFiledContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_anonymousFiled
return p
}
func (s *AnonymousFiledContext) GetParser() antlr.Parser { return s.parser }
func (s *AnonymousFiledContext) GetStar() antlr.Token { return s.star }
func (s *AnonymousFiledContext) SetStar(v antlr.Token) { s.star = v }
func (s *AnonymousFiledContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *AnonymousFiledContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *AnonymousFiledContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *AnonymousFiledContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitAnonymousFiled(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) AnonymousFiled() (localctx IAnonymousFiledContext) {
localctx = NewAnonymousFiledContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 40, ApiParserParserRULE_anonymousFiled)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
p.SetState(207)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__5 {
{
p.SetState(206)
_m := p.Match(ApiParserParserT__5)
localctx.(*AnonymousFiledContext).star = _m
}
}
{
p.SetState(209)
p.Match(ApiParserParserID)
}
return localctx
}
// IDataTypeContext is an interface to support dynamic dispatch.
type IDataTypeContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetInter returns the inter token.
GetInter() antlr.Token
// GetTime returns the time token.
GetTime() antlr.Token
// SetInter sets the inter token.
SetInter(antlr.Token)
// SetTime sets the time token.
SetTime(antlr.Token)
// IsDataTypeContext differentiates from other interfaces.
IsDataTypeContext()
}
type DataTypeContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
inter antlr.Token
time antlr.Token
}
func NewEmptyDataTypeContext() *DataTypeContext {
p := new(DataTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_dataType
return p
}
func (*DataTypeContext) IsDataTypeContext() {}
func NewDataTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DataTypeContext {
p := new(DataTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_dataType
return p
}
func (s *DataTypeContext) GetParser() antlr.Parser { return s.parser }
func (s *DataTypeContext) GetInter() antlr.Token { return s.inter }
func (s *DataTypeContext) GetTime() antlr.Token { return s.time }
func (s *DataTypeContext) SetInter(v antlr.Token) { s.inter = v }
func (s *DataTypeContext) SetTime(v antlr.Token) { s.time = v }
func (s *DataTypeContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *DataTypeContext) MapType() IMapTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IMapTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IMapTypeContext)
}
func (s *DataTypeContext) ArrayType() IArrayTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IArrayTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IArrayTypeContext)
}
func (s *DataTypeContext) INTERFACE() antlr.TerminalNode {
return s.GetToken(ApiParserParserINTERFACE, 0)
}
func (s *DataTypeContext) PointerType() IPointerTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IPointerTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IPointerTypeContext)
}
func (s *DataTypeContext) TypeStruct() ITypeStructContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(ITypeStructContext)
}
func (s *DataTypeContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *DataTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *DataTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitDataType(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) DataType() (localctx IDataTypeContext) { func (p *ApiParserParser) DataType() (localctx IDataTypeContext) {
localctx = NewDataTypeContext(p, p.GetParserRuleContext(), p.GetState()) localctx = NewDataTypeContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 42, ApiParserParserRULE_dataType) p.EnterRule(localctx, 42, ApiParserParserRULE_dataType)
@@ -253,37 +30,37 @@ func (p *ApiParserParser) DataType() (localctx IDataTypeContext) {
} }
}() }()
p.SetState(219) p.SetState(221)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 18, p.GetParserRuleContext()) { switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 18, p.GetParserRuleContext()) {
case 1: case 1:
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
isInterface(p) isInterface(p)
{ {
p.SetState(212) p.SetState(214)
p.Match(ApiParserParserID) p.Match(ApiParserParserID)
} }
case 2: case 2:
p.EnterOuterAlt(localctx, 2) p.EnterOuterAlt(localctx, 2)
{ {
p.SetState(213) p.SetState(215)
p.MapType() p.MapType()
} }
case 3: case 3:
p.EnterOuterAlt(localctx, 3) p.EnterOuterAlt(localctx, 3)
{ {
p.SetState(214) p.SetState(216)
p.ArrayType() p.ArrayType()
} }
case 4: case 4:
p.EnterOuterAlt(localctx, 4) p.EnterOuterAlt(localctx, 4)
{ {
p.SetState(215) p.SetState(217)
_m := p.Match(ApiParserParserINTERFACE) var _m = p.Match(ApiParserParserINTERFACE)
localctx.(*DataTypeContext).inter = _m localctx.(*DataTypeContext).inter = _m
} }
@@ -291,9 +68,9 @@ func (p *ApiParserParser) DataType() (localctx IDataTypeContext) {
case 5: case 5:
p.EnterOuterAlt(localctx, 5) p.EnterOuterAlt(localctx, 5)
{ {
p.SetState(216) p.SetState(218)
_m := p.Match(ApiParserParserT__6) var _m = p.Match(ApiParserParserT__6)
localctx.(*DataTypeContext).time = _m localctx.(*DataTypeContext).time = _m
} }
@@ -301,14 +78,14 @@ func (p *ApiParserParser) DataType() (localctx IDataTypeContext) {
case 6: case 6:
p.EnterOuterAlt(localctx, 6) p.EnterOuterAlt(localctx, 6)
{ {
p.SetState(217) p.SetState(219)
p.PointerType() p.PointerType()
} }
case 7: case 7:
p.EnterOuterAlt(localctx, 7) p.EnterOuterAlt(localctx, 7)
{ {
p.SetState(218) p.SetState(220)
p.TypeStruct() p.TypeStruct()
} }
@@ -341,7 +118,7 @@ type PointerTypeContext struct {
} }
func NewEmptyPointerTypeContext() *PointerTypeContext { func NewEmptyPointerTypeContext() *PointerTypeContext {
p := new(PointerTypeContext) var p = new(PointerTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_pointerType p.RuleIndex = ApiParserParserRULE_pointerType
return p return p
@@ -350,7 +127,7 @@ func NewEmptyPointerTypeContext() *PointerTypeContext {
func (*PointerTypeContext) IsPointerTypeContext() {} func (*PointerTypeContext) IsPointerTypeContext() {}
func NewPointerTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PointerTypeContext { func NewPointerTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PointerTypeContext {
p := new(PointerTypeContext) var p = new(PointerTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -410,15 +187,15 @@ func (p *ApiParserParser) PointerType() (localctx IPointerTypeContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(221) p.SetState(223)
_m := p.Match(ApiParserParserT__5) var _m = p.Match(ApiParserParserT__5)
localctx.(*PointerTypeContext).star = _m localctx.(*PointerTypeContext).star = _m
} }
checkKeyword(p) checkKeyword(p)
{ {
p.SetState(223) p.SetState(225)
p.Match(ApiParserParserID) p.Match(ApiParserParserID)
} }
@@ -477,7 +254,7 @@ type MapTypeContext struct {
} }
func NewEmptyMapTypeContext() *MapTypeContext { func NewEmptyMapTypeContext() *MapTypeContext {
p := new(MapTypeContext) var p = new(MapTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_mapType p.RuleIndex = ApiParserParserRULE_mapType
return p return p
@@ -486,7 +263,7 @@ func NewEmptyMapTypeContext() *MapTypeContext {
func (*MapTypeContext) IsMapTypeContext() {} func (*MapTypeContext) IsMapTypeContext() {}
func NewMapTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MapTypeContext { func NewMapTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MapTypeContext {
p := new(MapTypeContext) var p = new(MapTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -527,7 +304,7 @@ func (s *MapTypeContext) ID(i int) antlr.TerminalNode {
} }
func (s *MapTypeContext) DataType() IDataTypeContext { func (s *MapTypeContext) DataType() IDataTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -577,41 +354,312 @@ func (p *ApiParserParser) MapType() (localctx IMapTypeContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
match(p, "map") match(p, "map")
{ {
p.SetState(226) p.SetState(228)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*MapTypeContext).mapToken = _m localctx.(*MapTypeContext).mapToken = _m
} }
{ {
p.SetState(227) p.SetState(229)
_m := p.Match(ApiParserParserT__7) var _m = p.Match(ApiParserParserT__7)
localctx.(*MapTypeContext).lbrack = _m localctx.(*MapTypeContext).lbrack = _m
} }
checkKey(p) checkKey(p)
{ {
p.SetState(229) p.SetState(231)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*MapTypeContext).key = _m localctx.(*MapTypeContext).key = _m
} }
{ {
p.SetState(230) p.SetState(232)
_m := p.Match(ApiParserParserT__8) var _m = p.Match(ApiParserParserT__8)
localctx.(*MapTypeContext).rbrack = _m localctx.(*MapTypeContext).rbrack = _m
} }
{ {
p.SetState(231) p.SetState(233)
_x := p.DataType() var _x = p.DataType()
localctx.(*MapTypeContext).value = _x localctx.(*MapTypeContext).value = _x
} }
return localctx return localctx
} }
// IArrayTypeContext is an interface to support dynamic dispatch.
type IArrayTypeContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetLbrack returns the lbrack token.
GetLbrack() antlr.Token
// GetRbrack returns the rbrack token.
GetRbrack() antlr.Token
// SetLbrack sets the lbrack token.
SetLbrack(antlr.Token)
// SetRbrack sets the rbrack token.
SetRbrack(antlr.Token)
// IsArrayTypeContext differentiates from other interfaces.
IsArrayTypeContext()
}
type ArrayTypeContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
lbrack antlr.Token
rbrack antlr.Token
}
func NewEmptyArrayTypeContext() *ArrayTypeContext {
var p = new(ArrayTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_arrayType
return p
}
func (*ArrayTypeContext) IsArrayTypeContext() {}
func NewArrayTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ArrayTypeContext {
var p = new(ArrayTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_arrayType
return p
}
func (s *ArrayTypeContext) GetParser() antlr.Parser { return s.parser }
func (s *ArrayTypeContext) GetLbrack() antlr.Token { return s.lbrack }
func (s *ArrayTypeContext) GetRbrack() antlr.Token { return s.rbrack }
func (s *ArrayTypeContext) SetLbrack(v antlr.Token) { s.lbrack = v }
func (s *ArrayTypeContext) SetRbrack(v antlr.Token) { s.rbrack = v }
func (s *ArrayTypeContext) DataType() IDataTypeContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IDataTypeContext)
}
func (s *ArrayTypeContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ArrayTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ArrayTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitArrayType(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ArrayType() (localctx IArrayTypeContext) {
localctx = NewArrayTypeContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 48, ApiParserParserRULE_arrayType)
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
{
p.SetState(235)
var _m = p.Match(ApiParserParserT__7)
localctx.(*ArrayTypeContext).lbrack = _m
}
{
p.SetState(236)
var _m = p.Match(ApiParserParserT__8)
localctx.(*ArrayTypeContext).rbrack = _m
}
{
p.SetState(237)
p.DataType()
}
return localctx
}
// IServiceSpecContext is an interface to support dynamic dispatch.
type IServiceSpecContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsServiceSpecContext differentiates from other interfaces.
IsServiceSpecContext()
}
type ServiceSpecContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
}
func NewEmptyServiceSpecContext() *ServiceSpecContext {
var p = new(ServiceSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_serviceSpec
return p
}
func (*ServiceSpecContext) IsServiceSpecContext() {}
func NewServiceSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceSpecContext {
var p = new(ServiceSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_serviceSpec
return p
}
func (s *ServiceSpecContext) GetParser() antlr.Parser { return s.parser }
func (s *ServiceSpecContext) ServiceApi() IServiceApiContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceApiContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IServiceApiContext)
}
func (s *ServiceSpecContext) AtServer() IAtServerContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IAtServerContext)
}
func (s *ServiceSpecContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ServiceSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ServiceSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitServiceSpec(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ServiceSpec() (localctx IServiceSpecContext) {
localctx = NewServiceSpecContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 50, ApiParserParserRULE_serviceSpec)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
p.SetState(240)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserATSERVER {
{
p.SetState(239)
p.AtServer()
}
}
{
p.SetState(242)
p.ServiceApi()
}
return localctx
}
// IAtServerContext is an interface to support dynamic dispatch.
type IAtServerContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsAtServerContext differentiates from other interfaces.
IsAtServerContext()
}

View File

@@ -10,276 +10,6 @@ import (
// The apiparser_parser.go file was split into multiple files because it // The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation. // was too large and caused a possible memory overflow during goctl installation.
// IArrayTypeContext is an interface to support dynamic dispatch.
type IArrayTypeContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetLbrack returns the lbrack token.
GetLbrack() antlr.Token
// GetRbrack returns the rbrack token.
GetRbrack() antlr.Token
// SetLbrack sets the lbrack token.
SetLbrack(antlr.Token)
// SetRbrack sets the rbrack token.
SetRbrack(antlr.Token)
// IsArrayTypeContext differentiates from other interfaces.
IsArrayTypeContext()
}
type ArrayTypeContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
lbrack antlr.Token
rbrack antlr.Token
}
func NewEmptyArrayTypeContext() *ArrayTypeContext {
p := new(ArrayTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_arrayType
return p
}
func (*ArrayTypeContext) IsArrayTypeContext() {}
func NewArrayTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ArrayTypeContext {
p := new(ArrayTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_arrayType
return p
}
func (s *ArrayTypeContext) GetParser() antlr.Parser { return s.parser }
func (s *ArrayTypeContext) GetLbrack() antlr.Token { return s.lbrack }
func (s *ArrayTypeContext) GetRbrack() antlr.Token { return s.rbrack }
func (s *ArrayTypeContext) SetLbrack(v antlr.Token) { s.lbrack = v }
func (s *ArrayTypeContext) SetRbrack(v antlr.Token) { s.rbrack = v }
func (s *ArrayTypeContext) DataType() IDataTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IDataTypeContext)
}
func (s *ArrayTypeContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ArrayTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ArrayTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitArrayType(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ArrayType() (localctx IArrayTypeContext) {
localctx = NewArrayTypeContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 48, ApiParserParserRULE_arrayType)
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
{
p.SetState(233)
_m := p.Match(ApiParserParserT__7)
localctx.(*ArrayTypeContext).lbrack = _m
}
{
p.SetState(234)
_m := p.Match(ApiParserParserT__8)
localctx.(*ArrayTypeContext).rbrack = _m
}
{
p.SetState(235)
p.DataType()
}
return localctx
}
// IServiceSpecContext is an interface to support dynamic dispatch.
type IServiceSpecContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsServiceSpecContext differentiates from other interfaces.
IsServiceSpecContext()
}
type ServiceSpecContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
}
func NewEmptyServiceSpecContext() *ServiceSpecContext {
p := new(ServiceSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_serviceSpec
return p
}
func (*ServiceSpecContext) IsServiceSpecContext() {}
func NewServiceSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceSpecContext {
p := new(ServiceSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_serviceSpec
return p
}
func (s *ServiceSpecContext) GetParser() antlr.Parser { return s.parser }
func (s *ServiceSpecContext) ServiceApi() IServiceApiContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceApiContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IServiceApiContext)
}
func (s *ServiceSpecContext) AtServer() IAtServerContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IAtServerContext)
}
func (s *ServiceSpecContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ServiceSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ServiceSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitServiceSpec(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ServiceSpec() (localctx IServiceSpecContext) {
localctx = NewServiceSpecContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 50, ApiParserParserRULE_serviceSpec)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
p.SetState(238)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserATSERVER {
{
p.SetState(237)
p.AtServer()
}
}
{
p.SetState(240)
p.ServiceApi()
}
return localctx
}
// IAtServerContext is an interface to support dynamic dispatch.
type IAtServerContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsAtServerContext differentiates from other interfaces.
IsAtServerContext()
}
type AtServerContext struct { type AtServerContext struct {
*antlr.BaseParserRuleContext *antlr.BaseParserRuleContext
parser antlr.Parser parser antlr.Parser
@@ -288,7 +18,7 @@ type AtServerContext struct {
} }
func NewEmptyAtServerContext() *AtServerContext { func NewEmptyAtServerContext() *AtServerContext {
p := new(AtServerContext) var p = new(AtServerContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_atServer p.RuleIndex = ApiParserParserRULE_atServer
return p return p
@@ -297,7 +27,7 @@ func NewEmptyAtServerContext() *AtServerContext {
func (*AtServerContext) IsAtServerContext() {} func (*AtServerContext) IsAtServerContext() {}
func NewAtServerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtServerContext { func NewAtServerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtServerContext {
p := new(AtServerContext) var p = new(AtServerContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -322,8 +52,8 @@ func (s *AtServerContext) ATSERVER() antlr.TerminalNode {
} }
func (s *AtServerContext) AllKvLit() []IKvLitContext { func (s *AtServerContext) AllKvLit() []IKvLitContext {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem()) var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem())
tst := make([]IKvLitContext, len(ts)) var tst = make([]IKvLitContext, len(ts))
for i, t := range ts { for i, t := range ts {
if t != nil { if t != nil {
@@ -335,7 +65,7 @@ func (s *AtServerContext) AllKvLit() []IKvLitContext {
} }
func (s *AtServerContext) KvLit(i int) IKvLitContext { func (s *AtServerContext) KvLit(i int) IKvLitContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i) var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
if t == nil { if t == nil {
return nil return nil
@@ -385,33 +115,34 @@ func (p *ApiParserParser) AtServer() (localctx IAtServerContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(242) p.SetState(244)
p.Match(ApiParserParserATSERVER) p.Match(ApiParserParserATSERVER)
} }
{ {
p.SetState(243) p.SetState(245)
_m := p.Match(ApiParserParserT__1) var _m = p.Match(ApiParserParserT__1)
localctx.(*AtServerContext).lp = _m localctx.(*AtServerContext).lp = _m
} }
p.SetState(245) p.SetState(247)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
for ok := true; ok; ok = _la == ApiParserParserID { for ok := true; ok; ok = _la == ApiParserParserID {
{ {
p.SetState(244) p.SetState(246)
p.KvLit() p.KvLit()
} }
p.SetState(247) p.SetState(249)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
} }
{ {
p.SetState(249) p.SetState(251)
_m := p.Match(ApiParserParserT__2) var _m = p.Match(ApiParserParserT__2)
localctx.(*AtServerContext).rp = _m localctx.(*AtServerContext).rp = _m
} }
@@ -457,7 +188,7 @@ type ServiceApiContext struct {
} }
func NewEmptyServiceApiContext() *ServiceApiContext { func NewEmptyServiceApiContext() *ServiceApiContext {
p := new(ServiceApiContext) var p = new(ServiceApiContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_serviceApi p.RuleIndex = ApiParserParserRULE_serviceApi
return p return p
@@ -466,7 +197,7 @@ func NewEmptyServiceApiContext() *ServiceApiContext {
func (*ServiceApiContext) IsServiceApiContext() {} func (*ServiceApiContext) IsServiceApiContext() {}
func NewServiceApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceApiContext { func NewServiceApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceApiContext {
p := new(ServiceApiContext) var p = new(ServiceApiContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -491,7 +222,7 @@ func (s *ServiceApiContext) SetLbrace(v antlr.Token) { s.lbrace = v }
func (s *ServiceApiContext) SetRbrace(v antlr.Token) { s.rbrace = v } func (s *ServiceApiContext) SetRbrace(v antlr.Token) { s.rbrace = v }
func (s *ServiceApiContext) ServiceName() IServiceNameContext { func (s *ServiceApiContext) ServiceName() IServiceNameContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceNameContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceNameContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -505,8 +236,8 @@ func (s *ServiceApiContext) ID() antlr.TerminalNode {
} }
func (s *ServiceApiContext) AllServiceRoute() []IServiceRouteContext { func (s *ServiceApiContext) AllServiceRoute() []IServiceRouteContext {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem()) var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem())
tst := make([]IServiceRouteContext, len(ts)) var tst = make([]IServiceRouteContext, len(ts))
for i, t := range ts { for i, t := range ts {
if t != nil { if t != nil {
@@ -518,7 +249,7 @@ func (s *ServiceApiContext) AllServiceRoute() []IServiceRouteContext {
} }
func (s *ServiceApiContext) ServiceRoute(i int) IServiceRouteContext { func (s *ServiceApiContext) ServiceRoute(i int) IServiceRouteContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem(), i) var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem(), i)
if t == nil { if t == nil {
return nil return nil
@@ -569,44 +300,396 @@ func (p *ApiParserParser) ServiceApi() (localctx IServiceApiContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
match(p, "service") match(p, "service")
{ {
p.SetState(252) p.SetState(254)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*ServiceApiContext).serviceToken = _m localctx.(*ServiceApiContext).serviceToken = _m
} }
{ {
p.SetState(253) p.SetState(255)
p.ServiceName() p.ServiceName()
} }
{ {
p.SetState(254) p.SetState(256)
_m := p.Match(ApiParserParserT__3) var _m = p.Match(ApiParserParserT__3)
localctx.(*ServiceApiContext).lbrace = _m localctx.(*ServiceApiContext).lbrace = _m
} }
p.SetState(258) p.SetState(260)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
for ((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<ApiParserParserATDOC)|(1<<ApiParserParserATHANDLER)|(1<<ApiParserParserATSERVER))) != 0 { for ((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<ApiParserParserATDOC)|(1<<ApiParserParserATHANDLER)|(1<<ApiParserParserATSERVER))) != 0 {
{ {
p.SetState(255) p.SetState(257)
p.ServiceRoute() p.ServiceRoute()
} }
p.SetState(260) p.SetState(262)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
} }
{ {
p.SetState(261) p.SetState(263)
_m := p.Match(ApiParserParserT__4) var _m = p.Match(ApiParserParserT__4)
localctx.(*ServiceApiContext).rbrace = _m localctx.(*ServiceApiContext).rbrace = _m
} }
return localctx return localctx
} }
// IServiceRouteContext is an interface to support dynamic dispatch.
type IServiceRouteContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsServiceRouteContext differentiates from other interfaces.
IsServiceRouteContext()
}
type ServiceRouteContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
}
func NewEmptyServiceRouteContext() *ServiceRouteContext {
var p = new(ServiceRouteContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_serviceRoute
return p
}
func (*ServiceRouteContext) IsServiceRouteContext() {}
func NewServiceRouteContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceRouteContext {
var p = new(ServiceRouteContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_serviceRoute
return p
}
func (s *ServiceRouteContext) GetParser() antlr.Parser { return s.parser }
func (s *ServiceRouteContext) Route() IRouteContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IRouteContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IRouteContext)
}
func (s *ServiceRouteContext) AtServer() IAtServerContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IAtServerContext)
}
func (s *ServiceRouteContext) AtHandler() IAtHandlerContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtHandlerContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IAtHandlerContext)
}
func (s *ServiceRouteContext) AtDoc() IAtDocContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtDocContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IAtDocContext)
}
func (s *ServiceRouteContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ServiceRouteContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ServiceRouteContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitServiceRoute(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ServiceRoute() (localctx IServiceRouteContext) {
localctx = NewServiceRouteContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 56, ApiParserParserRULE_serviceRoute)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
p.SetState(266)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserATDOC {
{
p.SetState(265)
p.AtDoc()
}
}
p.SetState(270)
p.GetErrorHandler().Sync(p)
switch p.GetTokenStream().LA(1) {
case ApiParserParserATSERVER:
{
p.SetState(268)
p.AtServer()
}
case ApiParserParserATHANDLER:
{
p.SetState(269)
p.AtHandler()
}
default:
panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
}
{
p.SetState(272)
p.Route()
}
return localctx
}
// IAtDocContext is an interface to support dynamic dispatch.
type IAtDocContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsAtDocContext differentiates from other interfaces.
IsAtDocContext()
}
type AtDocContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
lp antlr.Token
rp antlr.Token
}
func NewEmptyAtDocContext() *AtDocContext {
var p = new(AtDocContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_atDoc
return p
}
func (*AtDocContext) IsAtDocContext() {}
func NewAtDocContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtDocContext {
var p = new(AtDocContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_atDoc
return p
}
func (s *AtDocContext) GetParser() antlr.Parser { return s.parser }
func (s *AtDocContext) GetLp() antlr.Token { return s.lp }
func (s *AtDocContext) GetRp() antlr.Token { return s.rp }
func (s *AtDocContext) SetLp(v antlr.Token) { s.lp = v }
func (s *AtDocContext) SetRp(v antlr.Token) { s.rp = v }
func (s *AtDocContext) ATDOC() antlr.TerminalNode {
return s.GetToken(ApiParserParserATDOC, 0)
}
func (s *AtDocContext) STRING() antlr.TerminalNode {
return s.GetToken(ApiParserParserSTRING, 0)
}
func (s *AtDocContext) AllKvLit() []IKvLitContext {
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem())
var tst = make([]IKvLitContext, len(ts))
for i, t := range ts {
if t != nil {
tst[i] = t.(IKvLitContext)
}
}
return tst
}
func (s *AtDocContext) KvLit(i int) IKvLitContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
if t == nil {
return nil
}
return t.(IKvLitContext)
}
func (s *AtDocContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *AtDocContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *AtDocContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitAtDoc(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) AtDoc() (localctx IAtDocContext) {
localctx = NewAtDocContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 58, ApiParserParserRULE_atDoc)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
{
p.SetState(274)
p.Match(ApiParserParserATDOC)
}
p.SetState(276)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__1 {
{
p.SetState(275)
var _m = p.Match(ApiParserParserT__1)
localctx.(*AtDocContext).lp = _m
}
}
p.SetState(284)
p.GetErrorHandler().Sync(p)
switch p.GetTokenStream().LA(1) {
case ApiParserParserID:
p.SetState(279)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
for ok := true; ok; ok = _la == ApiParserParserID {
{
p.SetState(278)
p.KvLit()
}
p.SetState(281)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
}
case ApiParserParserSTRING:
{
p.SetState(283)
p.Match(ApiParserParserSTRING)
}
default:
panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
}
p.SetState(287)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__2 {
{
p.SetState(286)
var _m = p.Match(ApiParserParserT__2)
localctx.(*AtDocContext).rp = _m
}
}
return localctx
}

View File

@@ -10,354 +10,6 @@ import (
// The apiparser_parser.go file was split into multiple files because it // The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation. // was too large and caused a possible memory overflow during goctl installation.
// IServiceRouteContext is an interface to support dynamic dispatch.
type IServiceRouteContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsServiceRouteContext differentiates from other interfaces.
IsServiceRouteContext()
}
type ServiceRouteContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
}
func NewEmptyServiceRouteContext() *ServiceRouteContext {
p := new(ServiceRouteContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_serviceRoute
return p
}
func (*ServiceRouteContext) IsServiceRouteContext() {}
func NewServiceRouteContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceRouteContext {
p := new(ServiceRouteContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_serviceRoute
return p
}
func (s *ServiceRouteContext) GetParser() antlr.Parser { return s.parser }
func (s *ServiceRouteContext) Route() IRouteContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IRouteContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IRouteContext)
}
func (s *ServiceRouteContext) AtServer() IAtServerContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IAtServerContext)
}
func (s *ServiceRouteContext) AtHandler() IAtHandlerContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IAtHandlerContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IAtHandlerContext)
}
func (s *ServiceRouteContext) AtDoc() IAtDocContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IAtDocContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IAtDocContext)
}
func (s *ServiceRouteContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ServiceRouteContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ServiceRouteContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitServiceRoute(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ServiceRoute() (localctx IServiceRouteContext) {
localctx = NewServiceRouteContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 56, ApiParserParserRULE_serviceRoute)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
p.SetState(264)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserATDOC {
{
p.SetState(263)
p.AtDoc()
}
}
p.SetState(268)
p.GetErrorHandler().Sync(p)
switch p.GetTokenStream().LA(1) {
case ApiParserParserATSERVER:
{
p.SetState(266)
p.AtServer()
}
case ApiParserParserATHANDLER:
{
p.SetState(267)
p.AtHandler()
}
default:
panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
}
{
p.SetState(270)
p.Route()
}
return localctx
}
// IAtDocContext is an interface to support dynamic dispatch.
type IAtDocContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsAtDocContext differentiates from other interfaces.
IsAtDocContext()
}
type AtDocContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
lp antlr.Token
rp antlr.Token
}
func NewEmptyAtDocContext() *AtDocContext {
p := new(AtDocContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_atDoc
return p
}
func (*AtDocContext) IsAtDocContext() {}
func NewAtDocContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtDocContext {
p := new(AtDocContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_atDoc
return p
}
func (s *AtDocContext) GetParser() antlr.Parser { return s.parser }
func (s *AtDocContext) GetLp() antlr.Token { return s.lp }
func (s *AtDocContext) GetRp() antlr.Token { return s.rp }
func (s *AtDocContext) SetLp(v antlr.Token) { s.lp = v }
func (s *AtDocContext) SetRp(v antlr.Token) { s.rp = v }
func (s *AtDocContext) ATDOC() antlr.TerminalNode {
return s.GetToken(ApiParserParserATDOC, 0)
}
func (s *AtDocContext) STRING() antlr.TerminalNode {
return s.GetToken(ApiParserParserSTRING, 0)
}
func (s *AtDocContext) AllKvLit() []IKvLitContext {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem())
tst := make([]IKvLitContext, len(ts))
for i, t := range ts {
if t != nil {
tst[i] = t.(IKvLitContext)
}
}
return tst
}
func (s *AtDocContext) KvLit(i int) IKvLitContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
if t == nil {
return nil
}
return t.(IKvLitContext)
}
func (s *AtDocContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *AtDocContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *AtDocContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitAtDoc(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) AtDoc() (localctx IAtDocContext) {
localctx = NewAtDocContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 58, ApiParserParserRULE_atDoc)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
{
p.SetState(272)
p.Match(ApiParserParserATDOC)
}
p.SetState(274)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__1 {
{
p.SetState(273)
_m := p.Match(ApiParserParserT__1)
localctx.(*AtDocContext).lp = _m
}
}
p.SetState(282)
p.GetErrorHandler().Sync(p)
switch p.GetTokenStream().LA(1) {
case ApiParserParserID:
p.SetState(277)
p.GetErrorHandler().Sync(p)
for ok := true; ok; ok = _la == ApiParserParserID {
{
p.SetState(276)
p.KvLit()
}
p.SetState(279)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
}
case ApiParserParserSTRING:
{
p.SetState(281)
p.Match(ApiParserParserSTRING)
}
default:
panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
}
p.SetState(285)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__2 {
{
p.SetState(284)
_m := p.Match(ApiParserParserT__2)
localctx.(*AtDocContext).rp = _m
}
}
return localctx
}
// IAtHandlerContext is an interface to support dynamic dispatch. // IAtHandlerContext is an interface to support dynamic dispatch.
type IAtHandlerContext interface { type IAtHandlerContext interface {
antlr.ParserRuleContext antlr.ParserRuleContext
@@ -375,7 +27,7 @@ type AtHandlerContext struct {
} }
func NewEmptyAtHandlerContext() *AtHandlerContext { func NewEmptyAtHandlerContext() *AtHandlerContext {
p := new(AtHandlerContext) var p = new(AtHandlerContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_atHandler p.RuleIndex = ApiParserParserRULE_atHandler
return p return p
@@ -384,7 +36,7 @@ func NewEmptyAtHandlerContext() *AtHandlerContext {
func (*AtHandlerContext) IsAtHandlerContext() {} func (*AtHandlerContext) IsAtHandlerContext() {}
func NewAtHandlerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtHandlerContext { func NewAtHandlerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtHandlerContext {
p := new(AtHandlerContext) var p = new(AtHandlerContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -444,11 +96,11 @@ func (p *ApiParserParser) AtHandler() (localctx IAtHandlerContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(287) p.SetState(289)
p.Match(ApiParserParserATHANDLER) p.Match(ApiParserParserATHANDLER)
} }
{ {
p.SetState(288) p.SetState(290)
p.Match(ApiParserParserID) p.Match(ApiParserParserID)
} }
@@ -493,7 +145,7 @@ type RouteContext struct {
} }
func NewEmptyRouteContext() *RouteContext { func NewEmptyRouteContext() *RouteContext {
p := new(RouteContext) var p = new(RouteContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_route p.RuleIndex = ApiParserParserRULE_route
return p return p
@@ -502,7 +154,7 @@ func NewEmptyRouteContext() *RouteContext {
func (*RouteContext) IsRouteContext() {} func (*RouteContext) IsRouteContext() {}
func NewRouteContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RouteContext { func NewRouteContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RouteContext {
p := new(RouteContext) var p = new(RouteContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -527,7 +179,7 @@ func (s *RouteContext) SetRequest(v IBodyContext) { s.request = v }
func (s *RouteContext) SetResponse(v IReplybodyContext) { s.response = v } func (s *RouteContext) SetResponse(v IReplybodyContext) { s.response = v }
func (s *RouteContext) Path() IPathContext { func (s *RouteContext) Path() IPathContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IPathContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IPathContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -541,7 +193,7 @@ func (s *RouteContext) ID() antlr.TerminalNode {
} }
func (s *RouteContext) Body() IBodyContext { func (s *RouteContext) Body() IBodyContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IBodyContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IBodyContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -551,7 +203,7 @@ func (s *RouteContext) Body() IBodyContext {
} }
func (s *RouteContext) Replybody() IReplybodyContext { func (s *RouteContext) Replybody() IReplybodyContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IReplybodyContext)(nil)).Elem(), 0) var t = s.GetTypedRuleContext(reflect.TypeOf((*IReplybodyContext)(nil)).Elem(), 0)
if t == nil { if t == nil {
return nil return nil
@@ -602,42 +254,410 @@ func (p *ApiParserParser) Route() (localctx IRouteContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
checkHTTPMethod(p) checkHTTPMethod(p)
{ {
p.SetState(291) p.SetState(293)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*RouteContext).httpMethod = _m localctx.(*RouteContext).httpMethod = _m
} }
{ {
p.SetState(292) p.SetState(294)
p.Path() p.Path()
} }
p.SetState(294) p.SetState(296)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__1 { if _la == ApiParserParserT__1 {
{ {
p.SetState(293) p.SetState(295)
_x := p.Body() var _x = p.Body()
localctx.(*RouteContext).request = _x localctx.(*RouteContext).request = _x
} }
} }
p.SetState(297) p.SetState(299)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__9 { if _la == ApiParserParserT__9 {
{ {
p.SetState(296) p.SetState(298)
_x := p.Replybody() var _x = p.Replybody()
localctx.(*RouteContext).response = _x localctx.(*RouteContext).response = _x
} }
} }
return localctx return localctx
} }
// IBodyContext is an interface to support dynamic dispatch.
type IBodyContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsBodyContext differentiates from other interfaces.
IsBodyContext()
}
type BodyContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
lp antlr.Token
rp antlr.Token
}
func NewEmptyBodyContext() *BodyContext {
var p = new(BodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_body
return p
}
func (*BodyContext) IsBodyContext() {}
func NewBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *BodyContext {
var p = new(BodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_body
return p
}
func (s *BodyContext) GetParser() antlr.Parser { return s.parser }
func (s *BodyContext) GetLp() antlr.Token { return s.lp }
func (s *BodyContext) GetRp() antlr.Token { return s.rp }
func (s *BodyContext) SetLp(v antlr.Token) { s.lp = v }
func (s *BodyContext) SetRp(v antlr.Token) { s.rp = v }
func (s *BodyContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *BodyContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *BodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *BodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitBody(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) Body() (localctx IBodyContext) {
localctx = NewBodyContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 64, ApiParserParserRULE_body)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
{
p.SetState(301)
var _m = p.Match(ApiParserParserT__1)
localctx.(*BodyContext).lp = _m
}
p.SetState(303)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserID {
{
p.SetState(302)
p.Match(ApiParserParserID)
}
}
{
p.SetState(305)
var _m = p.Match(ApiParserParserT__2)
localctx.(*BodyContext).rp = _m
}
return localctx
}
// IReplybodyContext is an interface to support dynamic dispatch.
type IReplybodyContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetReturnToken returns the returnToken token.
GetReturnToken() antlr.Token
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetReturnToken sets the returnToken token.
SetReturnToken(antlr.Token)
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsReplybodyContext differentiates from other interfaces.
IsReplybodyContext()
}
type ReplybodyContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
returnToken antlr.Token
lp antlr.Token
rp antlr.Token
}
func NewEmptyReplybodyContext() *ReplybodyContext {
var p = new(ReplybodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_replybody
return p
}
func (*ReplybodyContext) IsReplybodyContext() {}
func NewReplybodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ReplybodyContext {
var p = new(ReplybodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_replybody
return p
}
func (s *ReplybodyContext) GetParser() antlr.Parser { return s.parser }
func (s *ReplybodyContext) GetReturnToken() antlr.Token { return s.returnToken }
func (s *ReplybodyContext) GetLp() antlr.Token { return s.lp }
func (s *ReplybodyContext) GetRp() antlr.Token { return s.rp }
func (s *ReplybodyContext) SetReturnToken(v antlr.Token) { s.returnToken = v }
func (s *ReplybodyContext) SetLp(v antlr.Token) { s.lp = v }
func (s *ReplybodyContext) SetRp(v antlr.Token) { s.rp = v }
func (s *ReplybodyContext) DataType() IDataTypeContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IDataTypeContext)
}
func (s *ReplybodyContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ReplybodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ReplybodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitReplybody(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) Replybody() (localctx IReplybodyContext) {
localctx = NewReplybodyContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 66, ApiParserParserRULE_replybody)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
{
p.SetState(307)
var _m = p.Match(ApiParserParserT__9)
localctx.(*ReplybodyContext).returnToken = _m
}
{
p.SetState(308)
var _m = p.Match(ApiParserParserT__1)
localctx.(*ReplybodyContext).lp = _m
}
p.SetState(310)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if ((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<ApiParserParserT__5)|(1<<ApiParserParserT__6)|(1<<ApiParserParserT__7)|(1<<ApiParserParserINTERFACE)|(1<<ApiParserParserID))) != 0 {
{
p.SetState(309)
p.DataType()
}
}
{
p.SetState(312)
var _m = p.Match(ApiParserParserT__2)
localctx.(*ReplybodyContext).rp = _m
}
return localctx
}
// IKvLitContext is an interface to support dynamic dispatch.
type IKvLitContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetKey returns the key token.
GetKey() antlr.Token
// GetValue returns the value token.
GetValue() antlr.Token
// SetKey sets the key token.
SetKey(antlr.Token)
// SetValue sets the value token.
SetValue(antlr.Token)
// IsKvLitContext differentiates from other interfaces.
IsKvLitContext()
}
type KvLitContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
key antlr.Token
value antlr.Token
}
func NewEmptyKvLitContext() *KvLitContext {
var p = new(KvLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_kvLit
return p
}
func (*KvLitContext) IsKvLitContext() {}
func NewKvLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *KvLitContext {
var p = new(KvLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_kvLit
return p
}
func (s *KvLitContext) GetParser() antlr.Parser { return s.parser }
func (s *KvLitContext) GetKey() antlr.Token { return s.key }
func (s *KvLitContext) GetValue() antlr.Token { return s.value }
func (s *KvLitContext) SetKey(v antlr.Token) { s.key = v }
func (s *KvLitContext) SetValue(v antlr.Token) { s.value = v }
func (s *KvLitContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *KvLitContext) LINE_VALUE() antlr.TerminalNode {
return s.GetToken(ApiParserParserLINE_VALUE, 0)
}
func (s *KvLitContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *KvLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}

View File

@@ -1,6 +1,7 @@
package api package api
import ( import (
"fmt"
"reflect" "reflect"
"github.com/zeromicro/antlr" "github.com/zeromicro/antlr"
@@ -10,370 +11,6 @@ import (
// The apiparser_parser.go file was split into multiple files because it // The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation. // was too large and caused a possible memory overflow during goctl installation.
// IBodyContext is an interface to support dynamic dispatch.
type IBodyContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsBodyContext differentiates from other interfaces.
IsBodyContext()
}
type BodyContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
lp antlr.Token
rp antlr.Token
}
func NewEmptyBodyContext() *BodyContext {
p := new(BodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_body
return p
}
func (*BodyContext) IsBodyContext() {}
func NewBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *BodyContext {
p := new(BodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_body
return p
}
func (s *BodyContext) GetParser() antlr.Parser { return s.parser }
func (s *BodyContext) GetLp() antlr.Token { return s.lp }
func (s *BodyContext) GetRp() antlr.Token { return s.rp }
func (s *BodyContext) SetLp(v antlr.Token) { s.lp = v }
func (s *BodyContext) SetRp(v antlr.Token) { s.rp = v }
func (s *BodyContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *BodyContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *BodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *BodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitBody(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) Body() (localctx IBodyContext) {
localctx = NewBodyContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 64, ApiParserParserRULE_body)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
{
p.SetState(299)
_m := p.Match(ApiParserParserT__1)
localctx.(*BodyContext).lp = _m
}
p.SetState(301)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserID {
{
p.SetState(300)
p.Match(ApiParserParserID)
}
}
{
p.SetState(303)
_m := p.Match(ApiParserParserT__2)
localctx.(*BodyContext).rp = _m
}
return localctx
}
// IReplybodyContext is an interface to support dynamic dispatch.
type IReplybodyContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetReturnToken returns the returnToken token.
GetReturnToken() antlr.Token
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetReturnToken sets the returnToken token.
SetReturnToken(antlr.Token)
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsReplybodyContext differentiates from other interfaces.
IsReplybodyContext()
}
type ReplybodyContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
returnToken antlr.Token
lp antlr.Token
rp antlr.Token
}
func NewEmptyReplybodyContext() *ReplybodyContext {
p := new(ReplybodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_replybody
return p
}
func (*ReplybodyContext) IsReplybodyContext() {}
func NewReplybodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ReplybodyContext {
p := new(ReplybodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_replybody
return p
}
func (s *ReplybodyContext) GetParser() antlr.Parser { return s.parser }
func (s *ReplybodyContext) GetReturnToken() antlr.Token { return s.returnToken }
func (s *ReplybodyContext) GetLp() antlr.Token { return s.lp }
func (s *ReplybodyContext) GetRp() antlr.Token { return s.rp }
func (s *ReplybodyContext) SetReturnToken(v antlr.Token) { s.returnToken = v }
func (s *ReplybodyContext) SetLp(v antlr.Token) { s.lp = v }
func (s *ReplybodyContext) SetRp(v antlr.Token) { s.rp = v }
func (s *ReplybodyContext) DataType() IDataTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IDataTypeContext)
}
func (s *ReplybodyContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ReplybodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ReplybodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitReplybody(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) Replybody() (localctx IReplybodyContext) {
localctx = NewReplybodyContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 66, ApiParserParserRULE_replybody)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
{
p.SetState(305)
_m := p.Match(ApiParserParserT__9)
localctx.(*ReplybodyContext).returnToken = _m
}
{
p.SetState(306)
_m := p.Match(ApiParserParserT__1)
localctx.(*ReplybodyContext).lp = _m
}
p.SetState(308)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if ((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<ApiParserParserT__5)|(1<<ApiParserParserT__6)|(1<<ApiParserParserT__7)|(1<<ApiParserParserINTERFACE)|(1<<ApiParserParserID))) != 0 {
{
p.SetState(307)
p.DataType()
}
}
{
p.SetState(310)
_m := p.Match(ApiParserParserT__2)
localctx.(*ReplybodyContext).rp = _m
}
return localctx
}
// IKvLitContext is an interface to support dynamic dispatch.
type IKvLitContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetKey returns the key token.
GetKey() antlr.Token
// GetValue returns the value token.
GetValue() antlr.Token
// SetKey sets the key token.
SetKey(antlr.Token)
// SetValue sets the value token.
SetValue(antlr.Token)
// IsKvLitContext differentiates from other interfaces.
IsKvLitContext()
}
type KvLitContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
key antlr.Token
value antlr.Token
}
func NewEmptyKvLitContext() *KvLitContext {
p := new(KvLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_kvLit
return p
}
func (*KvLitContext) IsKvLitContext() {}
func NewKvLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *KvLitContext {
p := new(KvLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_kvLit
return p
}
func (s *KvLitContext) GetParser() antlr.Parser { return s.parser }
func (s *KvLitContext) GetKey() antlr.Token { return s.key }
func (s *KvLitContext) GetValue() antlr.Token { return s.value }
func (s *KvLitContext) SetKey(v antlr.Token) { s.key = v }
func (s *KvLitContext) SetValue(v antlr.Token) { s.value = v }
func (s *KvLitContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *KvLitContext) LINE_VALUE() antlr.TerminalNode {
return s.GetToken(ApiParserParserLINE_VALUE, 0)
}
func (s *KvLitContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *KvLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *KvLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { func (s *KvLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) { switch t := visitor.(type) {
case ApiParserVisitor: case ApiParserVisitor:
@@ -406,17 +43,17 @@ func (p *ApiParserParser) KvLit() (localctx IKvLitContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(312) p.SetState(314)
_m := p.Match(ApiParserParserID) var _m = p.Match(ApiParserParserID)
localctx.(*KvLitContext).key = _m localctx.(*KvLitContext).key = _m
} }
checkKeyValue(p) checkKeyValue(p)
{ {
p.SetState(314) p.SetState(316)
_m := p.Match(ApiParserParserLINE_VALUE) var _m = p.Match(ApiParserParserLINE_VALUE)
localctx.(*KvLitContext).value = _m localctx.(*KvLitContext).value = _m
} }
@@ -441,7 +78,7 @@ type ServiceNameContext struct {
} }
func NewEmptyServiceNameContext() *ServiceNameContext { func NewEmptyServiceNameContext() *ServiceNameContext {
p := new(ServiceNameContext) var p = new(ServiceNameContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_serviceName p.RuleIndex = ApiParserParserRULE_serviceName
return p return p
@@ -450,7 +87,7 @@ func NewEmptyServiceNameContext() *ServiceNameContext {
func (*ServiceNameContext) IsServiceNameContext() {} func (*ServiceNameContext) IsServiceNameContext() {}
func NewServiceNameContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceNameContext { func NewServiceNameContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceNameContext {
p := new(ServiceNameContext) var p = new(ServiceNameContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -510,26 +147,28 @@ func (p *ApiParserParser) ServiceName() (localctx IServiceNameContext) {
}() }()
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
p.SetState(320) p.SetState(322)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
for ok := true; ok; ok = _la == ApiParserParserID { for ok := true; ok; ok = _la == ApiParserParserID {
{ {
p.SetState(316) p.SetState(318)
p.Match(ApiParserParserID) p.Match(ApiParserParserID)
} }
p.SetState(318) p.SetState(320)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__10 { if _la == ApiParserParserT__10 {
{ {
p.SetState(317) p.SetState(319)
p.Match(ApiParserParserT__10) p.Match(ApiParserParserT__10)
} }
} }
p.SetState(322) p.SetState(324)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
} }
@@ -554,7 +193,7 @@ type PathContext struct {
} }
func NewEmptyPathContext() *PathContext { func NewEmptyPathContext() *PathContext {
p := new(PathContext) var p = new(PathContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_path p.RuleIndex = ApiParserParserRULE_path
return p return p
@@ -563,7 +202,7 @@ func NewEmptyPathContext() *PathContext {
func (*PathContext) IsPathContext() {} func (*PathContext) IsPathContext() {}
func NewPathContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PathContext { func NewPathContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PathContext {
p := new(PathContext) var p = new(PathContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
@@ -575,12 +214,27 @@ func NewPathContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokin
func (s *PathContext) GetParser() antlr.Parser { return s.parser } func (s *PathContext) GetParser() antlr.Parser { return s.parser }
func (s *PathContext) AllID() []antlr.TerminalNode { func (s *PathContext) AllPathItem() []IPathItemContext {
return s.GetTokens(ApiParserParserID) var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IPathItemContext)(nil)).Elem())
var tst = make([]IPathItemContext, len(ts))
for i, t := range ts {
if t != nil {
tst[i] = t.(IPathItemContext)
}
}
return tst
} }
func (s *PathContext) ID(i int) antlr.TerminalNode { func (s *PathContext) PathItem(i int) IPathItemContext {
return s.GetToken(ApiParserParserID, i) var t = s.GetTypedRuleContext(reflect.TypeOf((*IPathItemContext)(nil)).Elem(), i)
if t == nil {
return nil
}
return t.(IPathItemContext)
} }
func (s *PathContext) GetRuleContext() antlr.RuleContext { func (s *PathContext) GetRuleContext() antlr.RuleContext {
@@ -622,70 +276,71 @@ func (p *ApiParserParser) Path() (localctx IPathContext) {
} }
}() }()
p.SetState(344) p.SetState(346)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 38, p.GetParserRuleContext()) { switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 38, p.GetParserRuleContext()) {
case 1: case 1:
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
p.SetState(339) p.SetState(341)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
for ok := true; ok; ok = _la == ApiParserParserT__11 || _la == ApiParserParserT__12 { for ok := true; ok; ok = _la == ApiParserParserT__11 || _la == ApiParserParserT__12 {
p.SetState(339) p.SetState(341)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
switch p.GetTokenStream().LA(1) { switch p.GetTokenStream().LA(1) {
case ApiParserParserT__11: case ApiParserParserT__11:
{ {
p.SetState(324) p.SetState(326)
p.Match(ApiParserParserT__11) p.Match(ApiParserParserT__11)
} }
{ {
p.SetState(325) p.SetState(327)
p.Match(ApiParserParserID) p.PathItem()
} }
p.SetState(330) p.SetState(332)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
for _la == ApiParserParserT__10 { for _la == ApiParserParserT__10 {
{ {
p.SetState(326) p.SetState(328)
p.Match(ApiParserParserT__10) p.Match(ApiParserParserT__10)
} }
{ {
p.SetState(327) p.SetState(329)
p.Match(ApiParserParserID) p.PathItem()
} }
p.SetState(332) p.SetState(334)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
} }
case ApiParserParserT__12: case ApiParserParserT__12:
{ {
p.SetState(333) p.SetState(335)
p.Match(ApiParserParserT__12) p.Match(ApiParserParserT__12)
} }
{ {
p.SetState(334) p.SetState(336)
p.Match(ApiParserParserID) p.PathItem()
} }
p.SetState(337) p.SetState(339)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__10 { if _la == ApiParserParserT__10 {
{ {
p.SetState(335) p.SetState(337)
p.Match(ApiParserParserT__10) p.Match(ApiParserParserT__10)
} }
{ {
p.SetState(336) p.SetState(338)
p.Match(ApiParserParserID) p.PathItem()
} }
} }
@@ -694,7 +349,7 @@ func (p *ApiParserParser) Path() (localctx IPathContext) {
panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
} }
p.SetState(341) p.SetState(343)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
} }
@@ -702,7 +357,7 @@ func (p *ApiParserParser) Path() (localctx IPathContext) {
case 2: case 2:
p.EnterOuterAlt(localctx, 2) p.EnterOuterAlt(localctx, 2)
{ {
p.SetState(343) p.SetState(345)
p.Match(ApiParserParserT__11) p.Match(ApiParserParserT__11)
} }
@@ -710,3 +365,146 @@ func (p *ApiParserParser) Path() (localctx IPathContext) {
return localctx return localctx
} }
// IPathItemContext is an interface to support dynamic dispatch.
type IPathItemContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsPathItemContext differentiates from other interfaces.
IsPathItemContext()
}
type PathItemContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
}
func NewEmptyPathItemContext() *PathItemContext {
var p = new(PathItemContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_pathItem
return p
}
func (*PathItemContext) IsPathItemContext() {}
func NewPathItemContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PathItemContext {
var p = new(PathItemContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_pathItem
return p
}
func (s *PathItemContext) GetParser() antlr.Parser { return s.parser }
func (s *PathItemContext) AllID() []antlr.TerminalNode {
return s.GetTokens(ApiParserParserID)
}
func (s *PathItemContext) ID(i int) antlr.TerminalNode {
return s.GetToken(ApiParserParserID, i)
}
func (s *PathItemContext) AllLetterOrDigit() []antlr.TerminalNode {
return s.GetTokens(ApiParserParserLetterOrDigit)
}
func (s *PathItemContext) LetterOrDigit(i int) antlr.TerminalNode {
return s.GetToken(ApiParserParserLetterOrDigit, i)
}
func (s *PathItemContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *PathItemContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *PathItemContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitPathItem(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) PathItem() (localctx IPathItemContext) {
localctx = NewPathItemContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 74, ApiParserParserRULE_pathItem)
var _la int
defer func() {
p.ExitRule()
}()
defer func() {
if err := recover(); err != nil {
if v, ok := err.(antlr.RecognitionException); ok {
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
} else {
panic(err)
}
}
}()
p.EnterOuterAlt(localctx, 1)
p.SetState(349)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
for ok := true; ok; ok = _la == ApiParserParserID || _la == ApiParserParserLetterOrDigit {
{
p.SetState(348)
_la = p.GetTokenStream().LA(1)
if !(_la == ApiParserParserID || _la == ApiParserParserLetterOrDigit) {
p.GetErrorHandler().RecoverInline(p)
} else {
p.GetErrorHandler().ReportMatch(p)
p.Consume()
}
}
p.SetState(351)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
}
return localctx
}
func (p *ApiParserParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool {
switch ruleIndex {
case 18:
var t *FieldContext = nil
if localctx != nil {
t = localctx.(*FieldContext)
}
return p.Field_Sempred(t, predIndex)
default:
panic("No predicate with index: " + fmt.Sprint(ruleIndex))
}
}
func (p *ApiParserParser) Field_Sempred(localctx antlr.RuleContext, predIndex int) bool {
switch predIndex {
case 0:
return isNormal(p)
default:
panic("No predicate with index: " + fmt.Sprint(predIndex))
}
}

View File

@@ -1,35 +0,0 @@
package api
import (
"fmt"
"github.com/zeromicro/antlr"
)
// Part 9
// The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation.
func (p *ApiParserParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool {
switch ruleIndex {
case 18:
var t *FieldContext = nil
if localctx != nil {
t = localctx.(*FieldContext)
}
return p.Field_Sempred(t, predIndex)
default:
panic("No predicate with index: " + fmt.Sprint(ruleIndex))
}
}
func (p *ApiParserParser) Field_Sempred(localctx antlr.RuleContext, predIndex int) bool {
switch predIndex {
case 0:
return isNormal(p)
default:
panic("No predicate with index: " + fmt.Sprint(predIndex))
}
}

View File

@@ -1,119 +1,123 @@
package api // ApiParser // Code generated from C:/Users/keson/GolandProjects/go-zero/tools/goctl/api/parser/g4\ApiParser.g4 by ANTLR 4.9. DO NOT EDIT.
package api // ApiParser
import "github.com/zeromicro/antlr" import "github.com/zeromicro/antlr"
// ApiParserVisitor is a complete Visitor for a parse tree produced by ApiParserParser. // A complete Visitor for a parse tree produced by ApiParserParser.
type ApiParserVisitor interface { type ApiParserVisitor interface {
antlr.ParseTreeVisitor antlr.ParseTreeVisitor
// VisitApi is a parse tree produced by ApiParserParser#api. // Visit a parse tree produced by ApiParserParser#api.
VisitApi(ctx *ApiContext) interface{} VisitApi(ctx *ApiContext) interface{}
// VisitSpec is a parse tree produced by ApiParserParser#spec. // Visit a parse tree produced by ApiParserParser#spec.
VisitSpec(ctx *SpecContext) interface{} VisitSpec(ctx *SpecContext) interface{}
// VisitSyntaxLit is a parse tree produced by ApiParserParser#syntaxLit. // Visit a parse tree produced by ApiParserParser#syntaxLit.
VisitSyntaxLit(ctx *SyntaxLitContext) interface{} VisitSyntaxLit(ctx *SyntaxLitContext) interface{}
// VisitImportSpec is a parse tree produced by ApiParserParser#importSpec. // Visit a parse tree produced by ApiParserParser#importSpec.
VisitImportSpec(ctx *ImportSpecContext) interface{} VisitImportSpec(ctx *ImportSpecContext) interface{}
// VisitImportLit is a parse tree produced by ApiParserParser#importLit. // Visit a parse tree produced by ApiParserParser#importLit.
VisitImportLit(ctx *ImportLitContext) interface{} VisitImportLit(ctx *ImportLitContext) interface{}
// VisitImportBlock is a parse tree produced by ApiParserParser#importBlock. // Visit a parse tree produced by ApiParserParser#importBlock.
VisitImportBlock(ctx *ImportBlockContext) interface{} VisitImportBlock(ctx *ImportBlockContext) interface{}
// VisitImportBlockValue is a parse tree produced by ApiParserParser#importBlockValue. // Visit a parse tree produced by ApiParserParser#importBlockValue.
VisitImportBlockValue(ctx *ImportBlockValueContext) interface{} VisitImportBlockValue(ctx *ImportBlockValueContext) interface{}
// VisitImportValue is a parse tree produced by ApiParserParser#importValue. // Visit a parse tree produced by ApiParserParser#importValue.
VisitImportValue(ctx *ImportValueContext) interface{} VisitImportValue(ctx *ImportValueContext) interface{}
// VisitInfoSpec is a parse tree produced by ApiParserParser#infoSpec. // Visit a parse tree produced by ApiParserParser#infoSpec.
VisitInfoSpec(ctx *InfoSpecContext) interface{} VisitInfoSpec(ctx *InfoSpecContext) interface{}
// VisitTypeSpec is a parse tree produced by ApiParserParser#typeSpec. // Visit a parse tree produced by ApiParserParser#typeSpec.
VisitTypeSpec(ctx *TypeSpecContext) interface{} VisitTypeSpec(ctx *TypeSpecContext) interface{}
// VisitTypeLit is a parse tree produced by ApiParserParser#typeLit. // Visit a parse tree produced by ApiParserParser#typeLit.
VisitTypeLit(ctx *TypeLitContext) interface{} VisitTypeLit(ctx *TypeLitContext) interface{}
// VisitTypeBlock is a parse tree produced by ApiParserParser#typeBlock. // Visit a parse tree produced by ApiParserParser#typeBlock.
VisitTypeBlock(ctx *TypeBlockContext) interface{} VisitTypeBlock(ctx *TypeBlockContext) interface{}
// VisitTypeLitBody is a parse tree produced by ApiParserParser#typeLitBody. // Visit a parse tree produced by ApiParserParser#typeLitBody.
VisitTypeLitBody(ctx *TypeLitBodyContext) interface{} VisitTypeLitBody(ctx *TypeLitBodyContext) interface{}
// VisitTypeBlockBody is a parse tree produced by ApiParserParser#typeBlockBody. // Visit a parse tree produced by ApiParserParser#typeBlockBody.
VisitTypeBlockBody(ctx *TypeBlockBodyContext) interface{} VisitTypeBlockBody(ctx *TypeBlockBodyContext) interface{}
// VisitTypeStruct is a parse tree produced by ApiParserParser#typeStruct. // Visit a parse tree produced by ApiParserParser#typeStruct.
VisitTypeStruct(ctx *TypeStructContext) interface{} VisitTypeStruct(ctx *TypeStructContext) interface{}
// VisitTypeAlias is a parse tree produced by ApiParserParser#typeAlias. // Visit a parse tree produced by ApiParserParser#typeAlias.
VisitTypeAlias(ctx *TypeAliasContext) interface{} VisitTypeAlias(ctx *TypeAliasContext) interface{}
// VisitTypeBlockStruct is a parse tree produced by ApiParserParser#typeBlockStruct. // Visit a parse tree produced by ApiParserParser#typeBlockStruct.
VisitTypeBlockStruct(ctx *TypeBlockStructContext) interface{} VisitTypeBlockStruct(ctx *TypeBlockStructContext) interface{}
// VisitTypeBlockAlias is a parse tree produced by ApiParserParser#typeBlockAlias. // Visit a parse tree produced by ApiParserParser#typeBlockAlias.
VisitTypeBlockAlias(ctx *TypeBlockAliasContext) interface{} VisitTypeBlockAlias(ctx *TypeBlockAliasContext) interface{}
// VisitField is a parse tree produced by ApiParserParser#field. // Visit a parse tree produced by ApiParserParser#field.
VisitField(ctx *FieldContext) interface{} VisitField(ctx *FieldContext) interface{}
// VisitNormalField is a parse tree produced by ApiParserParser#normalField. // Visit a parse tree produced by ApiParserParser#normalField.
VisitNormalField(ctx *NormalFieldContext) interface{} VisitNormalField(ctx *NormalFieldContext) interface{}
// VisitAnonymousFiled is a parse tree produced by ApiParserParser#anonymousFiled. // Visit a parse tree produced by ApiParserParser#anonymousFiled.
VisitAnonymousFiled(ctx *AnonymousFiledContext) interface{} VisitAnonymousFiled(ctx *AnonymousFiledContext) interface{}
// VisitDataType is a parse tree produced by ApiParserParser#dataType. // Visit a parse tree produced by ApiParserParser#dataType.
VisitDataType(ctx *DataTypeContext) interface{} VisitDataType(ctx *DataTypeContext) interface{}
// VisitPointerType is a parse tree produced by ApiParserParser#pointerType. // Visit a parse tree produced by ApiParserParser#pointerType.
VisitPointerType(ctx *PointerTypeContext) interface{} VisitPointerType(ctx *PointerTypeContext) interface{}
// VisitMapType is a parse tree produced by ApiParserParser#mapType. // Visit a parse tree produced by ApiParserParser#mapType.
VisitMapType(ctx *MapTypeContext) interface{} VisitMapType(ctx *MapTypeContext) interface{}
// VisitArrayType is a parse tree produced by ApiParserParser#arrayType. // Visit a parse tree produced by ApiParserParser#arrayType.
VisitArrayType(ctx *ArrayTypeContext) interface{} VisitArrayType(ctx *ArrayTypeContext) interface{}
// VisitServiceSpec is a parse tree produced by ApiParserParser#serviceSpec. // Visit a parse tree produced by ApiParserParser#serviceSpec.
VisitServiceSpec(ctx *ServiceSpecContext) interface{} VisitServiceSpec(ctx *ServiceSpecContext) interface{}
// VisitAtServer is a parse tree produced by ApiParserParser#atServer. // Visit a parse tree produced by ApiParserParser#atServer.
VisitAtServer(ctx *AtServerContext) interface{} VisitAtServer(ctx *AtServerContext) interface{}
// VisitServiceApi is a parse tree produced by ApiParserParser#serviceApi. // Visit a parse tree produced by ApiParserParser#serviceApi.
VisitServiceApi(ctx *ServiceApiContext) interface{} VisitServiceApi(ctx *ServiceApiContext) interface{}
// VisitServiceRoute is a parse tree produced by ApiParserParser#serviceRoute. // Visit a parse tree produced by ApiParserParser#serviceRoute.
VisitServiceRoute(ctx *ServiceRouteContext) interface{} VisitServiceRoute(ctx *ServiceRouteContext) interface{}
// VisitAtDoc is a parse tree produced by ApiParserParser#atDoc. // Visit a parse tree produced by ApiParserParser#atDoc.
VisitAtDoc(ctx *AtDocContext) interface{} VisitAtDoc(ctx *AtDocContext) interface{}
// VisitAtHandler is a parse tree produced by ApiParserParser#atHandler. // Visit a parse tree produced by ApiParserParser#atHandler.
VisitAtHandler(ctx *AtHandlerContext) interface{} VisitAtHandler(ctx *AtHandlerContext) interface{}
// VisitRoute is a parse tree produced by ApiParserParser#route. // Visit a parse tree produced by ApiParserParser#route.
VisitRoute(ctx *RouteContext) interface{} VisitRoute(ctx *RouteContext) interface{}
// VisitBody is a parse tree produced by ApiParserParser#body. // Visit a parse tree produced by ApiParserParser#body.
VisitBody(ctx *BodyContext) interface{} VisitBody(ctx *BodyContext) interface{}
// VisitReplybody is a parse tree produced by ApiParserParser#replybody. // Visit a parse tree produced by ApiParserParser#replybody.
VisitReplybody(ctx *ReplybodyContext) interface{} VisitReplybody(ctx *ReplybodyContext) interface{}
// VisitKvLit is a parse tree produced by ApiParserParser#kvLit. // Visit a parse tree produced by ApiParserParser#kvLit.
VisitKvLit(ctx *KvLitContext) interface{} VisitKvLit(ctx *KvLitContext) interface{}
// VisitServiceName is a parse tree produced by ApiParserParser#serviceName. // Visit a parse tree produced by ApiParserParser#serviceName.
VisitServiceName(ctx *ServiceNameContext) interface{} VisitServiceName(ctx *ServiceNameContext) interface{}
// VisitPath is a parse tree produced by ApiParserParser#path. // Visit a parse tree produced by ApiParserParser#path.
VisitPath(ctx *PathContext) interface{} VisitPath(ctx *PathContext) interface{}
// Visit a parse tree produced by ApiParserParser#pathItem.
VisitPathItem(ctx *PathItemContext) interface{}
} }

View File

@@ -125,6 +125,14 @@ func TestRoute(t *testing.T) {
}, },
})) }))
v, err = parser.Accept(fn, `post /1/2a/3b/4`)
assert.Nil(t, err)
route = v.(*ast.Route)
assert.True(t, route.Equal(&ast.Route{
Method: ast.NewTextExpr("post"),
Path: ast.NewTextExpr("/1/2a/3b/4"),
}))
v, err = parser.Accept(fn, `post /foo/foo-bar/:bar`) v, err = parser.Accept(fn, `post /foo/foo-bar/:bar`)
assert.Nil(t, err) assert.Nil(t, err)
route = v.(*ast.Route) route = v.(*ast.Route)

View File

@@ -1,13 +1,16 @@
package cmd package cmd
import ( import (
_ "embed"
"fmt" "fmt"
"os" "os"
"runtime" "runtime"
"strings" "strings"
"text/template"
"github.com/logrusorgru/aurora" "github.com/logrusorgru/aurora"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/withfig/autocomplete-tools/integrations/cobra"
"github.com/zeromicro/go-zero/tools/goctl/api" "github.com/zeromicro/go-zero/tools/goctl/api"
"github.com/zeromicro/go-zero/tools/goctl/bug" "github.com/zeromicro/go-zero/tools/goctl/bug"
"github.com/zeromicro/go-zero/tools/goctl/docker" "github.com/zeromicro/go-zero/tools/goctl/docker"
@@ -29,11 +32,18 @@ const (
assign = "=" assign = "="
) )
var rootCmd = &cobra.Command{ var (
Use: "goctl", //go:embed usage.tpl
Short: "A cli tool to generate go-zero code", usageTpl string
Long: "A cli tool to generate api, zrpc, model code",
} rootCmd = &cobra.Command{
Use: "goctl",
Short: "A cli tool to generate go-zero code",
Long: "A cli tool to generate api, zrpc, model code\n\n" +
"GitHub: https://github.com/zeromicro/go-zero\n" +
"Site: https://go-zero.dev",
}
)
// Execute executes the given command // Execute executes the given command
func Execute() { func Execute() {
@@ -95,9 +105,18 @@ func isBuiltin(name string) bool {
} }
func init() { func init() {
cobra.AddTemplateFuncs(template.FuncMap{
"blue": blue,
"green": green,
"rpadx": rpadx,
"rainbow": rainbow,
})
rootCmd.Version = fmt.Sprintf( rootCmd.Version = fmt.Sprintf(
"%s %s/%s", version.BuildVersion, "%s %s/%s", version.BuildVersion,
runtime.GOOS, runtime.GOARCH) runtime.GOOS, runtime.GOARCH)
rootCmd.SetUsageTemplate(usageTpl)
rootCmd.AddCommand(api.Cmd) rootCmd.AddCommand(api.Cmd)
rootCmd.AddCommand(bug.Cmd) rootCmd.AddCommand(bug.Cmd)
rootCmd.AddCommand(docker.Cmd) rootCmd.AddCommand(docker.Cmd)
@@ -109,4 +128,5 @@ func init() {
rootCmd.AddCommand(rpc.Cmd) rootCmd.AddCommand(rpc.Cmd)
rootCmd.AddCommand(tpl.Cmd) rootCmd.AddCommand(tpl.Cmd)
rootCmd.AddCommand(upgrade.Cmd) rootCmd.AddCommand(upgrade.Cmd)
rootCmd.AddCommand(cobracompletefig.CreateCompletionSpecCommand())
} }

60
tools/goctl/cmd/usage.go Normal file
View File

@@ -0,0 +1,60 @@
package cmd
import (
"fmt"
"runtime"
"github.com/logrusorgru/aurora"
"github.com/zeromicro/go-zero/tools/goctl/vars"
)
var colorRender = []func(v interface{}) string{
func(v interface{}) string {
return aurora.BrightRed(v).String()
},
func(v interface{}) string {
return aurora.BrightGreen(v).String()
},
func(v interface{}) string {
return aurora.BrightYellow(v).String()
},
func(v interface{}) string {
return aurora.BrightBlue(v).String()
},
func(v interface{}) string {
return aurora.BrightMagenta(v).String()
},
func(v interface{}) string {
return aurora.BrightCyan(v).String()
},
}
func blue(s string) string {
if runtime.GOOS == vars.OsWindows {
return s
}
return aurora.BrightBlue(s).String()
}
func green(s string) string {
if runtime.GOOS == vars.OsWindows {
return s
}
return aurora.BrightGreen(s).String()
}
func rainbow(s string) string {
if runtime.GOOS == vars.OsWindows {
return s
}
s0 := s[0]
return colorRender[int(s0)%(len(colorRender)-1)](s)
}
// rpadx adds padding to the right of a string.
func rpadx(s string, padding int) string {
template := fmt.Sprintf("%%-%ds", padding)
return rainbow(fmt.Sprintf(template, s))
}

23
tools/goctl/cmd/usage.tpl Normal file
View File

@@ -0,0 +1,23 @@
{{blue "Usage:"}}{{if .Runnable}}
{{green .UseLine}}{{end}}{{if .HasAvailableSubCommands}}
{{green .CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
{{blue "Aliases:"}}
{{green .NameAndAliases}}{{end}}{{if .HasExample}}
{{blue "Examples:"}}
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
{{blue "Available Commands:"}}{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpadx .Name .NamePadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
{{blue "Flags:"}}
{{green .LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
{{blue "Global Flags:"}}
{{green .InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
{{blue "Additional help topics:"}}{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
Use "{{green .CommandPath}} [command] --help" for more information about a command.{{end}}

View File

@@ -3,6 +3,7 @@ package docker
import "github.com/spf13/cobra" import "github.com/spf13/cobra"
var ( var (
varExeName string
varStringGo string varStringGo string
varStringBase string varStringBase string
varIntPort int varIntPort int
@@ -21,11 +22,12 @@ var (
) )
func init() { func init() {
Cmd.Flags().StringVar(&varExeName, "exe", "", "The executable name in the built image")
Cmd.Flags().StringVar(&varStringGo, "go", "", "The file that contains main function") Cmd.Flags().StringVar(&varStringGo, "go", "", "The file that contains main function")
Cmd.Flags().StringVar(&varStringBase, "base", "scratch", "The base image to build the docker image, default scratch") Cmd.Flags().StringVar(&varStringBase, "base", "scratch", "The base image to build the docker image, default scratch")
Cmd.Flags().IntVar(&varIntPort, "port", 0, "The port to expose, default none") Cmd.Flags().IntVar(&varIntPort, "port", 0, "The port to expose, default none")
Cmd.Flags().StringVar(&varStringHome, "home", "", "The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority") Cmd.Flags().StringVar(&varStringHome, "home", "", "The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority")
Cmd.Flags().StringVar(&varStringRemote, "remote", "", "The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the https://github.com/zeromicro/go-zero-template directory structure") Cmd.Flags().StringVar(&varStringRemote, "remote", "", "The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority\nThe git repo directory must be consistent with the https://github.com/zeromicro/go-zero-template directory structure")
Cmd.Flags().StringVar(&varStringBranch, "branch", "", "The branch of the remote repo, it does work with --remote") Cmd.Flags().StringVar(&varStringBranch, "branch", "", "The branch of the remote repo, it does work with --remote")
Cmd.Flags().StringVar(&varStringVersion, "version", "", "The goctl builder golang image version") Cmd.Flags().StringVar(&varStringVersion, "version", "", "The goctl builder golang image version")
Cmd.Flags().StringVar(&varStringTZ, "tz", "Asia/Shanghai", "The timezone of the container") Cmd.Flags().StringVar(&varStringTZ, "tz", "Asia/Shanghai", "The timezone of the container")

View File

@@ -4,6 +4,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"os" "os"
"path"
"path/filepath" "path/filepath"
"strings" "strings"
"text/template" "text/template"
@@ -24,6 +25,7 @@ const (
// Docker describes a dockerfile // Docker describes a dockerfile
type Docker struct { type Docker struct {
Chinese bool Chinese bool
GoMainFrom string
GoRelPath string GoRelPath string
GoFile string GoFile string
ExeFile string ExeFile string
@@ -65,11 +67,7 @@ func dockerCommand(_ *cobra.Command, _ []string) (err error) {
pathx.RegisterGoctlHome(home) pathx.RegisterGoctlHome(home)
} }
if len(goFile) == 0 { if len(goFile) > 0 && !pathx.FileExists(goFile) {
return errors.New("-go can't be empty")
}
if !pathx.FileExists(goFile) {
return fmt.Errorf("file %q not found", goFile) return fmt.Errorf("file %q not found", goFile)
} }
@@ -126,9 +124,13 @@ func findConfig(file, dir string) (string, error) {
} }
func generateDockerfile(goFile, base string, port int, version, timezone string, args ...string) error { func generateDockerfile(goFile, base string, port int, version, timezone string, args ...string) error {
projPath, err := getFilePath(filepath.Dir(goFile)) var projPath string
if err != nil { var err error
return err if len(goFile) > 0 {
projPath, err = getFilePath(filepath.Dir(goFile))
if err != nil {
return err
}
} }
if len(projPath) == 0 { if len(projPath) == 0 {
@@ -151,12 +153,27 @@ func generateDockerfile(goFile, base string, port int, version, timezone string,
builder.WriteString(`, "` + arg + `"`) builder.WriteString(`, "` + arg + `"`)
} }
var exeName string
if len(varExeName) > 0 {
exeName = varExeName
} else if len(goFile) > 0 {
exeName = pathx.FileNameWithoutExt(filepath.Base(goFile))
} else {
absPath, err := filepath.Abs(projPath)
if err != nil {
return err
}
exeName = filepath.Base(absPath)
}
t := template.Must(template.New("dockerfile").Parse(text)) t := template.Must(template.New("dockerfile").Parse(text))
return t.Execute(out, Docker{ return t.Execute(out, Docker{
Chinese: env.InChina(), Chinese: env.InChina(),
GoMainFrom: path.Join(projPath, goFile),
GoRelPath: projPath, GoRelPath: projPath,
GoFile: goFile, GoFile: goFile,
ExeFile: pathx.FileNameWithoutExt(filepath.Base(goFile)), ExeFile: exeName,
BaseImage: base, BaseImage: base,
HasPort: port > 0, HasPort: port > 0,
Port: port, Port: port,

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