mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-11 08:50:00 +08:00
Compare commits
67 Commits
v1.2.3
...
tools/goct
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6eb1a9670 | ||
|
|
e4ab518576 | ||
|
|
dfc67b5fac | ||
|
|
62266d8f91 | ||
|
|
b8ea16a88e | ||
|
|
23deaf50e6 | ||
|
|
38a36ed8d3 | ||
|
|
49bab23c54 | ||
|
|
78ba00d3a7 | ||
|
|
787b046a70 | ||
|
|
f827a7b985 | ||
|
|
f5f2097d14 | ||
|
|
cfcfb87fd4 | ||
|
|
1d223fc114 | ||
|
|
c0647f0719 | ||
|
|
8745ed9c61 | ||
|
|
836726e710 | ||
|
|
a67c118dcf | ||
|
|
cd289465fd | ||
|
|
263e426ae1 | ||
|
|
d5e493383a | ||
|
|
6f1d27354a | ||
|
|
26101732d2 | ||
|
|
71d40e0c08 | ||
|
|
4ba2ff7cdd | ||
|
|
2cdf5e7395 | ||
|
|
8315a55b3f | ||
|
|
d1c2a31af7 | ||
|
|
3e6c217408 | ||
|
|
b299f350be | ||
|
|
8fd16c17dc | ||
|
|
5979b2aa0f | ||
|
|
0b17e0e5d9 | ||
|
|
3d8ad5e4f6 | ||
|
|
ff1752dd39 | ||
|
|
1becaeb7be | ||
|
|
171afaadb9 | ||
|
|
776e6e647d | ||
|
|
4ccdf4ec72 | ||
|
|
a7bd993c0c | ||
|
|
a290ff4486 | ||
|
|
490ef13822 | ||
|
|
1b14de2ff9 | ||
|
|
914692cc82 | ||
|
|
07191dc430 | ||
|
|
af3fb2b04d | ||
|
|
0240fa131a | ||
|
|
e96577dd38 | ||
|
|
403dd7367a | ||
|
|
8086ad120b | ||
|
|
87a445689c | ||
|
|
b6bda54870 | ||
|
|
9d528dddd6 | ||
|
|
543d590710 | ||
|
|
f1d70eb6b2 | ||
|
|
d828c3f37e | ||
|
|
038491b7bc | ||
|
|
cf683411ee | ||
|
|
de5ed6a677 | ||
|
|
3dda557410 | ||
|
|
c800f6f723 | ||
|
|
0395ba1816 | ||
|
|
86f9f63b46 | ||
|
|
a7a6753118 | ||
|
|
2e80d12d6a | ||
|
|
417a96cbf2 | ||
|
|
2d4c29ea7c |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # https://gitee.com/kevwan/static/raw/master/images/sponsor.jpg
|
||||
custom: https://gitee.com/kevwan/static/raw/master/images/sponsor.jpg
|
||||
|
||||
30
.github/workflows/release.yaml
vendored
Normal file
30
.github/workflows/release.yaml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
releases-matrix:
|
||||
name: Release goctl binary
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
# build and publish in parallel: linux/386, linux/amd64, linux/arm64,
|
||||
# windows/386, windows/amd64, windows/arm64, darwin/amd64, darwin/arm64
|
||||
goos: [linux, windows, darwin]
|
||||
goarch: ["386", amd64, arm64]
|
||||
exclude:
|
||||
- goarch: "386"
|
||||
goos: darwin
|
||||
- goarch: "386"
|
||||
goos: windows
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: wangyoucao577/go-release-action@v1.22
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
goos: ${{ matrix.goos }}
|
||||
goarch: ${{ matrix.goarch }}
|
||||
goversion: "https://dl.google.com/go/go1.17.5.linux-amd64.tar.gz"
|
||||
project_path: "tools/goctl"
|
||||
binary_name: "goctl"
|
||||
extra_files: tools/goctl/goctl.md
|
||||
@@ -16,7 +16,6 @@ We hope that the items listed below will inspire further engagement from the com
|
||||
- [x] Support `username/password` authentication in ETCD
|
||||
- [x] Support `SSL/TLS` in `zRPC`
|
||||
- [x] Support `TLS` in redis connections
|
||||
- [ ] Support `retry strategies` in `zRPC`
|
||||
|
||||
## 2022
|
||||
- [ ] Support `goctl mock` command to start a mocking server with given `.api` file
|
||||
|
||||
@@ -37,25 +37,35 @@ func GetRegistry() *Registry {
|
||||
|
||||
// GetConn returns an etcd client connection associated with given endpoints.
|
||||
func (r *Registry) GetConn(endpoints []string) (EtcdClient, error) {
|
||||
return r.getCluster(endpoints).getClient()
|
||||
c, _ := r.getCluster(endpoints)
|
||||
return c.getClient()
|
||||
}
|
||||
|
||||
// Monitor monitors the key on given etcd endpoints, notify with the given UpdateListener.
|
||||
func (r *Registry) Monitor(endpoints []string, key string, l UpdateListener) error {
|
||||
return r.getCluster(endpoints).monitor(key, l)
|
||||
c, exists := r.getCluster(endpoints)
|
||||
// if exists, the existing values should be updated to the listener.
|
||||
if exists {
|
||||
kvs := c.getCurrent(key)
|
||||
for _, kv := range kvs {
|
||||
l.OnAdd(kv)
|
||||
}
|
||||
}
|
||||
|
||||
return c.monitor(key, l)
|
||||
}
|
||||
|
||||
func (r *Registry) getCluster(endpoints []string) *cluster {
|
||||
func (r *Registry) getCluster(endpoints []string) (c *cluster, exists bool) {
|
||||
clusterKey := getClusterKey(endpoints)
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
c, ok := r.clusters[clusterKey]
|
||||
if !ok {
|
||||
c, exists = r.clusters[clusterKey]
|
||||
if !exists {
|
||||
c = newCluster(endpoints)
|
||||
r.clusters[clusterKey] = c
|
||||
}
|
||||
|
||||
return c
|
||||
return
|
||||
}
|
||||
|
||||
type cluster struct {
|
||||
@@ -94,6 +104,21 @@ func (c *cluster) getClient() (EtcdClient, error) {
|
||||
return val.(EtcdClient), nil
|
||||
}
|
||||
|
||||
func (c *cluster) getCurrent(key string) []KV {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
var kvs []KV
|
||||
for k, v := range c.values[key] {
|
||||
kvs = append(kvs, KV{
|
||||
Key: k,
|
||||
Val: v,
|
||||
})
|
||||
}
|
||||
|
||||
return kvs
|
||||
}
|
||||
|
||||
func (c *cluster) handleChanges(key string, kvs []KV) {
|
||||
var add []KV
|
||||
var remove []KV
|
||||
@@ -197,14 +222,12 @@ func (c *cluster) load(cli EtcdClient, key string) {
|
||||
}
|
||||
|
||||
var kvs []KV
|
||||
c.lock.Lock()
|
||||
for _, ev := range resp.Kvs {
|
||||
kvs = append(kvs, KV{
|
||||
Key: string(ev.Key),
|
||||
Val: string(ev.Value),
|
||||
})
|
||||
}
|
||||
c.lock.Unlock()
|
||||
|
||||
c.handleChanges(key, kvs)
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ func setMockClient(cli EtcdClient) func() {
|
||||
|
||||
func TestGetCluster(t *testing.T) {
|
||||
AddAccount([]string{"first"}, "foo", "bar")
|
||||
c1 := GetRegistry().getCluster([]string{"first"})
|
||||
c2 := GetRegistry().getCluster([]string{"second"})
|
||||
c3 := GetRegistry().getCluster([]string{"first"})
|
||||
c1, _ := GetRegistry().getCluster([]string{"first"})
|
||||
c2, _ := GetRegistry().getCluster([]string{"second"})
|
||||
c3, _ := GetRegistry().getCluster([]string{"first"})
|
||||
assert.Equal(t, c1, c3)
|
||||
assert.NotEqual(t, c1, c2)
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ func (s Stream) Head(n int64) Stream {
|
||||
}
|
||||
if n == 0 {
|
||||
// let successive method go ASAP even we have more items to skip
|
||||
// why we don't just break the loop, because if break,
|
||||
// why we don't just break the loop, because if breaks,
|
||||
// this former goroutine will block forever, which will cause goroutine leak.
|
||||
close(source)
|
||||
}
|
||||
|
||||
@@ -79,8 +79,10 @@ func (l *durationLogger) WithDuration(duration time.Duration) Logger {
|
||||
}
|
||||
|
||||
func (l *durationLogger) write(writer io.Writer, level string, val interface{}) {
|
||||
l.Timestamp = getTimestamp()
|
||||
l.Level = level
|
||||
l.Content = val
|
||||
outputJson(writer, l)
|
||||
outputJson(writer, &durationLogger{
|
||||
Timestamp: getTimestamp(),
|
||||
Level: level,
|
||||
Content: val,
|
||||
Duration: l.Duration,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -23,6 +23,13 @@ func TestWithDurationErrorf(t *testing.T) {
|
||||
assert.True(t, strings.Contains(builder.String(), "duration"), builder.String())
|
||||
}
|
||||
|
||||
func TestWithDurationErrorv(t *testing.T) {
|
||||
var builder strings.Builder
|
||||
log.SetOutput(&builder)
|
||||
WithDuration(time.Second).Errorv("foo")
|
||||
assert.True(t, strings.Contains(builder.String(), "duration"), builder.String())
|
||||
}
|
||||
|
||||
func TestWithDurationInfo(t *testing.T) {
|
||||
var builder strings.Builder
|
||||
log.SetOutput(&builder)
|
||||
@@ -37,6 +44,13 @@ func TestWithDurationInfof(t *testing.T) {
|
||||
assert.True(t, strings.Contains(builder.String(), "duration"), builder.String())
|
||||
}
|
||||
|
||||
func TestWithDurationInfov(t *testing.T) {
|
||||
var builder strings.Builder
|
||||
log.SetOutput(&builder)
|
||||
WithDuration(time.Second).Infov("foo")
|
||||
assert.True(t, strings.Contains(builder.String(), "duration"), builder.String())
|
||||
}
|
||||
|
||||
func TestWithDurationSlow(t *testing.T) {
|
||||
var builder strings.Builder
|
||||
log.SetOutput(&builder)
|
||||
@@ -50,3 +64,10 @@ func TestWithDurationSlowf(t *testing.T) {
|
||||
WithDuration(time.Second).WithDuration(time.Hour).Slowf("foo")
|
||||
assert.True(t, strings.Contains(builder.String(), "duration"), builder.String())
|
||||
}
|
||||
|
||||
func TestWithDurationSlowv(t *testing.T) {
|
||||
var builder strings.Builder
|
||||
log.SetOutput(&builder)
|
||||
WithDuration(time.Second).WithDuration(time.Hour).Slowv("foo")
|
||||
assert.True(t, strings.Contains(builder.String(), "duration"), builder.String())
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ func ErrorCaller(callDepth int, v ...interface{}) {
|
||||
|
||||
// ErrorCallerf writes v with context in format into error log.
|
||||
func ErrorCallerf(callDepth int, format string, v ...interface{}) {
|
||||
errorTextSync(fmt.Sprintf(format, v...), callDepth+callerInnerDepth)
|
||||
errorTextSync(fmt.Errorf(format, v...).Error(), callDepth+callerInnerDepth)
|
||||
}
|
||||
|
||||
// Errorf writes v with format into error log.
|
||||
|
||||
@@ -2,6 +2,7 @@ package logx
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -242,6 +243,16 @@ func TestSetLevelWithDuration(t *testing.T) {
|
||||
assert.Equal(t, 0, writer.builder.Len())
|
||||
}
|
||||
|
||||
func TestErrorfWithWrappedError(t *testing.T) {
|
||||
SetLevel(ErrorLevel)
|
||||
const message = "there"
|
||||
writer := new(mockWriter)
|
||||
errorLog = writer
|
||||
atomic.StoreUint32(&initialized, 1)
|
||||
Errorf("hello %w", errors.New(message))
|
||||
assert.True(t, strings.Contains(writer.builder.String(), "hello there"))
|
||||
}
|
||||
|
||||
func TestMustNil(t *testing.T) {
|
||||
Must(nil)
|
||||
}
|
||||
|
||||
@@ -77,12 +77,16 @@ func (l *traceLogger) WithDuration(duration time.Duration) Logger {
|
||||
}
|
||||
|
||||
func (l *traceLogger) write(writer io.Writer, level string, val interface{}) {
|
||||
l.Timestamp = getTimestamp()
|
||||
l.Level = level
|
||||
l.Content = val
|
||||
l.Trace = traceIdFromContext(l.ctx)
|
||||
l.Span = spanIdFromContext(l.ctx)
|
||||
outputJson(writer, l)
|
||||
outputJson(writer, &traceLogger{
|
||||
logEntry: logEntry{
|
||||
Timestamp: getTimestamp(),
|
||||
Level: level,
|
||||
Duration: l.Duration,
|
||||
Content: val,
|
||||
},
|
||||
Trace: traceIdFromContext(l.ctx),
|
||||
Span: spanIdFromContext(l.ctx),
|
||||
})
|
||||
}
|
||||
|
||||
// WithContext sets ctx to log, for keeping tracing information.
|
||||
|
||||
@@ -51,6 +51,10 @@ func TestTraceError(t *testing.T) {
|
||||
l.WithDuration(time.Second).Errorf(testlog)
|
||||
assert.True(t, strings.Contains(buf.String(), traceKey))
|
||||
assert.True(t, strings.Contains(buf.String(), spanKey))
|
||||
buf.Reset()
|
||||
l.WithDuration(time.Second).Errorv(testlog)
|
||||
assert.True(t, strings.Contains(buf.String(), traceKey))
|
||||
assert.True(t, strings.Contains(buf.String(), spanKey))
|
||||
}
|
||||
|
||||
func TestTraceInfo(t *testing.T) {
|
||||
@@ -72,6 +76,10 @@ func TestTraceInfo(t *testing.T) {
|
||||
l.WithDuration(time.Second).Infof(testlog)
|
||||
assert.True(t, strings.Contains(buf.String(), traceKey))
|
||||
assert.True(t, strings.Contains(buf.String(), spanKey))
|
||||
buf.Reset()
|
||||
l.WithDuration(time.Second).Infov(testlog)
|
||||
assert.True(t, strings.Contains(buf.String(), traceKey))
|
||||
assert.True(t, strings.Contains(buf.String(), spanKey))
|
||||
}
|
||||
|
||||
func TestTraceSlow(t *testing.T) {
|
||||
@@ -93,6 +101,10 @@ func TestTraceSlow(t *testing.T) {
|
||||
l.WithDuration(time.Second).Slowf(testlog)
|
||||
assert.True(t, strings.Contains(buf.String(), traceKey))
|
||||
assert.True(t, strings.Contains(buf.String(), spanKey))
|
||||
buf.Reset()
|
||||
l.WithDuration(time.Second).Slowv(testlog)
|
||||
assert.True(t, strings.Contains(buf.String(), traceKey))
|
||||
assert.True(t, strings.Contains(buf.String(), spanKey))
|
||||
}
|
||||
|
||||
func TestTraceWithoutContext(t *testing.T) {
|
||||
|
||||
@@ -15,6 +15,11 @@ func UnmarshalJsonBytes(content []byte, v interface{}) error {
|
||||
return unmarshalJsonBytes(content, v, jsonUnmarshaler)
|
||||
}
|
||||
|
||||
// UnmarshalJsonMap unmarshals content from m into v.
|
||||
func UnmarshalJsonMap(m map[string]interface{}, v interface{}) error {
|
||||
return jsonUnmarshaler.Unmarshal(m, v)
|
||||
}
|
||||
|
||||
// UnmarshalJsonReader unmarshals content from reader into v.
|
||||
func UnmarshalJsonReader(reader io.Reader, v interface{}) error {
|
||||
return unmarshalJsonReader(reader, v, jsonUnmarshaler)
|
||||
|
||||
@@ -871,3 +871,50 @@ func TestUnmarshalReaderError(t *testing.T) {
|
||||
assert.NotNil(t, err)
|
||||
assert.True(t, strings.Contains(err.Error(), payload))
|
||||
}
|
||||
|
||||
func TestUnmarshalMap(t *testing.T) {
|
||||
t.Run("nil map and valid", func(t *testing.T) {
|
||||
var m map[string]interface{}
|
||||
var v struct {
|
||||
Any string `json:",optional"`
|
||||
}
|
||||
|
||||
err := UnmarshalJsonMap(m, &v)
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, len(v.Any) == 0)
|
||||
})
|
||||
|
||||
t.Run("empty map but not valid", func(t *testing.T) {
|
||||
m := map[string]interface{}{}
|
||||
var v struct {
|
||||
Any string
|
||||
}
|
||||
|
||||
err := UnmarshalJsonMap(m, &v)
|
||||
assert.NotNil(t, err)
|
||||
})
|
||||
|
||||
t.Run("empty map and valid", func(t *testing.T) {
|
||||
m := map[string]interface{}{}
|
||||
var v struct {
|
||||
Any string `json:",optional"`
|
||||
}
|
||||
|
||||
err := UnmarshalJsonMap(m, &v)
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, len(v.Any) == 0)
|
||||
})
|
||||
|
||||
t.Run("valid map", func(t *testing.T) {
|
||||
m := map[string]interface{}{
|
||||
"Any": "foo",
|
||||
}
|
||||
var v struct {
|
||||
Any string
|
||||
}
|
||||
|
||||
err := UnmarshalJsonMap(m, &v)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "foo", v.Any)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/jsonx"
|
||||
@@ -25,15 +24,17 @@ var (
|
||||
errValueNotSettable = errors.New("value is not settable")
|
||||
errValueNotStruct = errors.New("value type is not struct")
|
||||
keyUnmarshaler = NewUnmarshaler(defaultKeyName)
|
||||
cacheKeys atomic.Value
|
||||
cacheKeysLock sync.Mutex
|
||||
durationType = reflect.TypeOf(time.Duration(0))
|
||||
cacheKeys map[string][]string
|
||||
cacheKeysLock sync.Mutex
|
||||
defaultCache map[string]interface{}
|
||||
defaultCacheLock sync.Mutex
|
||||
emptyMap = map[string]interface{}{}
|
||||
emptyValue = reflect.ValueOf(lang.Placeholder)
|
||||
)
|
||||
|
||||
type (
|
||||
// A Unmarshaler is used to unmarshal with given tag key.
|
||||
// Unmarshaler is used to unmarshal with given tag key.
|
||||
Unmarshaler struct {
|
||||
key string
|
||||
opts unmarshalOptions
|
||||
@@ -46,12 +47,11 @@ type (
|
||||
fromString bool
|
||||
canonicalKey func(key string) string
|
||||
}
|
||||
|
||||
keyCache map[string][]string
|
||||
)
|
||||
|
||||
func init() {
|
||||
cacheKeys.Store(make(keyCache))
|
||||
cacheKeys = make(map[string][]string)
|
||||
defaultCache = make(map[string]interface{})
|
||||
}
|
||||
|
||||
// NewUnmarshaler returns a Unmarshaler.
|
||||
@@ -207,6 +207,8 @@ func (u *Unmarshaler) processFieldNotFromString(field reflect.StructField, value
|
||||
switch {
|
||||
case valueKind == reflect.Map && typeKind == reflect.Struct:
|
||||
return u.processFieldStruct(field, value, mapValue, fullName)
|
||||
case valueKind == reflect.Map && typeKind == reflect.Map:
|
||||
return u.fillMap(field, value, mapValue)
|
||||
case valueKind == reflect.String && typeKind == reflect.Slice:
|
||||
return u.fillSliceFromString(fieldType, value, mapValue)
|
||||
case valueKind == reflect.String && derefedFieldType == durationType:
|
||||
@@ -386,7 +388,13 @@ func (u *Unmarshaler) processNamedFieldWithoutValue(field reflect.StructField, v
|
||||
if derefedType == durationType {
|
||||
return fillDurationValue(fieldKind, value, defaultValue)
|
||||
}
|
||||
return setValue(fieldKind, value, defaultValue)
|
||||
|
||||
switch fieldKind {
|
||||
case reflect.Array, reflect.Slice:
|
||||
return u.fillSliceWithDefault(derefedType, value, defaultValue)
|
||||
default:
|
||||
return setValue(fieldKind, value, defaultValue)
|
||||
}
|
||||
}
|
||||
|
||||
switch fieldKind {
|
||||
@@ -500,7 +508,8 @@ func (u *Unmarshaler) fillSliceFromString(fieldType reflect.Type, value reflect.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int, baseKind reflect.Kind, value interface{}) error {
|
||||
func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int,
|
||||
baseKind reflect.Kind, value interface{}) error {
|
||||
ithVal := slice.Index(index)
|
||||
switch v := value.(type) {
|
||||
case json.Number:
|
||||
@@ -529,6 +538,28 @@ func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int, baseKind re
|
||||
}
|
||||
}
|
||||
|
||||
func (u *Unmarshaler) fillSliceWithDefault(derefedType reflect.Type, value reflect.Value,
|
||||
defaultValue string) error {
|
||||
baseFieldType := Deref(derefedType.Elem())
|
||||
baseFieldKind := baseFieldType.Kind()
|
||||
defaultCacheLock.Lock()
|
||||
slice, ok := defaultCache[defaultValue]
|
||||
defaultCacheLock.Unlock()
|
||||
if !ok {
|
||||
if baseFieldKind == reflect.String {
|
||||
slice = parseGroupedSegments(defaultValue)
|
||||
} else if err := jsonx.UnmarshalFromString(defaultValue, &slice); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defaultCacheLock.Lock()
|
||||
defaultCache[defaultValue] = slice
|
||||
defaultCacheLock.Unlock()
|
||||
}
|
||||
|
||||
return u.fillSlice(derefedType, value, slice)
|
||||
}
|
||||
|
||||
func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue interface{}) (reflect.Value, error) {
|
||||
mapType := reflect.MapOf(keyType, elemType)
|
||||
valueType := reflect.TypeOf(mapValue)
|
||||
@@ -584,6 +615,8 @@ func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue inter
|
||||
targetValue.SetMapIndex(key, innerValue)
|
||||
default:
|
||||
switch v := keythData.(type) {
|
||||
case bool:
|
||||
targetValue.SetMapIndex(key, reflect.ValueOf(v))
|
||||
case string:
|
||||
targetValue.SetMapIndex(key, reflect.ValueOf(v))
|
||||
case json.Number:
|
||||
@@ -720,20 +753,6 @@ func getValueWithChainedKeys(m Valuer, keys []string) (interface{}, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func insertKeys(key string, cache []string) {
|
||||
cacheKeysLock.Lock()
|
||||
defer cacheKeysLock.Unlock()
|
||||
|
||||
keys := cacheKeys.Load().(keyCache)
|
||||
// copy the contents into the new map, to guarantee the old map is immutable
|
||||
newKeys := make(keyCache)
|
||||
for k, v := range keys {
|
||||
newKeys[k] = v
|
||||
}
|
||||
newKeys[key] = cache
|
||||
cacheKeys.Store(newKeys)
|
||||
}
|
||||
|
||||
func join(elem ...string) string {
|
||||
var builder strings.Builder
|
||||
|
||||
@@ -764,15 +783,19 @@ func newTypeMismatchError(name string) error {
|
||||
}
|
||||
|
||||
func readKeys(key string) []string {
|
||||
cache := cacheKeys.Load().(keyCache)
|
||||
if keys, ok := cache[key]; ok {
|
||||
cacheKeysLock.Lock()
|
||||
keys, ok := cacheKeys[key]
|
||||
cacheKeysLock.Unlock()
|
||||
if ok {
|
||||
return keys
|
||||
}
|
||||
|
||||
keys := strings.FieldsFunc(key, func(c rune) bool {
|
||||
keys = strings.FieldsFunc(key, func(c rune) bool {
|
||||
return c == delimiter
|
||||
})
|
||||
insertKeys(key, keys)
|
||||
cacheKeysLock.Lock()
|
||||
cacheKeys[key] = keys
|
||||
cacheKeysLock.Unlock()
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
@@ -198,6 +198,66 @@ func TestUnmarshalIntWithDefault(t *testing.T) {
|
||||
assert.Equal(t, 1, in.Int)
|
||||
}
|
||||
|
||||
func TestUnmarshalBoolSliceWithDefault(t *testing.T) {
|
||||
type inner struct {
|
||||
Bools []bool `key:"bools,default=[true,false]"`
|
||||
}
|
||||
|
||||
var in inner
|
||||
assert.Nil(t, UnmarshalKey(nil, &in))
|
||||
assert.ElementsMatch(t, []bool{true, false}, in.Bools)
|
||||
}
|
||||
|
||||
func TestUnmarshalIntSliceWithDefault(t *testing.T) {
|
||||
type inner struct {
|
||||
Ints []int `key:"ints,default=[1,2,3]"`
|
||||
}
|
||||
|
||||
var in inner
|
||||
assert.Nil(t, UnmarshalKey(nil, &in))
|
||||
assert.ElementsMatch(t, []int{1, 2, 3}, in.Ints)
|
||||
}
|
||||
|
||||
func TestUnmarshalIntSliceWithDefaultHasSpaces(t *testing.T) {
|
||||
type inner struct {
|
||||
Ints []int `key:"ints,default=[1, 2, 3]"`
|
||||
}
|
||||
|
||||
var in inner
|
||||
assert.Nil(t, UnmarshalKey(nil, &in))
|
||||
assert.ElementsMatch(t, []int{1, 2, 3}, in.Ints)
|
||||
}
|
||||
|
||||
func TestUnmarshalFloatSliceWithDefault(t *testing.T) {
|
||||
type inner struct {
|
||||
Floats []float32 `key:"floats,default=[1.1,2.2,3.3]"`
|
||||
}
|
||||
|
||||
var in inner
|
||||
assert.Nil(t, UnmarshalKey(nil, &in))
|
||||
assert.ElementsMatch(t, []float32{1.1, 2.2, 3.3}, in.Floats)
|
||||
}
|
||||
|
||||
func TestUnmarshalStringSliceWithDefault(t *testing.T) {
|
||||
type inner struct {
|
||||
Strs []string `key:"strs,default=[foo,bar,woo]"`
|
||||
}
|
||||
|
||||
var in inner
|
||||
assert.Nil(t, UnmarshalKey(nil, &in))
|
||||
assert.ElementsMatch(t, []string{"foo", "bar", "woo"}, in.Strs)
|
||||
}
|
||||
|
||||
func TestUnmarshalStringSliceWithDefaultHasSpaces(t *testing.T) {
|
||||
type inner struct {
|
||||
Strs []string `key:"strs,default=[foo, bar, woo]"`
|
||||
}
|
||||
|
||||
var in inner
|
||||
assert.Nil(t, UnmarshalKey(nil, &in))
|
||||
assert.ElementsMatch(t, []string{"foo", "bar", "woo"}, in.Strs)
|
||||
}
|
||||
|
||||
func TestUnmarshalUint(t *testing.T) {
|
||||
type inner struct {
|
||||
Uint uint `key:"uint"`
|
||||
@@ -861,10 +921,12 @@ func TestUnmarshalSliceOfStruct(t *testing.T) {
|
||||
func TestUnmarshalWithStringOptionsCorrect(t *testing.T) {
|
||||
type inner struct {
|
||||
Value string `key:"value,options=first|second"`
|
||||
Foo string `key:"foo,options=[bar,baz]"`
|
||||
Correct string `key:"correct,options=1|2"`
|
||||
}
|
||||
m := map[string]interface{}{
|
||||
"value": "first",
|
||||
"foo": "bar",
|
||||
"correct": "2",
|
||||
}
|
||||
|
||||
@@ -872,6 +934,7 @@ func TestUnmarshalWithStringOptionsCorrect(t *testing.T) {
|
||||
ast := assert.New(t)
|
||||
ast.Nil(UnmarshalKey(m, &in))
|
||||
ast.Equal("first", in.Value)
|
||||
ast.Equal("bar", in.Foo)
|
||||
ast.Equal("2", in.Correct)
|
||||
}
|
||||
|
||||
@@ -943,6 +1006,22 @@ func TestUnmarshalStringOptionsWithStringOptionsIncorrect(t *testing.T) {
|
||||
ast.NotNil(unmarshaler.Unmarshal(m, &in))
|
||||
}
|
||||
|
||||
func TestUnmarshalStringOptionsWithStringOptionsIncorrectGrouped(t *testing.T) {
|
||||
type inner struct {
|
||||
Value string `key:"value,options=[first,second]"`
|
||||
Correct string `key:"correct,options=1|2"`
|
||||
}
|
||||
m := map[string]interface{}{
|
||||
"value": "third",
|
||||
"correct": "2",
|
||||
}
|
||||
|
||||
var in inner
|
||||
unmarshaler := NewUnmarshaler(defaultKeyName, WithStringValues())
|
||||
ast := assert.New(t)
|
||||
ast.NotNil(unmarshaler.Unmarshal(m, &in))
|
||||
}
|
||||
|
||||
func TestUnmarshalWithStringOptionsIncorrect(t *testing.T) {
|
||||
type inner struct {
|
||||
Value string `key:"value,options=first|second"`
|
||||
@@ -2518,3 +2597,29 @@ func TestUnmarshalJsonReaderPtrArray(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 3, len(res.B))
|
||||
}
|
||||
|
||||
func TestUnmarshalJsonWithoutKey(t *testing.T) {
|
||||
payload := `{"A": "1", "B": "2"}`
|
||||
var res struct {
|
||||
A string `json:""`
|
||||
B string `json:","`
|
||||
}
|
||||
reader := strings.NewReader(payload)
|
||||
err := UnmarshalJsonReader(reader, &res)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "1", res.A)
|
||||
assert.Equal(t, "2", res.B)
|
||||
}
|
||||
|
||||
func BenchmarkDefaultValue(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
var a struct {
|
||||
Ints []int `json:"ints,default=[1,2,3]"`
|
||||
Strs []string `json:"strs,default=[foo,bar,baz]"`
|
||||
}
|
||||
_ = UnmarshalJsonMap(nil, &a)
|
||||
if len(a.Strs) != 3 || len(a.Ints) != 3 {
|
||||
b.Fatal("failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,19 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
defaultOption = "default"
|
||||
stringOption = "string"
|
||||
optionalOption = "optional"
|
||||
optionsOption = "options"
|
||||
rangeOption = "range"
|
||||
optionSeparator = "|"
|
||||
equalToken = "="
|
||||
defaultOption = "default"
|
||||
stringOption = "string"
|
||||
optionalOption = "optional"
|
||||
optionsOption = "options"
|
||||
rangeOption = "range"
|
||||
optionSeparator = "|"
|
||||
equalToken = "="
|
||||
escapeChar = '\\'
|
||||
leftBracket = '('
|
||||
rightBracket = ')'
|
||||
leftSquareBracket = '['
|
||||
rightSquareBracket = ']'
|
||||
segmentSeparator = ','
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -118,7 +124,7 @@ func convertType(kind reflect.Kind, str string) (interface{}, error) {
|
||||
}
|
||||
|
||||
func doParseKeyAndOptions(field reflect.StructField, value string) (string, *fieldOptions, error) {
|
||||
segments := strings.Split(value, ",")
|
||||
segments := parseSegments(value)
|
||||
key := strings.TrimSpace(segments[0])
|
||||
options := segments[1:]
|
||||
|
||||
@@ -198,6 +204,16 @@ func maybeNewValue(field reflect.StructField, value reflect.Value) {
|
||||
}
|
||||
}
|
||||
|
||||
func parseGroupedSegments(val string) []string {
|
||||
val = strings.TrimLeftFunc(val, func(r rune) bool {
|
||||
return r == leftBracket || r == leftSquareBracket
|
||||
})
|
||||
val = strings.TrimRightFunc(val, func(r rune) bool {
|
||||
return r == rightBracket || r == rightSquareBracket
|
||||
})
|
||||
return parseSegments(val)
|
||||
}
|
||||
|
||||
// don't modify returned fieldOptions, it's cached and shared among different calls.
|
||||
func parseKeyAndOptions(tagName string, field reflect.StructField) (string, *fieldOptions, error) {
|
||||
value := field.Tag.Get(tagName)
|
||||
@@ -309,7 +325,7 @@ func parseOption(fieldOpts *fieldOptions, fieldName, option string) error {
|
||||
return fmt.Errorf("field %s has wrong options", fieldName)
|
||||
}
|
||||
|
||||
fieldOpts.Options = strings.Split(segs[1], optionSeparator)
|
||||
fieldOpts.Options = parseOptions(segs[1])
|
||||
case strings.HasPrefix(option, defaultOption):
|
||||
segs := strings.Split(option, equalToken)
|
||||
if len(segs) != 2 {
|
||||
@@ -334,6 +350,69 @@ func parseOption(fieldOpts *fieldOptions, fieldName, option string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseOptions parses the given options in tag.
|
||||
// for example: `json:"name,options=foo|bar"` or `json:"name,options=[foo,bar]"`
|
||||
func parseOptions(val string) []string {
|
||||
if len(val) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if val[0] == leftSquareBracket {
|
||||
return parseGroupedSegments(val)
|
||||
}
|
||||
|
||||
return strings.Split(val, optionSeparator)
|
||||
}
|
||||
|
||||
func parseSegments(val string) []string {
|
||||
var segments []string
|
||||
var escaped, grouped bool
|
||||
var buf strings.Builder
|
||||
|
||||
for _, ch := range val {
|
||||
if escaped {
|
||||
buf.WriteRune(ch)
|
||||
escaped = false
|
||||
continue
|
||||
}
|
||||
|
||||
switch ch {
|
||||
case segmentSeparator:
|
||||
if grouped {
|
||||
buf.WriteRune(ch)
|
||||
} else {
|
||||
// need to trim spaces, but we cannot ignore empty string,
|
||||
// because the first segment stands for the key might be empty.
|
||||
// if ignored, the later tag will be used as the key.
|
||||
segments = append(segments, strings.TrimSpace(buf.String()))
|
||||
buf.Reset()
|
||||
}
|
||||
case escapeChar:
|
||||
if grouped {
|
||||
buf.WriteRune(ch)
|
||||
} else {
|
||||
escaped = true
|
||||
}
|
||||
case leftBracket, leftSquareBracket:
|
||||
buf.WriteRune(ch)
|
||||
grouped = true
|
||||
case rightBracket, rightSquareBracket:
|
||||
buf.WriteRune(ch)
|
||||
grouped = false
|
||||
default:
|
||||
buf.WriteRune(ch)
|
||||
}
|
||||
}
|
||||
|
||||
last := strings.TrimSpace(buf.String())
|
||||
// ignore last empty string
|
||||
if len(last) > 0 {
|
||||
segments = append(segments, last)
|
||||
}
|
||||
|
||||
return segments
|
||||
}
|
||||
|
||||
func reprOfValue(val reflect.Value) string {
|
||||
switch vt := val.Interface().(type) {
|
||||
case bool:
|
||||
|
||||
@@ -90,6 +90,82 @@ func TestParseKeyAndOptionWithTagAndOption(t *testing.T) {
|
||||
assert.True(t, options.FromString)
|
||||
}
|
||||
|
||||
func TestParseSegments(t *testing.T) {
|
||||
tests := []struct {
|
||||
input string
|
||||
expect []string
|
||||
}{
|
||||
{
|
||||
input: "",
|
||||
expect: []string{},
|
||||
},
|
||||
{
|
||||
input: ",",
|
||||
expect: []string{""},
|
||||
},
|
||||
{
|
||||
input: "foo,",
|
||||
expect: []string{"foo"},
|
||||
},
|
||||
{
|
||||
input: ",foo",
|
||||
// the first empty string cannot be ignored, it's the key.
|
||||
expect: []string{"", "foo"},
|
||||
},
|
||||
{
|
||||
input: "foo",
|
||||
expect: []string{"foo"},
|
||||
},
|
||||
{
|
||||
input: "foo,bar",
|
||||
expect: []string{"foo", "bar"},
|
||||
},
|
||||
{
|
||||
input: "foo,bar,baz",
|
||||
expect: []string{"foo", "bar", "baz"},
|
||||
},
|
||||
{
|
||||
input: "foo,options=a|b",
|
||||
expect: []string{"foo", "options=a|b"},
|
||||
},
|
||||
{
|
||||
input: "foo,bar,default=[baz,qux]",
|
||||
expect: []string{"foo", "bar", "default=[baz,qux]"},
|
||||
},
|
||||
{
|
||||
input: "foo,bar,options=[baz,qux]",
|
||||
expect: []string{"foo", "bar", "options=[baz,qux]"},
|
||||
},
|
||||
{
|
||||
input: `foo\,bar,options=[baz,qux]`,
|
||||
expect: []string{`foo,bar`, "options=[baz,qux]"},
|
||||
},
|
||||
{
|
||||
input: `foo,bar,options=\[baz,qux]`,
|
||||
expect: []string{"foo", "bar", "options=[baz", "qux]"},
|
||||
},
|
||||
{
|
||||
input: `foo,bar,options=[baz\,qux]`,
|
||||
expect: []string{"foo", "bar", `options=[baz\,qux]`},
|
||||
},
|
||||
{
|
||||
input: `foo\,bar,options=[baz,qux],default=baz`,
|
||||
expect: []string{`foo,bar`, "options=[baz,qux]", "default=baz"},
|
||||
},
|
||||
{
|
||||
input: `foo\,bar,options=[baz,qux, quux],default=[qux, baz]`,
|
||||
expect: []string{`foo,bar`, "options=[baz,qux, quux]", "default=[qux, baz]"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
t.Run(test.input, func(t *testing.T) {
|
||||
assert.ElementsMatch(t, test.expect, parseSegments(test.input))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatePtrWithNonPtr(t *testing.T) {
|
||||
var foo string
|
||||
rve := reflect.ValueOf(foo)
|
||||
|
||||
@@ -945,6 +945,70 @@ func TestUnmarshalYamlBadReader(t *testing.T) {
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestUnmarshalYamlMapBool(t *testing.T) {
|
||||
text := `machine:
|
||||
node1: true
|
||||
node2: true
|
||||
node3: true
|
||||
`
|
||||
var v struct {
|
||||
Machine map[string]bool `json:"machine,optional"`
|
||||
}
|
||||
reader := strings.NewReader(text)
|
||||
assert.Nil(t, UnmarshalYamlReader(reader, &v))
|
||||
assert.True(t, v.Machine["node1"])
|
||||
assert.True(t, v.Machine["node2"])
|
||||
assert.True(t, v.Machine["node3"])
|
||||
}
|
||||
|
||||
func TestUnmarshalYamlMapInt(t *testing.T) {
|
||||
text := `machine:
|
||||
node1: 1
|
||||
node2: 2
|
||||
node3: 3
|
||||
`
|
||||
var v struct {
|
||||
Machine map[string]int `json:"machine,optional"`
|
||||
}
|
||||
reader := strings.NewReader(text)
|
||||
assert.Nil(t, UnmarshalYamlReader(reader, &v))
|
||||
assert.Equal(t, 1, v.Machine["node1"])
|
||||
assert.Equal(t, 2, v.Machine["node2"])
|
||||
assert.Equal(t, 3, v.Machine["node3"])
|
||||
}
|
||||
|
||||
func TestUnmarshalYamlMapByte(t *testing.T) {
|
||||
text := `machine:
|
||||
node1: 1
|
||||
node2: 2
|
||||
node3: 3
|
||||
`
|
||||
var v struct {
|
||||
Machine map[string]byte `json:"machine,optional"`
|
||||
}
|
||||
reader := strings.NewReader(text)
|
||||
assert.Nil(t, UnmarshalYamlReader(reader, &v))
|
||||
assert.Equal(t, byte(1), v.Machine["node1"])
|
||||
assert.Equal(t, byte(2), v.Machine["node2"])
|
||||
assert.Equal(t, byte(3), v.Machine["node3"])
|
||||
}
|
||||
|
||||
func TestUnmarshalYamlMapRune(t *testing.T) {
|
||||
text := `machine:
|
||||
node1: 1
|
||||
node2: 2
|
||||
node3: 3
|
||||
`
|
||||
var v struct {
|
||||
Machine map[string]rune `json:"machine,optional"`
|
||||
}
|
||||
reader := strings.NewReader(text)
|
||||
assert.Nil(t, UnmarshalYamlReader(reader, &v))
|
||||
assert.Equal(t, rune(1), v.Machine["node1"])
|
||||
assert.Equal(t, rune(2), v.Machine["node2"])
|
||||
assert.Equal(t, rune(3), v.Machine["node3"])
|
||||
}
|
||||
|
||||
type badReader struct{}
|
||||
|
||||
func (b *badReader) Read(p []byte) (n int, err error) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
@@ -43,6 +44,7 @@ type (
|
||||
Option func(opts *mapReduceOptions)
|
||||
|
||||
mapReduceOptions struct {
|
||||
ctx context.Context
|
||||
workers int
|
||||
}
|
||||
|
||||
@@ -95,14 +97,15 @@ func Map(generate GenerateFunc, mapper MapFunc, opts ...Option) chan interface{}
|
||||
collector := make(chan interface{}, options.workers)
|
||||
done := syncx.NewDoneChan()
|
||||
|
||||
go executeMappers(mapper, source, collector, done.Done(), options.workers)
|
||||
go executeMappers(options.ctx, mapper, source, collector, done.Done(), options.workers)
|
||||
|
||||
return collector
|
||||
}
|
||||
|
||||
// MapReduce maps all elements generated from given generate func,
|
||||
// and reduces the output elements with given reducer.
|
||||
func MapReduce(generate GenerateFunc, mapper MapperFunc, reducer ReducerFunc, opts ...Option) (interface{}, error) {
|
||||
func MapReduce(generate GenerateFunc, mapper MapperFunc, reducer ReducerFunc,
|
||||
opts ...Option) (interface{}, error) {
|
||||
source := buildSource(generate)
|
||||
return MapReduceWithSource(source, mapper, reducer, opts...)
|
||||
}
|
||||
@@ -120,7 +123,7 @@ func MapReduceWithSource(source <-chan interface{}, mapper MapperFunc, reducer R
|
||||
|
||||
collector := make(chan interface{}, options.workers)
|
||||
done := syncx.NewDoneChan()
|
||||
writer := newGuardedWriter(output, done.Done())
|
||||
writer := newGuardedWriter(options.ctx, output, done.Done())
|
||||
var closeOnce sync.Once
|
||||
var retErr errorx.AtomicError
|
||||
finish := func() {
|
||||
@@ -154,7 +157,7 @@ func MapReduceWithSource(source <-chan interface{}, mapper MapperFunc, reducer R
|
||||
reducer(collector, writer, cancel)
|
||||
}()
|
||||
|
||||
go executeMappers(func(item interface{}, w Writer) {
|
||||
go executeMappers(options.ctx, func(item interface{}, w Writer) {
|
||||
mapper(item, w, cancel)
|
||||
}, source, collector, done.Done(), options.workers)
|
||||
|
||||
@@ -187,6 +190,13 @@ func MapVoid(generate GenerateFunc, mapper VoidMapFunc, opts ...Option) {
|
||||
}, opts...))
|
||||
}
|
||||
|
||||
// WithContext customizes a mapreduce processing accepts a given ctx.
|
||||
func WithContext(ctx context.Context) Option {
|
||||
return func(opts *mapReduceOptions) {
|
||||
opts.ctx = ctx
|
||||
}
|
||||
}
|
||||
|
||||
// WithWorkers customizes a mapreduce processing with given workers.
|
||||
func WithWorkers(workers int) Option {
|
||||
return func(opts *mapReduceOptions) {
|
||||
@@ -224,8 +234,8 @@ func drain(channel <-chan interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func executeMappers(mapper MapFunc, input <-chan interface{}, collector chan<- interface{},
|
||||
done <-chan lang.PlaceholderType, workers int) {
|
||||
func executeMappers(ctx context.Context, mapper MapFunc, input <-chan interface{},
|
||||
collector chan<- interface{}, done <-chan lang.PlaceholderType, workers int) {
|
||||
var wg sync.WaitGroup
|
||||
defer func() {
|
||||
wg.Wait()
|
||||
@@ -233,9 +243,11 @@ func executeMappers(mapper MapFunc, input <-chan interface{}, collector chan<- i
|
||||
}()
|
||||
|
||||
pool := make(chan lang.PlaceholderType, workers)
|
||||
writer := newGuardedWriter(collector, done)
|
||||
writer := newGuardedWriter(ctx, collector, done)
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-done:
|
||||
return
|
||||
case pool <- lang.Placeholder:
|
||||
@@ -261,6 +273,7 @@ func executeMappers(mapper MapFunc, input <-chan interface{}, collector chan<- i
|
||||
|
||||
func newOptions() *mapReduceOptions {
|
||||
return &mapReduceOptions{
|
||||
ctx: context.Background(),
|
||||
workers: defaultWorkers,
|
||||
}
|
||||
}
|
||||
@@ -275,12 +288,15 @@ func once(fn func(error)) func(error) {
|
||||
}
|
||||
|
||||
type guardedWriter struct {
|
||||
ctx context.Context
|
||||
channel chan<- interface{}
|
||||
done <-chan lang.PlaceholderType
|
||||
}
|
||||
|
||||
func newGuardedWriter(channel chan<- interface{}, done <-chan lang.PlaceholderType) guardedWriter {
|
||||
func newGuardedWriter(ctx context.Context, channel chan<- interface{},
|
||||
done <-chan lang.PlaceholderType) guardedWriter {
|
||||
return guardedWriter{
|
||||
ctx: ctx,
|
||||
channel: channel,
|
||||
done: done,
|
||||
}
|
||||
@@ -288,6 +304,8 @@ func newGuardedWriter(channel chan<- interface{}, done <-chan lang.PlaceholderTy
|
||||
|
||||
func (gw guardedWriter) Write(v interface{}) {
|
||||
select {
|
||||
case <-gw.ctx.Done():
|
||||
return
|
||||
case <-gw.done:
|
||||
return
|
||||
default:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
@@ -410,6 +411,50 @@ func TestMapReduceWithoutReducerWrite(t *testing.T) {
|
||||
assert.Nil(t, res)
|
||||
}
|
||||
|
||||
func TestMapReduceVoidPanicInReducer(t *testing.T) {
|
||||
const message = "foo"
|
||||
var done syncx.AtomicBool
|
||||
err := MapReduceVoid(func(source chan<- interface{}) {
|
||||
for i := 0; i < defaultWorkers*2; i++ {
|
||||
source <- i
|
||||
}
|
||||
done.Set(true)
|
||||
}, func(item interface{}, writer Writer, cancel func(error)) {
|
||||
i := item.(int)
|
||||
writer.Write(i)
|
||||
}, func(pipe <-chan interface{}, cancel func(error)) {
|
||||
panic(message)
|
||||
}, WithWorkers(1))
|
||||
assert.NotNil(t, err)
|
||||
assert.Equal(t, message, err.Error())
|
||||
assert.True(t, done.True())
|
||||
}
|
||||
|
||||
func TestMapReduceWithContext(t *testing.T) {
|
||||
var done syncx.AtomicBool
|
||||
var result []int
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
err := MapReduceVoid(func(source chan<- interface{}) {
|
||||
for i := 0; i < defaultWorkers*2; i++ {
|
||||
source <- i
|
||||
}
|
||||
done.Set(true)
|
||||
}, func(item interface{}, writer Writer, c func(error)) {
|
||||
i := item.(int)
|
||||
if i == defaultWorkers/2 {
|
||||
cancel()
|
||||
}
|
||||
writer.Write(i)
|
||||
}, func(pipe <-chan interface{}, cancel func(error)) {
|
||||
for item := range pipe {
|
||||
i := item.(int)
|
||||
result = append(result, i)
|
||||
}
|
||||
}, WithContext(ctx))
|
||||
assert.NotNil(t, err)
|
||||
assert.Equal(t, ErrReduceNoOutput, err)
|
||||
}
|
||||
|
||||
func BenchmarkMapReduce(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/logx"
|
||||
"github.com/tal-tech/go-zero/core/threading"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -46,10 +47,10 @@ func gracefulStop(signals chan os.Signal) {
|
||||
signal.Stop(signals)
|
||||
|
||||
logx.Info("Got signal SIGTERM, shutting down...")
|
||||
wrapUpListeners.notifyListeners()
|
||||
go wrapUpListeners.notifyListeners()
|
||||
|
||||
time.Sleep(wrapUpTime)
|
||||
shutdownListeners.notifyListeners()
|
||||
go shutdownListeners.notifyListeners()
|
||||
|
||||
time.Sleep(delayTimeBeforeForceQuit - wrapUpTime)
|
||||
logx.Infof("Still alive after %v, going to force kill the process...", delayTimeBeforeForceQuit)
|
||||
@@ -81,7 +82,9 @@ func (lm *listenerManager) notifyListeners() {
|
||||
lm.lock.Lock()
|
||||
defer lm.lock.Unlock()
|
||||
|
||||
group := threading.NewRoutineGroup()
|
||||
for _, listener := range lm.listeners {
|
||||
listener()
|
||||
group.RunSafe(listener)
|
||||
}
|
||||
group.Wait()
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package backoff
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Func defines the method to calculate how long to retry.
|
||||
type Func func(attempt int) time.Duration
|
||||
|
||||
// LinearWithJitter waits a set period of time, allowing for jitter (fractional adjustment).
|
||||
func LinearWithJitter(waitBetween time.Duration, jitterFraction float64) Func {
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
return func(attempt int) time.Duration {
|
||||
multiplier := jitterFraction * (r.Float64()*2 - 1)
|
||||
return time.Duration(float64(waitBetween) * (1 + multiplier))
|
||||
}
|
||||
}
|
||||
|
||||
// Interval it waits for a fixed period of time between calls.
|
||||
func Interval(interval time.Duration) Func {
|
||||
return func(attempt int) time.Duration {
|
||||
return interval
|
||||
}
|
||||
}
|
||||
|
||||
// Exponential produces increasing intervals for each attempt.
|
||||
func Exponential(scalar time.Duration) Func {
|
||||
return func(attempt int) time.Duration {
|
||||
return scalar * time.Duration((1<<attempt)>>1)
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package backoff
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestWaitBetween(t *testing.T) {
|
||||
fn := Interval(time.Second)
|
||||
assert.EqualValues(t, time.Second, fn(1))
|
||||
}
|
||||
|
||||
func TestExponential(t *testing.T) {
|
||||
fn := Exponential(time.Second)
|
||||
assert.EqualValues(t, time.Second, fn(1))
|
||||
}
|
||||
|
||||
func TestLinearWithJitter(t *testing.T) {
|
||||
const rounds = 1000000
|
||||
var total time.Duration
|
||||
fn := LinearWithJitter(time.Second, 0.5)
|
||||
for i := 0; i < rounds; i++ {
|
||||
total += fn(1)
|
||||
}
|
||||
|
||||
// 0.1% tolerance
|
||||
assert.True(t, total/time.Duration(rounds)-time.Second < time.Millisecond)
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package retry
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/retry/backoff"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
// WithDisable disables the retry behaviour on this call, or this interceptor.
|
||||
// It's semantically the same to `WithMax(0)`
|
||||
func WithDisable() *CallOption {
|
||||
return WithMax(0)
|
||||
}
|
||||
|
||||
// WithMax sets the maximum number of retries on this call, or this interceptor.
|
||||
func WithMax(maxRetries int) *CallOption {
|
||||
return &CallOption{apply: func(options *options) {
|
||||
options.max = maxRetries
|
||||
}}
|
||||
}
|
||||
|
||||
// WithBackoff sets the `BackoffFunc` used to control time between retries.
|
||||
func WithBackoff(backoffFunc backoff.Func) *CallOption {
|
||||
return &CallOption{apply: func(o *options) {
|
||||
o.backoffFunc = backoffFunc
|
||||
}}
|
||||
}
|
||||
|
||||
// WithCodes Allow code to be retried.
|
||||
func WithCodes(retryCodes ...codes.Code) *CallOption {
|
||||
return &CallOption{apply: func(o *options) {
|
||||
o.codes = retryCodes
|
||||
}}
|
||||
}
|
||||
|
||||
// WithPerRetryTimeout timeout for each retry
|
||||
func WithPerRetryTimeout(timeout time.Duration) *CallOption {
|
||||
return &CallOption{apply: func(o *options) {
|
||||
o.perCallTimeout = timeout
|
||||
}}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package retry
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tal-tech/go-zero/core/logx"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func TestRetryWithDisable(t *testing.T) {
|
||||
opt := &options{}
|
||||
assert.EqualValues(t, &options{}, parseRetryCallOptions(opt, WithDisable()))
|
||||
}
|
||||
|
||||
func TestRetryWithMax(t *testing.T) {
|
||||
n := 5
|
||||
for i := 0; i < n; i++ {
|
||||
opt := &options{}
|
||||
assert.EqualValues(t, &options{max: i}, parseRetryCallOptions(opt, WithMax(i)))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRetryWithBackoff(t *testing.T) {
|
||||
opt := &options{}
|
||||
|
||||
retryCallOptions := parseRetryCallOptions(opt, WithBackoff(func(attempt int) time.Duration {
|
||||
return time.Millisecond
|
||||
}))
|
||||
assert.EqualValues(t, time.Millisecond, retryCallOptions.backoffFunc(1))
|
||||
}
|
||||
|
||||
func TestRetryWithCodes(t *testing.T) {
|
||||
opt := &options{}
|
||||
c := []codes.Code{codes.Unknown, codes.NotFound}
|
||||
options := parseRetryCallOptions(opt, WithCodes(c...))
|
||||
assert.EqualValues(t, c, options.codes)
|
||||
}
|
||||
|
||||
func TestRetryWithPerRetryTimeout(t *testing.T) {
|
||||
opt := &options{}
|
||||
options := parseRetryCallOptions(opt, WithPerRetryTimeout(time.Millisecond))
|
||||
assert.EqualValues(t, time.Millisecond, options.perCallTimeout)
|
||||
}
|
||||
|
||||
func Test_waitRetryBackoff(t *testing.T) {
|
||||
logx.Disable()
|
||||
|
||||
opt := &options{perCallTimeout: time.Second, backoffFunc: func(attempt int) time.Duration {
|
||||
return time.Second
|
||||
}}
|
||||
logger := logx.WithContext(context.Background())
|
||||
err := waitRetryBackoff(logger, 1, context.Background(), opt)
|
||||
assert.NoError(t, err)
|
||||
ctx, cancelFunc := context.WithTimeout(context.Background(), time.Millisecond)
|
||||
defer cancelFunc()
|
||||
err = waitRetryBackoff(logger, 1, ctx, opt)
|
||||
assert.ErrorIs(t, err, status.FromContextError(context.DeadlineExceeded).Err())
|
||||
}
|
||||
|
||||
func Test_isRetriable(t *testing.T) {
|
||||
assert.False(t, isRetriable(status.FromContextError(context.DeadlineExceeded).Err(), &options{codes: DefaultRetriableCodes}))
|
||||
assert.True(t, isRetriable(status.Error(codes.ResourceExhausted, ""), &options{codes: DefaultRetriableCodes}))
|
||||
assert.False(t, isRetriable(errors.New("error"), &options{}))
|
||||
}
|
||||
|
||||
func Test_perCallContext(t *testing.T) {
|
||||
opt := &options{perCallTimeout: time.Second, includeRetryHeader: true}
|
||||
ctx := metadata.NewIncomingContext(context.Background(), map[string][]string{"1": {"1"}})
|
||||
callContext := perCallContext(ctx, opt, 1)
|
||||
md, ok := metadata.FromOutgoingContext(callContext)
|
||||
assert.True(t, ok)
|
||||
assert.EqualValues(t, metadata.MD{"1": {"1"}, AttemptMetadataKey: {"1"}}, md)
|
||||
}
|
||||
|
||||
func Test_filterCallOptions(t *testing.T) {
|
||||
grpcEmptyCallOpt := &grpc.EmptyCallOption{}
|
||||
retryCallOpt := &CallOption{}
|
||||
options, retryCallOptions := filterCallOptions([]grpc.CallOption{
|
||||
grpcEmptyCallOpt,
|
||||
retryCallOpt,
|
||||
})
|
||||
assert.EqualValues(t, []grpc.CallOption{grpcEmptyCallOpt}, options)
|
||||
assert.EqualValues(t, []*CallOption{retryCallOpt}, retryCallOptions)
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
package retry
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/logx"
|
||||
"github.com/tal-tech/go-zero/core/retry/backoff"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
const AttemptMetadataKey = "x-retry-attempt"
|
||||
|
||||
var (
|
||||
// DefaultRetriableCodes default retry code
|
||||
DefaultRetriableCodes = []codes.Code{codes.ResourceExhausted, codes.Unavailable}
|
||||
// defaultRetryOptions default retry configuration
|
||||
defaultRetryOptions = &options{
|
||||
max: 0, // disabled
|
||||
perCallTimeout: 0, // disabled
|
||||
includeRetryHeader: true,
|
||||
codes: DefaultRetriableCodes,
|
||||
backoffFunc: backoff.LinearWithJitter(50*time.Millisecond /*jitter*/, 0.10),
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
// options retry the configuration
|
||||
options struct {
|
||||
max int
|
||||
perCallTimeout time.Duration
|
||||
includeRetryHeader bool
|
||||
codes []codes.Code
|
||||
backoffFunc backoff.Func
|
||||
}
|
||||
|
||||
// CallOption is a grpc.CallOption that is local to grpc retry.
|
||||
CallOption struct {
|
||||
grpc.EmptyCallOption // make sure we implement private after() and before() fields so we don't panic.
|
||||
apply func(opt *options)
|
||||
}
|
||||
)
|
||||
|
||||
func waitRetryBackoff(logger logx.Logger, attempt int, ctx context.Context, retryOptions *options) error {
|
||||
var waitTime time.Duration = 0
|
||||
if attempt > 0 {
|
||||
waitTime = retryOptions.backoffFunc(attempt)
|
||||
}
|
||||
if waitTime > 0 {
|
||||
timer := time.NewTimer(waitTime)
|
||||
defer timer.Stop()
|
||||
|
||||
logger.Infof("grpc retry attempt: %d, backoff for %v", attempt, waitTime)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return status.FromContextError(ctx.Err()).Err()
|
||||
case <-timer.C:
|
||||
// double check
|
||||
err := ctx.Err()
|
||||
if err != nil {
|
||||
return status.FromContextError(err).Err()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func isRetriable(err error, retryOptions *options) bool {
|
||||
errCode := status.Code(err)
|
||||
if isContextError(err) {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, code := range retryOptions.codes {
|
||||
if code == errCode {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func isContextError(err error) bool {
|
||||
code := status.Code(err)
|
||||
return code == codes.DeadlineExceeded || code == codes.Canceled
|
||||
}
|
||||
|
||||
func reuseOrNewWithCallOptions(opt *options, retryCallOptions []*CallOption) *options {
|
||||
if len(retryCallOptions) == 0 {
|
||||
return opt
|
||||
}
|
||||
|
||||
return parseRetryCallOptions(opt, retryCallOptions...)
|
||||
}
|
||||
|
||||
func parseRetryCallOptions(opt *options, opts ...*CallOption) *options {
|
||||
for _, option := range opts {
|
||||
option.apply(opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
func perCallContext(ctx context.Context, callOpts *options, attempt int) context.Context {
|
||||
if attempt > 0 {
|
||||
if callOpts.perCallTimeout != 0 {
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, callOpts.perCallTimeout)
|
||||
_ = cancel
|
||||
}
|
||||
if callOpts.includeRetryHeader {
|
||||
cloneMd := extractIncomingAndClone(ctx)
|
||||
cloneMd.Set(AttemptMetadataKey, strconv.Itoa(attempt))
|
||||
ctx = metadata.NewOutgoingContext(ctx, cloneMd)
|
||||
}
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
func extractIncomingAndClone(ctx context.Context) metadata.MD {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return metadata.MD{}
|
||||
}
|
||||
|
||||
return md.Copy()
|
||||
}
|
||||
|
||||
func filterCallOptions(callOptions []grpc.CallOption) (grpcOptions []grpc.CallOption, retryOptions []*CallOption) {
|
||||
for _, opt := range callOptions {
|
||||
if co, ok := opt.(*CallOption); ok {
|
||||
retryOptions = append(retryOptions, co)
|
||||
} else {
|
||||
grpcOptions = append(grpcOptions, opt)
|
||||
}
|
||||
}
|
||||
|
||||
return grpcOptions, retryOptions
|
||||
}
|
||||
|
||||
func Do(ctx context.Context, call func(ctx context.Context, opts ...grpc.CallOption) error, opts ...grpc.CallOption) error {
|
||||
logger := logx.WithContext(ctx)
|
||||
grpcOpts, retryOpts := filterCallOptions(opts)
|
||||
callOpts := reuseOrNewWithCallOptions(defaultRetryOptions, retryOpts)
|
||||
|
||||
if callOpts.max == 0 {
|
||||
return call(ctx, opts...)
|
||||
}
|
||||
|
||||
var lastErr error
|
||||
for attempt := 0; attempt <= callOpts.max; attempt++ {
|
||||
if err := waitRetryBackoff(logger, attempt, ctx, callOpts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
callCtx := perCallContext(ctx, callOpts, attempt)
|
||||
lastErr = call(callCtx, grpcOpts...)
|
||||
|
||||
if lastErr == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if attempt == 0 {
|
||||
logger.Errorf("grpc call failed, got err: %v", lastErr)
|
||||
} else {
|
||||
logger.Errorf("grpc retry attempt: %d, got err: %v", attempt, lastErr)
|
||||
}
|
||||
if isContextError(lastErr) {
|
||||
if ctx.Err() != nil {
|
||||
logger.Errorf("grpc retry attempt: %d, parent context error: %v", attempt, ctx.Err())
|
||||
return lastErr
|
||||
} else if callOpts.perCallTimeout != 0 {
|
||||
logger.Errorf("grpc retry attempt: %d, context error from retry call", attempt)
|
||||
continue
|
||||
}
|
||||
}
|
||||
if !isRetriable(lastErr, callOpts) {
|
||||
return lastErr
|
||||
}
|
||||
}
|
||||
|
||||
return lastErr
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package retry
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func TestDo(t *testing.T) {
|
||||
n := 4
|
||||
for i := 0; i < n; i++ {
|
||||
count := 0
|
||||
err := Do(context.Background(), func(ctx context.Context, opts ...grpc.CallOption) error {
|
||||
count++
|
||||
return status.Error(codes.ResourceExhausted, "ResourceExhausted")
|
||||
}, WithMax(i))
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, i+1, count)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package search
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tal-tech/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
type mockedRoute struct {
|
||||
@@ -139,11 +142,9 @@ func TestStrictSearchSibling(t *testing.T) {
|
||||
tree.Add(r.route, r.value)
|
||||
}
|
||||
|
||||
for i := 0; i < 1000; i++ {
|
||||
result, ok := tree.Search(query)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, 3, result.Item.(int))
|
||||
}
|
||||
result, ok := tree.Search(query)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, 3, result.Item.(int))
|
||||
}
|
||||
|
||||
func TestAddDuplicate(t *testing.T) {
|
||||
@@ -185,3 +186,41 @@ func TestSearchInvalidItem(t *testing.T) {
|
||||
err := tree.Add("/", nil)
|
||||
assert.Equal(t, errEmptyItem, err)
|
||||
}
|
||||
|
||||
func BenchmarkSearchTree(b *testing.B) {
|
||||
const (
|
||||
avgLen = 1000
|
||||
entries = 10000
|
||||
)
|
||||
|
||||
tree := NewTree()
|
||||
generate := func() string {
|
||||
var buf strings.Builder
|
||||
size := rand.Intn(avgLen) + avgLen/2
|
||||
val := stringx.Randn(size)
|
||||
prev := 0
|
||||
for j := rand.Intn(9) + 1; j < size; j += rand.Intn(9) + 1 {
|
||||
buf.WriteRune('/')
|
||||
buf.WriteString(val[prev:j])
|
||||
prev = j
|
||||
}
|
||||
if prev < size {
|
||||
buf.WriteRune('/')
|
||||
buf.WriteString(val[prev:])
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
index := rand.Intn(entries)
|
||||
var query string
|
||||
for i := 0; i < entries; i++ {
|
||||
val := generate()
|
||||
if i == index {
|
||||
query = val
|
||||
}
|
||||
tree.Add(val, i)
|
||||
}
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
tree.Search(query)
|
||||
}
|
||||
}
|
||||
|
||||
2
core/stores/cache/cachenode_test.go
vendored
2
core/stores/cache/cachenode_test.go
vendored
@@ -53,8 +53,8 @@ func TestCacheNode_DelCache(t *testing.T) {
|
||||
func TestCacheNode_DelCacheWithErrors(t *testing.T) {
|
||||
store, clean, err := redistest.CreateRedis()
|
||||
assert.Nil(t, err)
|
||||
defer clean()
|
||||
store.Type = redis.ClusterType
|
||||
clean()
|
||||
|
||||
cn := cacheNode{
|
||||
rds: store,
|
||||
|
||||
@@ -16,6 +16,8 @@ var ErrNoRedisNode = errors.New("no redis node")
|
||||
type (
|
||||
// Store interface represents a KV store.
|
||||
Store interface {
|
||||
Decr(key string) (int64, error)
|
||||
Decrby(key string, increment int64) (int64, error)
|
||||
Del(keys ...string) (int, error)
|
||||
Eval(script, key string, args ...interface{}) (interface{}, error)
|
||||
Exists(key string) (bool, error)
|
||||
@@ -36,6 +38,7 @@ type (
|
||||
Hvals(key string) ([]string, error)
|
||||
Incr(key string) (int64, error)
|
||||
Incrby(key string, increment int64) (int64, error)
|
||||
Lindex(key string, index int64) (string, error)
|
||||
Llen(key string) (int, error)
|
||||
Lpop(key string) (string, error)
|
||||
Lpush(key string, values ...interface{}) (int, error)
|
||||
@@ -102,6 +105,24 @@ func NewStore(c KvConf) Store {
|
||||
}
|
||||
}
|
||||
|
||||
func (cs clusterStore) Decr(key string) (int64, error) {
|
||||
node, err := cs.getRedis(key)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return node.Decr(key)
|
||||
}
|
||||
|
||||
func (cs clusterStore) Decrby(key string, increment int64) (int64, error) {
|
||||
node, err := cs.getRedis(key)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return node.Decrby(key, increment)
|
||||
}
|
||||
|
||||
func (cs clusterStore) Del(keys ...string) (int, error) {
|
||||
var val int
|
||||
var be errorx.BatchError
|
||||
@@ -303,6 +324,15 @@ func (cs clusterStore) Llen(key string) (int, error) {
|
||||
return node.Llen(key)
|
||||
}
|
||||
|
||||
func (cs clusterStore) Lindex(key string, index int64) (string, error) {
|
||||
node, err := cs.getRedis(key)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return node.Lindex(key, index)
|
||||
}
|
||||
|
||||
func (cs clusterStore) Lpop(key string) (string, error) {
|
||||
node, err := cs.getRedis(key)
|
||||
if err != nil {
|
||||
|
||||
@@ -17,6 +17,36 @@ var (
|
||||
s2, _ = miniredis.Run()
|
||||
)
|
||||
|
||||
func TestRedis_Decr(t *testing.T) {
|
||||
store := clusterStore{dispatcher: hash.NewConsistentHash()}
|
||||
_, err := store.Decr("a")
|
||||
assert.NotNil(t, err)
|
||||
|
||||
runOnCluster(t, func(client Store) {
|
||||
val, err := client.Decr("a")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, int64(-1), val)
|
||||
val, err = client.Decr("a")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, int64(-2), val)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRedis_DecrBy(t *testing.T) {
|
||||
store := clusterStore{dispatcher: hash.NewConsistentHash()}
|
||||
_, err := store.Incrby("a", 2)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
runOnCluster(t, func(client Store) {
|
||||
val, err := client.Decrby("a", 2)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, int64(-2), val)
|
||||
val, err = client.Decrby("a", 3)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, int64(-5), val)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRedis_Exists(t *testing.T) {
|
||||
store := clusterStore{dispatcher: hash.NewConsistentHash()}
|
||||
_, err := store.Exists("foo")
|
||||
@@ -234,6 +264,8 @@ func TestRedis_List(t *testing.T) {
|
||||
assert.NotNil(t, err)
|
||||
_, err = store.Lrem("key", 0, "val")
|
||||
assert.NotNil(t, err)
|
||||
_, err = store.Lindex("key", 0)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
runOnCluster(t, func(client Store) {
|
||||
val, err := client.Lpush("key", "value1", "value2")
|
||||
@@ -245,6 +277,9 @@ func TestRedis_List(t *testing.T) {
|
||||
val, err = client.Llen("key")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 4, val)
|
||||
value, err := client.Lindex("key", 0)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "value2", value)
|
||||
vals, err := client.Lrange("key", 0, 10)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualValues(t, []string{"value2", "value1", "value3", "value4"}, vals)
|
||||
|
||||
@@ -36,20 +36,23 @@ func MustNewModel(url, collection string, c cache.CacheConf, opts ...cache.Optio
|
||||
return model
|
||||
}
|
||||
|
||||
// NewNodeModel returns a Model with a cache node.
|
||||
func NewNodeModel(url, collection string, rds *redis.Redis, opts ...cache.Option) (*Model, error) {
|
||||
c := cache.NewNode(rds, sharedCalls, stats, mgo.ErrNotFound, opts...)
|
||||
// NewModel returns a Model with a cache cluster.
|
||||
func NewModel(url, collection string, conf cache.CacheConf, opts ...cache.Option) (*Model, error) {
|
||||
c := cache.New(conf, sharedCalls, stats, mgo.ErrNotFound, opts...)
|
||||
return NewModelWithCache(url, collection, c)
|
||||
}
|
||||
|
||||
// NewModelWithCache returns a Model with a custom cache.
|
||||
func NewModelWithCache(url, collection string, c cache.Cache) (*Model, error) {
|
||||
return createModel(url, collection, c, func(collection mongo.Collection) CachedCollection {
|
||||
return newCollection(collection, c)
|
||||
})
|
||||
}
|
||||
|
||||
// NewModel returns a Model with a cache cluster.
|
||||
func NewModel(url, collection string, conf cache.CacheConf, opts ...cache.Option) (*Model, error) {
|
||||
c := cache.New(conf, sharedCalls, stats, mgo.ErrNotFound, opts...)
|
||||
return createModel(url, collection, c, func(collection mongo.Collection) CachedCollection {
|
||||
return newCollection(collection, c)
|
||||
})
|
||||
// NewNodeModel returns a Model with a cache node.
|
||||
func NewNodeModel(url, collection string, rds *redis.Redis, opts ...cache.Option) (*Model, error) {
|
||||
c := cache.NewNode(rds, sharedCalls, stats, mgo.ErrNotFound, opts...)
|
||||
return NewModelWithCache(url, collection, c)
|
||||
}
|
||||
|
||||
// Count returns the count of given query.
|
||||
|
||||
@@ -238,6 +238,36 @@ func (s *Redis) BlpopEx(redisNode RedisNode, key string) (string, bool, error) {
|
||||
return vals[1], true, nil
|
||||
}
|
||||
|
||||
// Decr is the implementation of redis decr command.
|
||||
func (s *Redis) Decr(key string) (val int64, err error) {
|
||||
err = s.brk.DoWithAcceptable(func() error {
|
||||
conn, err := getRedis(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
val, err = conn.Decr(key).Result()
|
||||
return err
|
||||
}, acceptable)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Decrby is the implementation of redis decrby command.
|
||||
func (s *Redis) Decrby(key string, increment int64) (val int64, err error) {
|
||||
err = s.brk.DoWithAcceptable(func() error {
|
||||
conn, err := getRedis(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
val, err = conn.DecrBy(key, increment).Result()
|
||||
return err
|
||||
}, acceptable)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Del deletes keys.
|
||||
func (s *Redis) Del(keys ...string) (val int, err error) {
|
||||
err = s.brk.DoWithAcceptable(func() error {
|
||||
@@ -765,6 +795,21 @@ func (s *Redis) Llen(key string) (val int, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Lindex is the implementation of redis lindex command.
|
||||
func (s *Redis) Lindex(key string, index int64) (val string, err error) {
|
||||
err = s.brk.DoWithAcceptable(func() error {
|
||||
conn, err := getRedis(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
val, err = conn.LIndex(key, index).Result()
|
||||
return err
|
||||
}, acceptable)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Lpop is the implementation of redis lpop command.
|
||||
func (s *Redis) Lpop(key string) (val string, err error) {
|
||||
err = s.brk.DoWithAcceptable(func() error {
|
||||
|
||||
@@ -14,6 +14,32 @@ import (
|
||||
"github.com/tal-tech/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
func TestRedis_Decr(t *testing.T) {
|
||||
runOnRedis(t, func(client *Redis) {
|
||||
_, err := New(client.Addr, badType()).Decr("a")
|
||||
assert.NotNil(t, err)
|
||||
val, err := client.Decr("a")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, int64(-1), val)
|
||||
val, err = client.Decr("a")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, int64(-2), val)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRedis_DecrBy(t *testing.T) {
|
||||
runOnRedis(t, func(client *Redis) {
|
||||
_, err := New(client.Addr, badType()).Decrby("a", 2)
|
||||
assert.NotNil(t, err)
|
||||
val, err := client.Decrby("a", 2)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, int64(-2), val)
|
||||
val, err = client.Decrby("a", 3)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, int64(-5), val)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRedis_Exists(t *testing.T) {
|
||||
runOnRedis(t, func(client *Redis) {
|
||||
_, err := New(client.Addr, badType()).Exists("a")
|
||||
@@ -295,6 +321,11 @@ func TestRedis_List(t *testing.T) {
|
||||
val, err = client.Llen("key")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 4, val)
|
||||
_, err = New(client.Addr, badType()).Lindex("key", 1)
|
||||
assert.NotNil(t, err)
|
||||
value, err := client.Lindex("key", 0)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "value2", value)
|
||||
vals, err := client.Lrange("key", 0, 10)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualValues(t, []string{"value2", "value1", "value3", "value4"}, vals)
|
||||
|
||||
@@ -2,7 +2,6 @@ package redis
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@@ -12,26 +11,19 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
lockCommand = `if redis.call("GET", KEYS[1]) == ARGV[1] then
|
||||
redis.call("SET", KEYS[1], ARGV[1], "PX", ARGV[2])
|
||||
return "OK"
|
||||
else
|
||||
return redis.call("SET", KEYS[1], ARGV[1], "NX", "PX", ARGV[2])
|
||||
end`
|
||||
delCommand = `if redis.call("GET", KEYS[1]) == ARGV[1] then
|
||||
return redis.call("DEL", KEYS[1])
|
||||
else
|
||||
return 0
|
||||
end`
|
||||
randomLen = 16
|
||||
tolerance = 500 // milliseconds
|
||||
millisPerSecond = 1000
|
||||
randomLen = 16
|
||||
)
|
||||
|
||||
// A RedisLock is a redis lock.
|
||||
type RedisLock struct {
|
||||
store *Redis
|
||||
seconds uint32
|
||||
count int32
|
||||
key string
|
||||
id string
|
||||
}
|
||||
@@ -51,30 +43,35 @@ func NewRedisLock(store *Redis, key string) *RedisLock {
|
||||
|
||||
// Acquire acquires the lock.
|
||||
func (rl *RedisLock) Acquire() (bool, error) {
|
||||
seconds := atomic.LoadUint32(&rl.seconds)
|
||||
resp, err := rl.store.Eval(lockCommand, []string{rl.key}, []string{
|
||||
rl.id, strconv.Itoa(int(seconds)*millisPerSecond + tolerance),
|
||||
})
|
||||
if err == red.Nil {
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
logx.Errorf("Error on acquiring lock for %s, %s", rl.key, err.Error())
|
||||
return false, err
|
||||
} else if resp == nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
reply, ok := resp.(string)
|
||||
if ok && reply == "OK" {
|
||||
newCount := atomic.AddInt32(&rl.count, 1)
|
||||
if newCount > 1 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
logx.Errorf("Unknown reply when acquiring lock for %s: %v", rl.key, resp)
|
||||
return false, nil
|
||||
seconds := atomic.LoadUint32(&rl.seconds)
|
||||
ok, err := rl.store.SetnxEx(rl.key, rl.id, int(seconds+1)) // +1s for tolerance
|
||||
if err == red.Nil {
|
||||
atomic.AddInt32(&rl.count, -1)
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
atomic.AddInt32(&rl.count, -1)
|
||||
logx.Errorf("Error on acquiring lock for %s, %s", rl.key, err.Error())
|
||||
return false, err
|
||||
} else if !ok {
|
||||
atomic.AddInt32(&rl.count, -1)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Release releases the lock.
|
||||
func (rl *RedisLock) Release() (bool, error) {
|
||||
newCount := atomic.AddInt32(&rl.count, -1)
|
||||
if newCount > 0 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
resp, err := rl.store.Eval(delCommand, []string{rl.key}, []string{rl.id})
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -88,7 +85,7 @@ func (rl *RedisLock) Release() (bool, error) {
|
||||
return reply == 1, nil
|
||||
}
|
||||
|
||||
// SetExpire sets the expire.
|
||||
// SetExpire sets the expiration.
|
||||
func (rl *RedisLock) SetExpire(seconds int) {
|
||||
atomic.StoreUint32(&rl.seconds, uint32(seconds))
|
||||
}
|
||||
|
||||
@@ -29,5 +29,25 @@ func TestRedisLock(t *testing.T) {
|
||||
endAcquire, err := secondLock.Acquire()
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, endAcquire)
|
||||
|
||||
endAcquire, err = secondLock.Acquire()
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, endAcquire)
|
||||
|
||||
release, err = secondLock.Release()
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, release)
|
||||
|
||||
againAcquire, err = firstLock.Acquire()
|
||||
assert.Nil(t, err)
|
||||
assert.False(t, againAcquire)
|
||||
|
||||
release, err = secondLock.Release()
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, release)
|
||||
|
||||
firstAcquire, err = firstLock.Acquire()
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, firstAcquire)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -39,20 +39,24 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// NewNodeConn returns a CachedConn with a redis node cache.
|
||||
func NewNodeConn(db sqlx.SqlConn, rds *redis.Redis, opts ...cache.Option) CachedConn {
|
||||
// NewConn returns a CachedConn with a redis cluster cache.
|
||||
func NewConn(db sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) CachedConn {
|
||||
cc := cache.New(c, exclusiveCalls, stats, sql.ErrNoRows, opts...)
|
||||
return NewConnWithCache(db, cc)
|
||||
}
|
||||
|
||||
// NewConnWithCache returns a CachedConn with a custom cache.
|
||||
func NewConnWithCache(db sqlx.SqlConn, c cache.Cache) CachedConn {
|
||||
return CachedConn{
|
||||
db: db,
|
||||
cache: cache.NewNode(rds, exclusiveCalls, stats, sql.ErrNoRows, opts...),
|
||||
cache: c,
|
||||
}
|
||||
}
|
||||
|
||||
// NewConn returns a CachedConn with a redis cluster cache.
|
||||
func NewConn(db sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) CachedConn {
|
||||
return CachedConn{
|
||||
db: db,
|
||||
cache: cache.New(c, exclusiveCalls, stats, sql.ErrNoRows, opts...),
|
||||
}
|
||||
// NewNodeConn returns a CachedConn with a redis node cache.
|
||||
func NewNodeConn(db sqlx.SqlConn, rds *redis.Redis, opts ...cache.Option) CachedConn {
|
||||
c := cache.NewNode(rds, exclusiveCalls, stats, sql.ErrNoRows, opts...)
|
||||
return NewConnWithCache(db, c)
|
||||
}
|
||||
|
||||
// DelCache deletes cache with keys.
|
||||
|
||||
@@ -562,6 +562,18 @@ func TestQueryRowNoCache(t *testing.T) {
|
||||
assert.True(t, ran)
|
||||
}
|
||||
|
||||
func TestNewConnWithCache(t *testing.T) {
|
||||
r, clean, err := redistest.CreateRedis()
|
||||
assert.Nil(t, err)
|
||||
defer clean()
|
||||
|
||||
var conn trackedConn
|
||||
c := NewConnWithCache(&conn, cache.NewNode(r, exclusiveCalls, stats, sql.ErrNoRows))
|
||||
_, err = c.ExecNoCache("delete from user_table where id='kevin'")
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, conn.execValue)
|
||||
}
|
||||
|
||||
func resetStats() {
|
||||
atomic.StoreUint64(&stats.Total, 0)
|
||||
atomic.StoreUint64(&stats.Hit, 0)
|
||||
|
||||
@@ -25,6 +25,7 @@ type (
|
||||
SqlConn interface {
|
||||
Session
|
||||
// RawDB is for other ORM to operate with, use it with caution.
|
||||
// Notice: don't close it.
|
||||
RawDB() (*sql.DB, error)
|
||||
Transact(func(session Session) error) error
|
||||
}
|
||||
|
||||
8
go.mod
8
go.mod
@@ -6,29 +6,21 @@ require (
|
||||
github.com/ClickHouse/clickhouse-go v1.5.1
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0
|
||||
github.com/alicebob/miniredis/v2 v2.16.0
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
|
||||
github.com/emicklei/proto v1.9.1
|
||||
github.com/fatih/color v1.9.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0
|
||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
|
||||
github.com/go-redis/redis v6.15.9+incompatible
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
github.com/golang-jwt/jwt v3.2.1+incompatible
|
||||
github.com/golang/mock v1.6.0
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/iancoleman/strcase v0.2.0
|
||||
github.com/justinas/alice v1.2.0
|
||||
github.com/lib/pq v1.10.3
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible
|
||||
github.com/mattn/go-colorable v0.1.6 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/openzipkin/zipkin-go v0.3.0 // indirect
|
||||
github.com/prometheus/client_golang v1.11.0
|
||||
github.com/spaolacci/murmur3 v1.1.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/urfave/cli v1.22.5
|
||||
github.com/zeromicro/antlr v0.0.1
|
||||
github.com/zeromicro/ddl-parser v0.0.0-20210712021150-63520aca7348
|
||||
go.etcd.io/etcd/api/v3 v3.5.1
|
||||
go.etcd.io/etcd/client/v3 v3.5.1
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
|
||||
20
go.sum
20
go.sum
@@ -54,8 +54,6 @@ github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGn
|
||||
github.com/alicebob/miniredis/v2 v2.16.0 h1:ALkyFg7bSTEd1Mkrb4ppq4fnwjklA59dVtIehXCUZkU=
|
||||
github.com/alicebob/miniredis/v2 v2.16.0/go.mod h1:gquAfGbzn92jvtrSC69+6zZnwSODVXVpYDRaGhWaL6I=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec h1:EEyRvzmpEUZ+I8WmD5cw/vY8EqhambkOqy5iFr0908A=
|
||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
|
||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
@@ -86,8 +84,6 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
|
||||
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
|
||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@@ -102,8 +98,6 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emicklei/proto v1.9.1 h1:MUgjFo5xlMwYv72TnF5xmmdKZ04u+dVbv6wdARv16D8=
|
||||
github.com/emicklei/proto v1.9.1/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
@@ -115,8 +109,6 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
|
||||
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
|
||||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
||||
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
|
||||
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
|
||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY=
|
||||
@@ -235,8 +227,6 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
||||
github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
|
||||
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
|
||||
@@ -275,8 +265,6 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
|
||||
github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
@@ -364,8 +352,6 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqn
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
@@ -390,8 +376,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
|
||||
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
|
||||
@@ -401,10 +385,6 @@ 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/gopher-lua v0.0.0-20200816102855-ee81675732da h1:NimzV1aGyq29m5ukMK0AMWEhFaL/lrEOaephfuoiARg=
|
||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
|
||||
github.com/zeromicro/antlr v0.0.1 h1:CQpIn/dc0pUjgGQ81y98s/NGOm2Hfru2NNio2I9mQgk=
|
||||
github.com/zeromicro/antlr v0.0.1/go.mod h1:nfpjEwFR6Q4xGDJMcZnCL9tEfQRgszMwu3rDz2Z+p5M=
|
||||
github.com/zeromicro/ddl-parser v0.0.0-20210712021150-63520aca7348 h1:OhxL9tn28gDeJVzreIUiE5oVxZCjL3tBJ0XBNw8p5R8=
|
||||
github.com/zeromicro/ddl-parser v0.0.0-20210712021150-63520aca7348/go.mod h1:ISU/8NuPyEpl9pa17Py9TBPetMjtsiHrb9f5XGiYbo8=
|
||||
go.etcd.io/etcd/api/v3 v3.5.1 h1:v28cktvBq+7vGyJXF8G+rWJmj+1XUmMtqcLnH8hDocM=
|
||||
go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.1 h1:XIQcHCFSG53bJETYeRJtIxdLv2EWRGxcfzR8lSnTH4E=
|
||||
|
||||
@@ -104,10 +104,10 @@ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/
|
||||
|
||||
```shell
|
||||
# Go 1.15 及之前版本
|
||||
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
|
||||
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl@cli
|
||||
|
||||
# Go 1.16 及以后版本
|
||||
go install github.com/tal-tech/go-zero/tools/goctl@latest
|
||||
GOPROXY=https://goproxy.cn/,direct go install github.com/tal-tech/go-zero/tools/goctl@cli
|
||||
```
|
||||
|
||||
确保 goctl 可执行
|
||||
@@ -141,7 +141,7 @@ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/
|
||||
|
||||
编写业务代码:
|
||||
|
||||
* api 文件定义了服务对外 HTTP 接口,可参考 [api 规范](https://github.com/zeromicro/zero-doc/blob/main/doc/goctl.md)
|
||||
* api 文件定义了服务对外 HTTP 接口,可参考 [api 规范](https://github.com/zeromicro/zero-doc/blob/main/docs/zero/goctl-api.md)
|
||||
* 可以在 `servicecontext.go` 里面传递依赖给 logic,比如 mysql, redis 等
|
||||
* 在 api 定义的 `get/post/put/delete` 等请求对应的 logic 里增加业务处理逻辑
|
||||
|
||||
@@ -232,6 +232,9 @@ go-zero 已被许多公司用于生产部署,接入场景如在线教育、电
|
||||
>46. 上海游族网络
|
||||
>47. 深信服
|
||||
>48. 中免日上科技互联有限公司
|
||||
>48. ECLOUDVALLEY TECHNOLOGY (HK) LIMITED
|
||||
>48. 馨科智(深圳)科技有限公司
|
||||
>48. 成都松珀科技有限公司
|
||||
|
||||
如果贵公司也已使用 go-zero,欢迎在 [登记地址](https://github.com/zeromicro/go-zero/issues/602) 登记,仅仅为了推广,不做其它用途。
|
||||
|
||||
|
||||
@@ -107,10 +107,10 @@ go get -u github.com/tal-tech/go-zero
|
||||
|
||||
```shell
|
||||
# for Go 1.15 and earlier
|
||||
GO111MODULE=on go get -u github.com/tal-tech/go-zero/tools/goctl
|
||||
GO111MODULE=on go get -u github.com/tal-tech/go-zero/tools/goctl@cli
|
||||
|
||||
# for Go 1.16 and later
|
||||
go install github.com/tal-tech/go-zero/tools/goctl@latest
|
||||
go install github.com/tal-tech/go-zero/tools/goctl@cli
|
||||
```
|
||||
|
||||
make sure goctl is executable.
|
||||
@@ -221,7 +221,7 @@ go get -u github.com/tal-tech/go-zero
|
||||
|
||||
## 9. Chat group
|
||||
|
||||
Join the chat via https://join.slack.com/t/go-zero/shared_invite/zt-ulzixfgi-NAkZjq856TewLY2KQSxHCw
|
||||
Join the chat via https://join.slack.com/t/go-zero/shared_invite/zt-10ruju779-BE4y6lQNB_R21samtyKTgA
|
||||
|
||||
## 10. Cloud Native Landscape
|
||||
|
||||
|
||||
@@ -196,12 +196,13 @@ func logDetails(r *http.Request, response *detailLoggedResponseWriter, timer *ut
|
||||
logs *internal.LogCollector) {
|
||||
var buf bytes.Buffer
|
||||
duration := timer.Duration()
|
||||
code := response.writer.code
|
||||
logger := logx.WithContext(r.Context())
|
||||
buf.WriteString(fmt.Sprintf("[HTTP] %s - %d - %s - %s\n=> %s\n",
|
||||
r.Method, response.writer.code, r.RemoteAddr, timex.ReprOfDuration(duration), dumpRequest(r)))
|
||||
r.Method, code, r.RemoteAddr, timex.ReprOfDuration(duration), dumpRequest(r)))
|
||||
if duration > defaultSlowThreshold {
|
||||
logger.Slowf("[HTTP] %s - %d - %s - slowcall(%s)\n=> %s\n",
|
||||
r.Method, response.writer.code, r.RemoteAddr, timex.ReprOfDuration(duration), dumpRequest(r))
|
||||
r.Method, code, r.RemoteAddr, timex.ReprOfDuration(duration), dumpRequest(r))
|
||||
}
|
||||
|
||||
body := logs.Flush()
|
||||
@@ -214,7 +215,11 @@ func logDetails(r *http.Request, response *detailLoggedResponseWriter, timer *ut
|
||||
buf.WriteString(fmt.Sprintf("<= %s", respBuf))
|
||||
}
|
||||
|
||||
logger.Info(buf.String())
|
||||
if isOkResponse(code) {
|
||||
logger.Info(buf.String())
|
||||
} else {
|
||||
logger.Error(buf.String())
|
||||
}
|
||||
}
|
||||
|
||||
func isOkResponse(code int) bool {
|
||||
|
||||
@@ -1,19 +1,192 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"path"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/tal-tech/go-zero/rest/httpx"
|
||||
"github.com/tal-tech/go-zero/rest/internal"
|
||||
)
|
||||
|
||||
const reason = "Request Timeout"
|
||||
const (
|
||||
statusClientClosedRequest = 499
|
||||
reason = "Request Timeout"
|
||||
)
|
||||
|
||||
// TimeoutHandler returns the handler with given timeout.
|
||||
// If client closed request, code 499 will be logged.
|
||||
// Notice: even if canceled in server side, 499 will be logged as well.
|
||||
func TimeoutHandler(duration time.Duration) func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
if duration > 0 {
|
||||
return http.TimeoutHandler(next, duration, reason)
|
||||
return &timeoutHandler{
|
||||
handler: next,
|
||||
dt: duration,
|
||||
}
|
||||
}
|
||||
|
||||
return next
|
||||
}
|
||||
}
|
||||
|
||||
// timeoutHandler is the handler that controls the request timeout.
|
||||
// Why we implement it on our own, because the stdlib implementation
|
||||
// treats the ClientClosedRequest as http.StatusServiceUnavailable.
|
||||
// And we write the codes in logs as code 499, which is defined by nginx.
|
||||
type timeoutHandler struct {
|
||||
handler http.Handler
|
||||
dt time.Duration
|
||||
}
|
||||
|
||||
func (h *timeoutHandler) errorBody() string {
|
||||
return reason
|
||||
}
|
||||
|
||||
func (h *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, cancelCtx := context.WithTimeout(r.Context(), h.dt)
|
||||
defer cancelCtx()
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
done := make(chan struct{})
|
||||
tw := &timeoutWriter{
|
||||
w: w,
|
||||
h: make(http.Header),
|
||||
req: r,
|
||||
}
|
||||
panicChan := make(chan interface{}, 1)
|
||||
go func() {
|
||||
defer func() {
|
||||
if p := recover(); p != nil {
|
||||
panicChan <- p
|
||||
}
|
||||
}()
|
||||
h.handler.ServeHTTP(tw, r)
|
||||
close(done)
|
||||
}()
|
||||
select {
|
||||
case p := <-panicChan:
|
||||
panic(p)
|
||||
case <-done:
|
||||
tw.mu.Lock()
|
||||
defer tw.mu.Unlock()
|
||||
dst := w.Header()
|
||||
for k, vv := range tw.h {
|
||||
dst[k] = vv
|
||||
}
|
||||
if !tw.wroteHeader {
|
||||
tw.code = http.StatusOK
|
||||
}
|
||||
w.WriteHeader(tw.code)
|
||||
w.Write(tw.wbuf.Bytes())
|
||||
case <-ctx.Done():
|
||||
tw.mu.Lock()
|
||||
defer tw.mu.Unlock()
|
||||
// there isn't any user-defined middleware before TimoutHandler,
|
||||
// so we can guarantee that cancelation in biz related code won't come here.
|
||||
httpx.Error(w, ctx.Err(), func(w http.ResponseWriter, err error) {
|
||||
if errors.Is(err, context.Canceled) {
|
||||
w.WriteHeader(statusClientClosedRequest)
|
||||
} else {
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
}
|
||||
io.WriteString(w, h.errorBody())
|
||||
})
|
||||
tw.timedOut = true
|
||||
}
|
||||
}
|
||||
|
||||
type timeoutWriter struct {
|
||||
w http.ResponseWriter
|
||||
h http.Header
|
||||
wbuf bytes.Buffer
|
||||
req *http.Request
|
||||
|
||||
mu sync.Mutex
|
||||
timedOut bool
|
||||
wroteHeader bool
|
||||
code int
|
||||
}
|
||||
|
||||
var _ http.Pusher = (*timeoutWriter)(nil)
|
||||
|
||||
// Push implements the Pusher interface.
|
||||
func (tw *timeoutWriter) Push(target string, opts *http.PushOptions) error {
|
||||
if pusher, ok := tw.w.(http.Pusher); ok {
|
||||
return pusher.Push(target, opts)
|
||||
}
|
||||
return http.ErrNotSupported
|
||||
}
|
||||
|
||||
func (tw *timeoutWriter) Header() http.Header { return tw.h }
|
||||
|
||||
func (tw *timeoutWriter) Write(p []byte) (int, error) {
|
||||
tw.mu.Lock()
|
||||
defer tw.mu.Unlock()
|
||||
|
||||
if tw.timedOut {
|
||||
return 0, http.ErrHandlerTimeout
|
||||
}
|
||||
|
||||
if !tw.wroteHeader {
|
||||
tw.writeHeaderLocked(http.StatusOK)
|
||||
}
|
||||
return tw.wbuf.Write(p)
|
||||
}
|
||||
|
||||
func (tw *timeoutWriter) writeHeaderLocked(code int) {
|
||||
checkWriteHeaderCode(code)
|
||||
|
||||
switch {
|
||||
case tw.timedOut:
|
||||
return
|
||||
case tw.wroteHeader:
|
||||
if tw.req != nil {
|
||||
caller := relevantCaller()
|
||||
internal.Errorf(tw.req, "http: superfluous response.WriteHeader call from %s (%s:%d)",
|
||||
caller.Function, path.Base(caller.File), caller.Line)
|
||||
}
|
||||
default:
|
||||
tw.wroteHeader = true
|
||||
tw.code = code
|
||||
}
|
||||
}
|
||||
|
||||
func (tw *timeoutWriter) WriteHeader(code int) {
|
||||
tw.mu.Lock()
|
||||
defer tw.mu.Unlock()
|
||||
tw.writeHeaderLocked(code)
|
||||
}
|
||||
|
||||
func checkWriteHeaderCode(code int) {
|
||||
if code < 100 || code > 599 {
|
||||
panic(fmt.Sprintf("invalid WriteHeader code %v", code))
|
||||
}
|
||||
}
|
||||
|
||||
// relevantCaller searches the call stack for the first function outside of net/http.
|
||||
// The purpose of this function is to provide more helpful error messages.
|
||||
func relevantCaller() runtime.Frame {
|
||||
pc := make([]uintptr, 16)
|
||||
n := runtime.Callers(1, pc)
|
||||
frames := runtime.CallersFrames(pc[:n])
|
||||
var frame runtime.Frame
|
||||
for {
|
||||
frame, more := frames.Next()
|
||||
if !strings.HasPrefix(frame.Function, "net/http.") {
|
||||
return frame
|
||||
}
|
||||
if !more {
|
||||
break
|
||||
}
|
||||
}
|
||||
return frame
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -39,6 +40,20 @@ func TestWithinTimeout(t *testing.T) {
|
||||
assert.Equal(t, http.StatusOK, resp.Code)
|
||||
}
|
||||
|
||||
func TestWithTimeoutTimedout(t *testing.T) {
|
||||
timeoutHandler := TimeoutHandler(time.Millisecond)
|
||||
handler := timeoutHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
time.Sleep(time.Millisecond * 10)
|
||||
w.Write([]byte(`foo`))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "http://localhost", nil)
|
||||
resp := httptest.NewRecorder()
|
||||
handler.ServeHTTP(resp, req)
|
||||
assert.Equal(t, http.StatusServiceUnavailable, resp.Code)
|
||||
}
|
||||
|
||||
func TestWithoutTimeout(t *testing.T) {
|
||||
timeoutHandler := TimeoutHandler(0)
|
||||
handler := timeoutHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -50,3 +65,91 @@ func TestWithoutTimeout(t *testing.T) {
|
||||
handler.ServeHTTP(resp, req)
|
||||
assert.Equal(t, http.StatusOK, resp.Code)
|
||||
}
|
||||
|
||||
func TestTimeoutPanic(t *testing.T) {
|
||||
timeoutHandler := TimeoutHandler(time.Minute)
|
||||
handler := timeoutHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
panic("foo")
|
||||
}))
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "http://localhost", nil)
|
||||
resp := httptest.NewRecorder()
|
||||
assert.Panics(t, func() {
|
||||
handler.ServeHTTP(resp, req)
|
||||
})
|
||||
}
|
||||
|
||||
func TestTimeoutWroteHeaderTwice(t *testing.T) {
|
||||
timeoutHandler := TimeoutHandler(time.Minute)
|
||||
handler := timeoutHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte(`hello`))
|
||||
w.Header().Set("foo", "bar")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "http://localhost", nil)
|
||||
resp := httptest.NewRecorder()
|
||||
handler.ServeHTTP(resp, req)
|
||||
assert.Equal(t, http.StatusOK, resp.Code)
|
||||
}
|
||||
|
||||
func TestTimeoutWriteBadCode(t *testing.T) {
|
||||
timeoutHandler := TimeoutHandler(time.Minute)
|
||||
handler := timeoutHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(1000)
|
||||
}))
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "http://localhost", nil)
|
||||
resp := httptest.NewRecorder()
|
||||
assert.Panics(t, func() {
|
||||
handler.ServeHTTP(resp, req)
|
||||
})
|
||||
}
|
||||
|
||||
func TestTimeoutClientClosed(t *testing.T) {
|
||||
timeoutHandler := TimeoutHandler(time.Minute)
|
||||
handler := timeoutHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(1000)
|
||||
}))
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "http://localhost", nil)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
req = req.WithContext(ctx)
|
||||
cancel()
|
||||
resp := httptest.NewRecorder()
|
||||
handler.ServeHTTP(resp, req)
|
||||
assert.Equal(t, statusClientClosedRequest, resp.Code)
|
||||
}
|
||||
|
||||
func TestTimeoutPusher(t *testing.T) {
|
||||
handler := &timeoutWriter{
|
||||
w: mockedPusher{},
|
||||
}
|
||||
|
||||
assert.Panics(t, func() {
|
||||
handler.Push("any", nil)
|
||||
})
|
||||
|
||||
handler = &timeoutWriter{
|
||||
w: httptest.NewRecorder(),
|
||||
}
|
||||
assert.Equal(t, http.ErrNotSupported, handler.Push("any", nil))
|
||||
}
|
||||
|
||||
type mockedPusher struct{}
|
||||
|
||||
func (m mockedPusher) Header() http.Header {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (m mockedPusher) Write(bytes []byte) (int, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (m mockedPusher) WriteHeader(statusCode int) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (m mockedPusher) Push(target string, opts *http.PushOptions) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ const (
|
||||
formKey = "form"
|
||||
pathKey = "path"
|
||||
headerKey = "header"
|
||||
emptyJson = "{}"
|
||||
maxMemory = 32 << 20 // 32MB
|
||||
maxBodyLen = 8 << 20 // 8MB
|
||||
separator = ";"
|
||||
@@ -106,14 +105,12 @@ func ParseHeader(headerValue string) map[string]string {
|
||||
|
||||
// ParseJsonBody parses the post request which contains json in body.
|
||||
func ParseJsonBody(r *http.Request, v interface{}) error {
|
||||
var reader io.Reader
|
||||
if withJsonBody(r) {
|
||||
reader = io.LimitReader(r.Body, maxBodyLen)
|
||||
} else {
|
||||
reader = strings.NewReader(emptyJson)
|
||||
reader := io.LimitReader(r.Body, maxBodyLen)
|
||||
return mapping.UnmarshalJsonReader(reader, v)
|
||||
}
|
||||
|
||||
return mapping.UnmarshalJsonReader(reader, v)
|
||||
return mapping.UnmarshalJsonMap(nil, v)
|
||||
}
|
||||
|
||||
// ParsePath parses the symbols reside in url path.
|
||||
|
||||
@@ -196,18 +196,32 @@ Content-Disposition: form-data; name="age"
|
||||
}
|
||||
|
||||
func TestParseJsonBody(t *testing.T) {
|
||||
var v struct {
|
||||
Name string `json:"name"`
|
||||
Age int `json:"age"`
|
||||
}
|
||||
t.Run("has body", func(t *testing.T) {
|
||||
var v struct {
|
||||
Name string `json:"name"`
|
||||
Age int `json:"age"`
|
||||
}
|
||||
|
||||
body := `{"name":"kevin", "age": 18}`
|
||||
r := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(body))
|
||||
r.Header.Set(ContentType, ApplicationJson)
|
||||
body := `{"name":"kevin", "age": 18}`
|
||||
r := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(body))
|
||||
r.Header.Set(ContentType, ApplicationJson)
|
||||
|
||||
assert.Nil(t, Parse(r, &v))
|
||||
assert.Equal(t, "kevin", v.Name)
|
||||
assert.Equal(t, 18, v.Age)
|
||||
assert.Nil(t, Parse(r, &v))
|
||||
assert.Equal(t, "kevin", v.Name)
|
||||
assert.Equal(t, 18, v.Age)
|
||||
})
|
||||
|
||||
t.Run("hasn't body", func(t *testing.T) {
|
||||
var v struct {
|
||||
Name string `json:"name,optional"`
|
||||
Age int `json:"age,optional"`
|
||||
}
|
||||
|
||||
r := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||
assert.Nil(t, Parse(r, &v))
|
||||
assert.Equal(t, "", v.Name)
|
||||
assert.Equal(t, 0, v.Age)
|
||||
})
|
||||
}
|
||||
|
||||
func TestParseRequired(t *testing.T) {
|
||||
|
||||
@@ -14,13 +14,17 @@ var (
|
||||
)
|
||||
|
||||
// Error writes err into w.
|
||||
func Error(w http.ResponseWriter, err error) {
|
||||
func Error(w http.ResponseWriter, err error, fns ...func(w http.ResponseWriter, err error)) {
|
||||
lock.RLock()
|
||||
handler := errorHandler
|
||||
lock.RUnlock()
|
||||
|
||||
if handler == nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
if len(fns) > 0 {
|
||||
fns[0](w, err)
|
||||
} else {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,18 @@ func TestError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorWithHandler(t *testing.T) {
|
||||
w := tracedResponseWriter{
|
||||
headers: make(map[string][]string),
|
||||
}
|
||||
Error(&w, errors.New("foo"), func(w http.ResponseWriter, err error) {
|
||||
http.Error(w, err.Error(), 499)
|
||||
})
|
||||
assert.Equal(t, 499, w.code)
|
||||
assert.True(t, w.hasBody)
|
||||
assert.Equal(t, "foo", strings.TrimSpace(w.builder.String()))
|
||||
}
|
||||
|
||||
func TestOk(t *testing.T) {
|
||||
w := tracedResponseWriter{
|
||||
headers: make(map[string][]string),
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package cors
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
allowOrigin = "Access-Control-Allow-Origin"
|
||||
@@ -23,23 +28,30 @@ const (
|
||||
|
||||
// NotAllowedHandler handles cross domain not allowed requests.
|
||||
// At most one origin can be specified, other origins are ignored if given, default to be *.
|
||||
func NotAllowedHandler(origins ...string) http.Handler {
|
||||
func NotAllowedHandler(fn func(w http.ResponseWriter), origins ...string) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
checkAndSetHeaders(w, r, origins)
|
||||
gw := &guardedResponseWriter{w: w}
|
||||
checkAndSetHeaders(gw, r, origins)
|
||||
if fn != nil {
|
||||
fn(gw)
|
||||
}
|
||||
|
||||
if r.Method != http.MethodOptions {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
if r.Method == http.MethodOptions {
|
||||
gw.WriteHeader(http.StatusNoContent)
|
||||
} else {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
gw.WriteHeader(http.StatusNotFound)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Middleware returns a middleware that adds CORS headers to the response.
|
||||
func Middleware(origins ...string) func(http.HandlerFunc) http.HandlerFunc {
|
||||
func Middleware(fn func(w http.Header), origins ...string) func(http.HandlerFunc) http.HandlerFunc {
|
||||
return func(next http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
checkAndSetHeaders(w, r, origins)
|
||||
if fn != nil {
|
||||
fn(w.Header())
|
||||
}
|
||||
|
||||
if r.Method == http.MethodOptions {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
@@ -50,6 +62,44 @@ func Middleware(origins ...string) func(http.HandlerFunc) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
type guardedResponseWriter struct {
|
||||
w http.ResponseWriter
|
||||
wroteHeader bool
|
||||
}
|
||||
|
||||
func (w *guardedResponseWriter) Flush() {
|
||||
if flusher, ok := w.w.(http.Flusher); ok {
|
||||
flusher.Flush()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *guardedResponseWriter) Header() http.Header {
|
||||
return w.w.Header()
|
||||
}
|
||||
|
||||
// Hijack implements the http.Hijacker interface.
|
||||
// This expands the Response to fulfill http.Hijacker if the underlying http.ResponseWriter supports it.
|
||||
func (w *guardedResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
if hijacked, ok := w.w.(http.Hijacker); ok {
|
||||
return hijacked.Hijack()
|
||||
}
|
||||
|
||||
return nil, nil, errors.New("server doesn't support hijacking")
|
||||
}
|
||||
|
||||
func (w *guardedResponseWriter) Write(bytes []byte) (int, error) {
|
||||
return w.w.Write(bytes)
|
||||
}
|
||||
|
||||
func (w *guardedResponseWriter) WriteHeader(code int) {
|
||||
if w.wroteHeader {
|
||||
return
|
||||
}
|
||||
|
||||
w.w.WriteHeader(code)
|
||||
w.wroteHeader = true
|
||||
}
|
||||
|
||||
func checkAndSetHeaders(w http.ResponseWriter, r *http.Request, origins []string) {
|
||||
setVaryHeaders(w, r)
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package cors
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
@@ -62,7 +64,7 @@ func TestCorsHandlerWithOrigins(t *testing.T) {
|
||||
r := httptest.NewRequest(method, "http://localhost", nil)
|
||||
r.Header.Set(originHeader, test.reqOrigin)
|
||||
w := httptest.NewRecorder()
|
||||
handler := NotAllowedHandler(test.origins...)
|
||||
handler := NotAllowedHandler(nil, test.origins...)
|
||||
handler.ServeHTTP(w, r)
|
||||
if method == http.MethodOptions {
|
||||
assert.Equal(t, http.StatusNoContent, w.Result().StatusCode)
|
||||
@@ -71,6 +73,22 @@ func TestCorsHandlerWithOrigins(t *testing.T) {
|
||||
}
|
||||
assert.Equal(t, test.expect, w.Header().Get(allowOrigin))
|
||||
})
|
||||
t.Run(test.name+"-handler-custom", func(t *testing.T) {
|
||||
r := httptest.NewRequest(method, "http://localhost", nil)
|
||||
r.Header.Set(originHeader, test.reqOrigin)
|
||||
w := httptest.NewRecorder()
|
||||
handler := NotAllowedHandler(func(w http.ResponseWriter) {
|
||||
w.Header().Set("foo", "bar")
|
||||
}, test.origins...)
|
||||
handler.ServeHTTP(w, r)
|
||||
if method == http.MethodOptions {
|
||||
assert.Equal(t, http.StatusNoContent, w.Result().StatusCode)
|
||||
} else {
|
||||
assert.Equal(t, http.StatusNotFound, w.Result().StatusCode)
|
||||
}
|
||||
assert.Equal(t, test.expect, w.Header().Get(allowOrigin))
|
||||
assert.Equal(t, "bar", w.Header().Get("foo"))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +99,7 @@ func TestCorsHandlerWithOrigins(t *testing.T) {
|
||||
r := httptest.NewRequest(method, "http://localhost", nil)
|
||||
r.Header.Set(originHeader, test.reqOrigin)
|
||||
w := httptest.NewRecorder()
|
||||
handler := Middleware(test.origins...)(func(w http.ResponseWriter, r *http.Request) {
|
||||
handler := Middleware(nil, test.origins...)(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
handler.ServeHTTP(w, r)
|
||||
@@ -92,6 +110,69 @@ func TestCorsHandlerWithOrigins(t *testing.T) {
|
||||
}
|
||||
assert.Equal(t, test.expect, w.Header().Get(allowOrigin))
|
||||
})
|
||||
t.Run(test.name+"-middleware-custom", func(t *testing.T) {
|
||||
r := httptest.NewRequest(method, "http://localhost", nil)
|
||||
r.Header.Set(originHeader, test.reqOrigin)
|
||||
w := httptest.NewRecorder()
|
||||
handler := Middleware(func(header http.Header) {
|
||||
header.Set("foo", "bar")
|
||||
}, test.origins...)(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
handler.ServeHTTP(w, r)
|
||||
if method == http.MethodOptions {
|
||||
assert.Equal(t, http.StatusNoContent, w.Result().StatusCode)
|
||||
} else {
|
||||
assert.Equal(t, http.StatusOK, w.Result().StatusCode)
|
||||
}
|
||||
assert.Equal(t, test.expect, w.Header().Get(allowOrigin))
|
||||
assert.Equal(t, "bar", w.Header().Get("foo"))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGuardedResponseWriter_Flush(t *testing.T) {
|
||||
req := httptest.NewRequest(http.MethodGet, "http://localhost", nil)
|
||||
handler := NotAllowedHandler(func(w http.ResponseWriter) {
|
||||
w.Header().Set("X-Test", "test")
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
_, err := w.Write([]byte("content"))
|
||||
assert.Nil(t, err)
|
||||
|
||||
flusher, ok := w.(http.Flusher)
|
||||
assert.True(t, ok)
|
||||
flusher.Flush()
|
||||
}, "foo.com")
|
||||
|
||||
resp := httptest.NewRecorder()
|
||||
handler.ServeHTTP(resp, req)
|
||||
assert.Equal(t, http.StatusServiceUnavailable, resp.Code)
|
||||
assert.Equal(t, "test", resp.Header().Get("X-Test"))
|
||||
assert.Equal(t, "content", resp.Body.String())
|
||||
}
|
||||
|
||||
func TestGuardedResponseWriter_Hijack(t *testing.T) {
|
||||
resp := httptest.NewRecorder()
|
||||
writer := &guardedResponseWriter{
|
||||
w: resp,
|
||||
}
|
||||
assert.NotPanics(t, func() {
|
||||
writer.Hijack()
|
||||
})
|
||||
|
||||
writer = &guardedResponseWriter{
|
||||
w: mockedHijackable{resp},
|
||||
}
|
||||
assert.NotPanics(t, func() {
|
||||
writer.Hijack()
|
||||
})
|
||||
}
|
||||
|
||||
type mockedHijackable struct {
|
||||
*httptest.ResponseRecorder
|
||||
}
|
||||
|
||||
func (m mockedHijackable) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
@@ -119,16 +119,13 @@ func VerifySignature(r *http.Request, securityHeader *ContentSecurityHeader, tol
|
||||
}, "\n")
|
||||
actualSignature := codec.HmacBase64(securityHeader.Key, signContent)
|
||||
|
||||
passed := securityHeader.Signature == actualSignature
|
||||
if !passed {
|
||||
logx.Infof("signature different, expect: %s, actual: %s",
|
||||
securityHeader.Signature, actualSignature)
|
||||
}
|
||||
|
||||
if passed {
|
||||
if securityHeader.Signature == actualSignature {
|
||||
return httpx.CodeSignaturePass
|
||||
}
|
||||
|
||||
logx.Infof("signature different, expect: %s, actual: %s",
|
||||
securityHeader.Signature, actualSignature)
|
||||
|
||||
return httpx.CodeSignatureInvalidToken
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package pathvar
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -16,7 +15,7 @@ func TestVars(t *testing.T) {
|
||||
}
|
||||
r, err := http.NewRequest(http.MethodGet, "/", nil)
|
||||
assert.Nil(t, err)
|
||||
r = r.WithContext(context.WithValue(context.Background(), pathVars, expect))
|
||||
r = WithVars(r, expect)
|
||||
assert.EqualValues(t, expect, Vars(r))
|
||||
}
|
||||
|
||||
|
||||
@@ -99,8 +99,18 @@ func ToMiddleware(handler func(next http.Handler) http.Handler) Middleware {
|
||||
// WithCors returns a func to enable CORS for given origin, or default to all origins (*).
|
||||
func WithCors(origin ...string) RunOption {
|
||||
return func(server *Server) {
|
||||
server.router.SetNotAllowedHandler(cors.NotAllowedHandler(origin...))
|
||||
server.Use(cors.Middleware(origin...))
|
||||
server.router.SetNotAllowedHandler(cors.NotAllowedHandler(nil, origin...))
|
||||
server.Use(cors.Middleware(nil, origin...))
|
||||
}
|
||||
}
|
||||
|
||||
// WithCustomCors returns a func to enable CORS for given origin, or default to all origins (*),
|
||||
// fn lets caller customizing the response.
|
||||
func WithCustomCors(middlewareFn func(header http.Header), notAllowedFn func(http.ResponseWriter),
|
||||
origin ...string) RunOption {
|
||||
return func(server *Server) {
|
||||
server.router.SetNotAllowedHandler(cors.NotAllowedHandler(notAllowedFn, origin...))
|
||||
server.Use(cors.Middleware(middlewareFn, origin...))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -310,3 +310,22 @@ Port: 54321
|
||||
opt := WithCors("local")
|
||||
opt(srv)
|
||||
}
|
||||
|
||||
func TestWithCustomCors(t *testing.T) {
|
||||
const configYaml = `
|
||||
Name: foo
|
||||
Port: 54321
|
||||
`
|
||||
var cnf RestConf
|
||||
assert.Nil(t, conf.LoadConfigFromYamlBytes([]byte(configYaml), &cnf))
|
||||
rt := router.NewRouter()
|
||||
srv, err := NewServer(cnf, WithRouter(rt))
|
||||
assert.Nil(t, err)
|
||||
|
||||
opt := WithCustomCors(func(header http.Header) {
|
||||
header.Set("foo", "bar")
|
||||
}, func(w http.ResponseWriter) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}, "local")
|
||||
opt(srv)
|
||||
}
|
||||
|
||||
@@ -53,6 +53,14 @@ func ApiCommand(c *cli.Context) error {
|
||||
defer fp.Close()
|
||||
|
||||
home := c.String("home")
|
||||
remote := c.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := util.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
|
||||
if len(home) > 0 {
|
||||
util.RegisterGoctlHome(home)
|
||||
}
|
||||
|
||||
@@ -31,6 +31,13 @@ func GoCommand(c *cli.Context) error {
|
||||
dir := c.String("dir")
|
||||
namingStyle := c.String("style")
|
||||
home := c.String("home")
|
||||
remote := c.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := util.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
|
||||
if len(home) > 0 {
|
||||
util.RegisterGoctlHome(home)
|
||||
|
||||
@@ -78,7 +78,7 @@ service A-api {
|
||||
@server(
|
||||
handler: NoResponseHandler
|
||||
)
|
||||
get /greet/get(Request) returns
|
||||
get /greet/get(Request)
|
||||
}
|
||||
`
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
{{.ImportPackages}}
|
||||
)
|
||||
|
||||
func {{.HandlerName}}(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
{{if .HasRequest}}var req types.{{.RequestType}}
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
@@ -32,7 +32,7 @@ func {{.HandlerName}}(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
{{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), ctx)
|
||||
{{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx)
|
||||
{{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}req{{end}})
|
||||
if err != nil {
|
||||
httpx.Error(w, err)
|
||||
|
||||
@@ -3,8 +3,10 @@ package gogen
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/parser/g4/gen/api"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/config"
|
||||
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
@@ -64,12 +66,8 @@ func genLogicByRoute(dir, rootPkg string, cfg *config.Config, group spec.Group,
|
||||
var requestString string
|
||||
if len(route.ResponseTypeName()) > 0 {
|
||||
resp := responseGoTypeName(route, typesPacket)
|
||||
responseString = "(" + resp + ", error)"
|
||||
if strings.HasPrefix(resp, "*") {
|
||||
returnString = fmt.Sprintf("return &%s{}, nil", strings.TrimPrefix(resp, "*"))
|
||||
} else {
|
||||
returnString = fmt.Sprintf("return %s{}, nil", resp)
|
||||
}
|
||||
responseString = "(resp " + resp + ", err error)"
|
||||
returnString = "return"
|
||||
} else {
|
||||
responseString = "error"
|
||||
returnString = "return nil"
|
||||
@@ -116,9 +114,47 @@ func genLogicImports(route spec.Route, parentPkg string) string {
|
||||
var imports []string
|
||||
imports = append(imports, `"context"`+"\n")
|
||||
imports = append(imports, fmt.Sprintf("\"%s\"", ctlutil.JoinPackages(parentPkg, contextDir)))
|
||||
if len(route.ResponseTypeName()) > 0 || len(route.RequestTypeName()) > 0 {
|
||||
if shallImportTypesPackage(route) {
|
||||
imports = append(imports, fmt.Sprintf("\"%s\"\n", ctlutil.JoinPackages(parentPkg, typesDir)))
|
||||
}
|
||||
imports = append(imports, fmt.Sprintf("\"%s/core/logx\"", vars.ProjectOpenSourceURL))
|
||||
return strings.Join(imports, "\n\t")
|
||||
}
|
||||
|
||||
func onlyPrimitiveTypes(val string) bool {
|
||||
fields := strings.FieldsFunc(val, func(r rune) bool {
|
||||
return r == '[' || r == ']' || r == ' '
|
||||
})
|
||||
|
||||
for _, field := range fields {
|
||||
if field == "map" {
|
||||
continue
|
||||
}
|
||||
// ignore array dimension number, like [5]int
|
||||
if _, err := strconv.Atoi(field); err == nil {
|
||||
continue
|
||||
}
|
||||
if !api.IsBasicType(field) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func shallImportTypesPackage(route spec.Route) bool {
|
||||
if len(route.RequestTypeName()) > 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
respTypeName := route.ResponseTypeName()
|
||||
if len(respTypeName) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
if onlyPrimitiveTypes(respTypeName) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -39,12 +39,15 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
)
|
||||
|
||||
var mapping = map[string]string{
|
||||
"delete": "http.MethodDelete",
|
||||
"get": "http.MethodGet",
|
||||
"head": "http.MethodHead",
|
||||
"post": "http.MethodPost",
|
||||
"put": "http.MethodPut",
|
||||
"patch": "http.MethodPatch",
|
||||
"delete": "http.MethodDelete",
|
||||
"get": "http.MethodGet",
|
||||
"head": "http.MethodHead",
|
||||
"post": "http.MethodPost",
|
||||
"put": "http.MethodPut",
|
||||
"patch": "http.MethodPatch",
|
||||
"connect": "http.MethodConnect",
|
||||
"options": "http.MethodOptions",
|
||||
"trace": "http.MethodTrace",
|
||||
}
|
||||
|
||||
type (
|
||||
|
||||
@@ -36,6 +36,10 @@ func CreateServiceCommand(c *cli.Context) error {
|
||||
dirName = "greet"
|
||||
}
|
||||
|
||||
dirStyle := c.String("style")
|
||||
if len(dirStyle) == 0 {
|
||||
dirStyle = conf.DefaultFormat
|
||||
}
|
||||
if strings.Contains(dirName, "-") {
|
||||
return errors.New("api new command service name not support strikethrough, because this will used by function name")
|
||||
}
|
||||
@@ -61,6 +65,14 @@ func CreateServiceCommand(c *cli.Context) error {
|
||||
defer fp.Close()
|
||||
|
||||
home := c.String("home")
|
||||
remote := c.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := util.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
|
||||
if len(home) > 0 {
|
||||
util.RegisterGoctlHome(home)
|
||||
}
|
||||
@@ -78,6 +90,6 @@ func CreateServiceCommand(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = gogen.DoGenProject(apiFilePath, abs, conf.DefaultFormat)
|
||||
err = gogen.DoGenProject(apiFilePath, abs, dirStyle)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -63,11 +63,11 @@ serviceApi: {match(p,"service")}serviceToken=ID serviceName lbrace='{' servi
|
||||
serviceRoute: atDoc? (atServer|atHandler) route;
|
||||
atDoc: ATDOC lp='('? ((kvLit+)|STRING) rp=')'?;
|
||||
atHandler: ATHANDLER ID;
|
||||
route: {checkHttpMethod(p)}httpMethod=ID path request=body? returnToken=ID? response=replybody?;
|
||||
route: {checkHTTPMethod(p)}httpMethod=ID path request=body? response=replybody?;
|
||||
body: lp='(' (ID)? rp=')';
|
||||
replybody: lp='(' dataType? rp=')';
|
||||
replybody: returnToken='returns' lp='(' dataType? rp=')';
|
||||
// kv
|
||||
kvLit: key=ID {checkKeyValue(p)}value=LINE_VALUE;
|
||||
|
||||
serviceName: (ID '-'?)+;
|
||||
path: (('/' (ID ('-' ID)*))|('/:' (ID ('-' ID)?)))+;
|
||||
path: (('/' (ID ('-' ID)*))|('/:' (ID ('-' ID)?)))+ | '/';
|
||||
@@ -2,11 +2,14 @@ package ast
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"sort"
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/parser/g4/gen/api"
|
||||
)
|
||||
|
||||
const prefixKey = "prefix"
|
||||
|
||||
// Api describes syntax for api
|
||||
type Api struct {
|
||||
LinePrefix string
|
||||
@@ -49,8 +52,15 @@ func (v *ApiVisitor) acceptService(root, final *Api) {
|
||||
}
|
||||
v.duplicateServerItemCheck(service)
|
||||
|
||||
var prefix string
|
||||
if service.AtServer != nil {
|
||||
p := service.AtServer.Kv.Get(prefixKey)
|
||||
if p != nil {
|
||||
prefix = p.Text()
|
||||
}
|
||||
}
|
||||
for _, route := range service.ServiceApi.ServiceRoute {
|
||||
uniqueRoute := fmt.Sprintf("%s %s", route.Route.Method.Text(), route.Route.Path.Text())
|
||||
uniqueRoute := fmt.Sprintf("%s %s", route.Route.Method.Text(), path.Join(prefix, route.Route.Path.Text()))
|
||||
if _, ok := final.routeM[uniqueRoute]; ok {
|
||||
v.panic(route.Route.Method, fmt.Sprintf("duplicate route '%s'", uniqueRoute))
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package ast
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -113,13 +114,13 @@ func (p *Parser) parse(filename, content string) (*Api, error) {
|
||||
apiAstList = append(apiAstList, root)
|
||||
for _, imp := range root.Import {
|
||||
dir := filepath.Dir(p.src)
|
||||
path := filepath.Join(dir, imp.Value.Text())
|
||||
data, err := p.readContent(path)
|
||||
imp := filepath.Join(dir, imp.Value.Text())
|
||||
data, err := p.readContent(imp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nestedApi, err := p.invoke(path, data)
|
||||
nestedApi, err := p.invoke(imp, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -196,8 +197,8 @@ func (p *Parser) valid(mainApi, nestedApi *Api) error {
|
||||
if handler.IsNotNil() {
|
||||
handlerName := handler.Text()
|
||||
handlerMap[handlerName] = Holder
|
||||
path := fmt.Sprintf("%s://%s", g.Route.Method.Text(), g.Route.Path.Text())
|
||||
routeMap[path] = Holder
|
||||
route := fmt.Sprintf("%s://%s", g.Route.Method.Text(), g.Route.Path.Text())
|
||||
routeMap[route] = Holder
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +240,13 @@ func (p *Parser) valid(mainApi, nestedApi *Api) error {
|
||||
|
||||
func (p *Parser) duplicateRouteCheck(nestedApi *Api, mainHandlerMap, mainRouteMap map[string]PlaceHolder) error {
|
||||
for _, each := range nestedApi.Service {
|
||||
var prefix string
|
||||
if each.AtServer != nil {
|
||||
p := each.AtServer.Kv.Get(prefixKey)
|
||||
if p != nil {
|
||||
prefix = p.Text()
|
||||
}
|
||||
}
|
||||
for _, r := range each.ServiceApi.ServiceRoute {
|
||||
handler := r.GetHandler()
|
||||
if !handler.IsNotNil() {
|
||||
@@ -250,8 +258,8 @@ func (p *Parser) duplicateRouteCheck(nestedApi *Api, mainHandlerMap, mainRouteMa
|
||||
nestedApi.LinePrefix, handler.Line(), handler.Column(), handler.Text())
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("%s://%s", r.Route.Method.Text(), r.Route.Path.Text())
|
||||
if _, ok := mainRouteMap[path]; ok {
|
||||
p := fmt.Sprintf("%s://%s", r.Route.Method.Text(), path.Join(prefix, r.Route.Path.Text()))
|
||||
if _, ok := mainRouteMap[p]; ok {
|
||||
return fmt.Errorf("%s line %d:%d duplicate route '%s'",
|
||||
nestedApi.LinePrefix, r.Route.Method.Line(), r.Route.Method.Column(), r.Route.Method.Text()+" "+r.Route.Path.Text())
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ type (
|
||||
// ApiVisitor wraps api.BaseApiParserVisitor to call methods which has prefix Visit to
|
||||
// visit node from the api syntax
|
||||
ApiVisitor struct {
|
||||
api.BaseApiParserVisitor
|
||||
*api.BaseApiParserVisitor
|
||||
debug bool
|
||||
log console.Console
|
||||
prefix string
|
||||
|
||||
@@ -71,9 +71,10 @@ type Route struct {
|
||||
|
||||
// Body describes request,response body ast for api syntax
|
||||
type Body struct {
|
||||
Lp Expr
|
||||
Rp Expr
|
||||
Name DataType
|
||||
ReturnExpr Expr
|
||||
Lp Expr
|
||||
Rp Expr
|
||||
Name DataType
|
||||
}
|
||||
|
||||
// VisitServiceSpec implements from api.BaseApiParserVisitor
|
||||
@@ -175,7 +176,7 @@ func (v *ApiVisitor) VisitAtHandler(ctx *api.AtHandlerContext) interface{} {
|
||||
return &atHandler
|
||||
}
|
||||
|
||||
// VisitRoute implements from api.BaseApiParserVisitor
|
||||
// serVisitRoute implements from api.BaseApiParserVisitor
|
||||
func (v *ApiVisitor) VisitRoute(ctx *api.RouteContext) interface{} {
|
||||
var route Route
|
||||
path := ctx.Path()
|
||||
@@ -193,16 +194,12 @@ func (v *ApiVisitor) VisitRoute(ctx *api.RouteContext) interface{} {
|
||||
if ctx.GetResponse() != nil {
|
||||
reply := ctx.GetResponse().Accept(v)
|
||||
if reply != nil {
|
||||
route.Reply = reply.(*Body)
|
||||
resp := reply.(*Body)
|
||||
route.ReturnToken = resp.ReturnExpr
|
||||
resp.ReturnExpr = nil
|
||||
route.Reply = resp
|
||||
}
|
||||
}
|
||||
if ctx.GetReturnToken() != nil {
|
||||
returnExpr := v.newExprWithToken(ctx.GetReturnToken())
|
||||
if ctx.GetReturnToken().GetText() != "returns" {
|
||||
v.panic(returnExpr, fmt.Sprintf("expecting returns, found input '%s'", ctx.GetReturnToken().GetText()))
|
||||
}
|
||||
route.ReturnToken = returnExpr
|
||||
}
|
||||
|
||||
route.DocExpr = v.getDoc(ctx)
|
||||
route.CommentExpr = v.getComment(ctx)
|
||||
@@ -249,6 +246,14 @@ func (v *ApiVisitor) VisitReplybody(ctx *api.ReplybodyContext) interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
var returnExpr Expr
|
||||
if ctx.GetReturnToken() != nil {
|
||||
returnExpr = v.newExprWithToken(ctx.GetReturnToken())
|
||||
if ctx.GetReturnToken().GetText() != "returns" {
|
||||
v.panic(returnExpr, fmt.Sprintf("expecting returns, found input '%s'", ctx.GetReturnToken().GetText()))
|
||||
}
|
||||
}
|
||||
|
||||
dt := ctx.DataType().Accept(v).(DataType)
|
||||
if dt == nil {
|
||||
return nil
|
||||
@@ -267,20 +272,18 @@ func (v *ApiVisitor) VisitReplybody(ctx *api.ReplybodyContext) interface{} {
|
||||
}
|
||||
case *Literal:
|
||||
lit := dataType.Literal.Text()
|
||||
if api.IsGolangKeyWord(dataType.Literal.Text()) {
|
||||
v.panic(dataType.Literal, fmt.Sprintf("expecting 'ID', but found golang keyword '%s'", dataType.Literal.Text()))
|
||||
}
|
||||
if api.IsBasicType(lit) {
|
||||
v.panic(dt.Expr(), fmt.Sprintf("unsupport %s", dt.Expr().Text()))
|
||||
if api.IsGolangKeyWord(lit) {
|
||||
v.panic(dataType.Literal, fmt.Sprintf("expecting 'ID', but found golang keyword '%s'", lit))
|
||||
}
|
||||
default:
|
||||
v.panic(dt.Expr(), fmt.Sprintf("unsupport %s", dt.Expr().Text()))
|
||||
}
|
||||
|
||||
return &Body{
|
||||
Lp: v.newExprWithToken(ctx.GetLp()),
|
||||
Rp: v.newExprWithToken(ctx.GetRp()),
|
||||
Name: dt,
|
||||
ReturnExpr: returnExpr,
|
||||
Lp: v.newExprWithToken(ctx.GetLp()),
|
||||
Rp: v.newExprWithToken(ctx.GetRp()),
|
||||
Name: dt,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// Code generated from tools/goctl/api/parser/g4/ApiParser.g4 by ANTLR 4.9. DO NOT EDIT.
|
||||
|
||||
package api // ApiParser
|
||||
import "github.com/zeromicro/antlr"
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// Code generated from tools/goctl/api/parser/g4/ApiParser.g4 by ANTLR 4.9. DO NOT EDIT.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
@@ -16,132 +14,136 @@ var (
|
||||
)
|
||||
|
||||
var serializedLexerAtn = []uint16{
|
||||
3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 25, 266,
|
||||
3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 26, 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,
|
||||
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,
|
||||
18, 9, 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, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 3, 2, 3, 2, 3, 3, 3, 3, 3,
|
||||
4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3,
|
||||
8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11,
|
||||
3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3,
|
||||
15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16,
|
||||
3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3,
|
||||
17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 6, 18, 132,
|
||||
10, 18, 13, 18, 14, 18, 133, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19,
|
||||
7, 19, 142, 10, 19, 12, 19, 14, 19, 145, 11, 19, 3, 19, 3, 19, 3, 19, 3,
|
||||
19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 7, 20, 156, 10, 20, 12, 20, 14,
|
||||
20, 159, 11, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 7, 21, 166, 10, 21,
|
||||
12, 21, 14, 21, 169, 11, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 6, 22,
|
||||
176, 10, 22, 13, 22, 14, 22, 177, 3, 22, 3, 22, 3, 23, 3, 23, 7, 23, 184,
|
||||
10, 23, 12, 23, 14, 23, 187, 11, 23, 3, 23, 3, 23, 7, 23, 191, 10, 23,
|
||||
12, 23, 14, 23, 194, 11, 23, 5, 23, 196, 10, 23, 3, 24, 3, 24, 7, 24, 200,
|
||||
10, 24, 12, 24, 14, 24, 203, 11, 24, 3, 25, 3, 25, 5, 25, 207, 10, 25,
|
||||
3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 5, 26, 215, 10, 26, 3, 26, 5,
|
||||
26, 218, 10, 26, 3, 26, 3, 26, 3, 26, 6, 26, 223, 10, 26, 13, 26, 14, 26,
|
||||
224, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 5, 26, 232, 10, 26, 3, 27, 3, 27,
|
||||
3, 27, 7, 27, 237, 10, 27, 12, 27, 14, 27, 240, 11, 27, 3, 27, 5, 27, 243,
|
||||
10, 27, 3, 28, 3, 28, 3, 29, 3, 29, 7, 29, 249, 10, 29, 12, 29, 14, 29,
|
||||
252, 11, 29, 3, 29, 5, 29, 255, 10, 29, 3, 30, 3, 30, 5, 30, 259, 10, 30,
|
||||
3, 31, 3, 31, 3, 31, 3, 31, 5, 31, 265, 10, 31, 3, 143, 2, 32, 3, 3, 5,
|
||||
4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25,
|
||||
14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43,
|
||||
23, 45, 24, 47, 25, 49, 2, 51, 2, 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, 36,
|
||||
94, 94, 6, 2, 12, 12, 15, 15, 94, 94, 98, 98, 4, 2, 11, 11, 34, 34, 6,
|
||||
2, 12, 12, 15, 15, 36, 36, 98, 98, 4, 2, 71, 71, 103, 103, 4, 2, 45, 45,
|
||||
47, 47, 10, 2, 36, 36, 41, 41, 94, 94, 100, 100, 104, 104, 112, 112, 116,
|
||||
116, 118, 118, 3, 2, 50, 53, 3, 2, 50, 57, 5, 2, 50, 59, 67, 72, 99, 104,
|
||||
3, 2, 50, 59, 4, 2, 50, 59, 97, 97, 6, 2, 38, 38, 67, 92, 97, 97, 99, 124,
|
||||
4, 2, 2, 129, 55298, 56321, 3, 2, 55298, 56321, 3, 2, 56322, 57345, 2,
|
||||
283, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2,
|
||||
2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3,
|
||||
2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25,
|
||||
3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2,
|
||||
33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 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, 47, 3, 2, 2,
|
||||
2, 3, 63, 3, 2, 2, 2, 5, 65, 3, 2, 2, 2, 7, 67, 3, 2, 2, 2, 9, 69, 3, 2,
|
||||
2, 2, 11, 71, 3, 2, 2, 2, 13, 73, 3, 2, 2, 2, 15, 75, 3, 2, 2, 2, 17, 85,
|
||||
3, 2, 2, 2, 19, 87, 3, 2, 2, 2, 21, 89, 3, 2, 2, 2, 23, 91, 3, 2, 2, 2,
|
||||
25, 93, 3, 2, 2, 2, 27, 96, 3, 2, 2, 2, 29, 101, 3, 2, 2, 2, 31, 110, 3,
|
||||
2, 2, 2, 33, 122, 3, 2, 2, 2, 35, 131, 3, 2, 2, 2, 37, 137, 3, 2, 2, 2,
|
||||
39, 151, 3, 2, 2, 2, 41, 162, 3, 2, 2, 2, 43, 172, 3, 2, 2, 2, 45, 181,
|
||||
3, 2, 2, 2, 47, 197, 3, 2, 2, 2, 49, 204, 3, 2, 2, 2, 51, 231, 3, 2, 2,
|
||||
2, 53, 233, 3, 2, 2, 2, 55, 244, 3, 2, 2, 2, 57, 246, 3, 2, 2, 2, 59, 258,
|
||||
3, 2, 2, 2, 61, 264, 3, 2, 2, 2, 63, 64, 7, 63, 2, 2, 64, 4, 3, 2, 2, 2,
|
||||
65, 66, 7, 42, 2, 2, 66, 6, 3, 2, 2, 2, 67, 68, 7, 43, 2, 2, 68, 8, 3,
|
||||
2, 2, 2, 69, 70, 7, 125, 2, 2, 70, 10, 3, 2, 2, 2, 71, 72, 7, 127, 2, 2,
|
||||
72, 12, 3, 2, 2, 2, 73, 74, 7, 44, 2, 2, 74, 14, 3, 2, 2, 2, 75, 76, 7,
|
||||
118, 2, 2, 76, 77, 7, 107, 2, 2, 77, 78, 7, 111, 2, 2, 78, 79, 7, 103,
|
||||
2, 2, 79, 80, 7, 48, 2, 2, 80, 81, 7, 86, 2, 2, 81, 82, 7, 107, 2, 2, 82,
|
||||
83, 7, 111, 2, 2, 83, 84, 7, 103, 2, 2, 84, 16, 3, 2, 2, 2, 85, 86, 7,
|
||||
93, 2, 2, 86, 18, 3, 2, 2, 2, 87, 88, 7, 95, 2, 2, 88, 20, 3, 2, 2, 2,
|
||||
89, 90, 7, 47, 2, 2, 90, 22, 3, 2, 2, 2, 91, 92, 7, 49, 2, 2, 92, 24, 3,
|
||||
2, 2, 2, 93, 94, 7, 49, 2, 2, 94, 95, 7, 60, 2, 2, 95, 26, 3, 2, 2, 2,
|
||||
96, 97, 7, 66, 2, 2, 97, 98, 7, 102, 2, 2, 98, 99, 7, 113, 2, 2, 99, 100,
|
||||
7, 101, 2, 2, 100, 28, 3, 2, 2, 2, 101, 102, 7, 66, 2, 2, 102, 103, 7,
|
||||
106, 2, 2, 103, 104, 7, 99, 2, 2, 104, 105, 7, 112, 2, 2, 105, 106, 7,
|
||||
102, 2, 2, 106, 107, 7, 110, 2, 2, 107, 108, 7, 103, 2, 2, 108, 109, 7,
|
||||
116, 2, 2, 109, 30, 3, 2, 2, 2, 110, 111, 7, 107, 2, 2, 111, 112, 7, 112,
|
||||
2, 2, 112, 113, 7, 118, 2, 2, 113, 114, 7, 103, 2, 2, 114, 115, 7, 116,
|
||||
2, 2, 115, 116, 7, 104, 2, 2, 116, 117, 7, 99, 2, 2, 117, 118, 7, 101,
|
||||
2, 2, 118, 119, 7, 103, 2, 2, 119, 120, 7, 125, 2, 2, 120, 121, 7, 127,
|
||||
2, 2, 121, 32, 3, 2, 2, 2, 122, 123, 7, 66, 2, 2, 123, 124, 7, 117, 2,
|
||||
2, 124, 125, 7, 103, 2, 2, 125, 126, 7, 116, 2, 2, 126, 127, 7, 120, 2,
|
||||
2, 127, 128, 7, 103, 2, 2, 128, 129, 7, 116, 2, 2, 129, 34, 3, 2, 2, 2,
|
||||
130, 132, 9, 2, 2, 2, 131, 130, 3, 2, 2, 2, 132, 133, 3, 2, 2, 2, 133,
|
||||
131, 3, 2, 2, 2, 133, 134, 3, 2, 2, 2, 134, 135, 3, 2, 2, 2, 135, 136,
|
||||
8, 18, 2, 2, 136, 36, 3, 2, 2, 2, 137, 138, 7, 49, 2, 2, 138, 139, 7, 44,
|
||||
2, 2, 139, 143, 3, 2, 2, 2, 140, 142, 11, 2, 2, 2, 141, 140, 3, 2, 2, 2,
|
||||
142, 145, 3, 2, 2, 2, 143, 144, 3, 2, 2, 2, 143, 141, 3, 2, 2, 2, 144,
|
||||
146, 3, 2, 2, 2, 145, 143, 3, 2, 2, 2, 146, 147, 7, 44, 2, 2, 147, 148,
|
||||
7, 49, 2, 2, 148, 149, 3, 2, 2, 2, 149, 150, 8, 19, 3, 2, 150, 38, 3, 2,
|
||||
2, 2, 151, 152, 7, 49, 2, 2, 152, 153, 7, 49, 2, 2, 153, 157, 3, 2, 2,
|
||||
2, 154, 156, 10, 3, 2, 2, 155, 154, 3, 2, 2, 2, 156, 159, 3, 2, 2, 2, 157,
|
||||
155, 3, 2, 2, 2, 157, 158, 3, 2, 2, 2, 158, 160, 3, 2, 2, 2, 159, 157,
|
||||
3, 2, 2, 2, 160, 161, 8, 20, 3, 2, 161, 40, 3, 2, 2, 2, 162, 167, 7, 36,
|
||||
2, 2, 163, 166, 10, 4, 2, 2, 164, 166, 5, 51, 26, 2, 165, 163, 3, 2, 2,
|
||||
2, 165, 164, 3, 2, 2, 2, 166, 169, 3, 2, 2, 2, 167, 165, 3, 2, 2, 2, 167,
|
||||
168, 3, 2, 2, 2, 168, 170, 3, 2, 2, 2, 169, 167, 3, 2, 2, 2, 170, 171,
|
||||
7, 36, 2, 2, 171, 42, 3, 2, 2, 2, 172, 175, 7, 98, 2, 2, 173, 176, 10,
|
||||
5, 2, 2, 174, 176, 5, 51, 26, 2, 175, 173, 3, 2, 2, 2, 175, 174, 3, 2,
|
||||
2, 2, 176, 177, 3, 2, 2, 2, 177, 175, 3, 2, 2, 2, 177, 178, 3, 2, 2, 2,
|
||||
178, 179, 3, 2, 2, 2, 179, 180, 7, 98, 2, 2, 180, 44, 3, 2, 2, 2, 181,
|
||||
185, 7, 60, 2, 2, 182, 184, 9, 6, 2, 2, 183, 182, 3, 2, 2, 2, 184, 187,
|
||||
3, 2, 2, 2, 185, 183, 3, 2, 2, 2, 185, 186, 3, 2, 2, 2, 186, 195, 3, 2,
|
||||
2, 2, 187, 185, 3, 2, 2, 2, 188, 196, 5, 41, 21, 2, 189, 191, 10, 7, 2,
|
||||
2, 190, 189, 3, 2, 2, 2, 191, 194, 3, 2, 2, 2, 192, 190, 3, 2, 2, 2, 192,
|
||||
193, 3, 2, 2, 2, 193, 196, 3, 2, 2, 2, 194, 192, 3, 2, 2, 2, 195, 188,
|
||||
3, 2, 2, 2, 195, 192, 3, 2, 2, 2, 196, 46, 3, 2, 2, 2, 197, 201, 5, 61,
|
||||
31, 2, 198, 200, 5, 59, 30, 2, 199, 198, 3, 2, 2, 2, 200, 203, 3, 2, 2,
|
||||
2, 201, 199, 3, 2, 2, 2, 201, 202, 3, 2, 2, 2, 202, 48, 3, 2, 2, 2, 203,
|
||||
201, 3, 2, 2, 2, 204, 206, 9, 8, 2, 2, 205, 207, 9, 9, 2, 2, 206, 205,
|
||||
3, 2, 2, 2, 206, 207, 3, 2, 2, 2, 207, 208, 3, 2, 2, 2, 208, 209, 5, 57,
|
||||
29, 2, 209, 50, 3, 2, 2, 2, 210, 211, 7, 94, 2, 2, 211, 232, 9, 10, 2,
|
||||
2, 212, 217, 7, 94, 2, 2, 213, 215, 9, 11, 2, 2, 214, 213, 3, 2, 2, 2,
|
||||
214, 215, 3, 2, 2, 2, 215, 216, 3, 2, 2, 2, 216, 218, 9, 12, 2, 2, 217,
|
||||
214, 3, 2, 2, 2, 217, 218, 3, 2, 2, 2, 218, 219, 3, 2, 2, 2, 219, 232,
|
||||
9, 12, 2, 2, 220, 222, 7, 94, 2, 2, 221, 223, 7, 119, 2, 2, 222, 221, 3,
|
||||
2, 2, 2, 223, 224, 3, 2, 2, 2, 224, 222, 3, 2, 2, 2, 224, 225, 3, 2, 2,
|
||||
2, 225, 226, 3, 2, 2, 2, 226, 227, 5, 55, 28, 2, 227, 228, 5, 55, 28, 2,
|
||||
228, 229, 5, 55, 28, 2, 229, 230, 5, 55, 28, 2, 230, 232, 3, 2, 2, 2, 231,
|
||||
210, 3, 2, 2, 2, 231, 212, 3, 2, 2, 2, 231, 220, 3, 2, 2, 2, 232, 52, 3,
|
||||
2, 2, 2, 233, 242, 5, 55, 28, 2, 234, 237, 5, 55, 28, 2, 235, 237, 7, 97,
|
||||
2, 2, 236, 234, 3, 2, 2, 2, 236, 235, 3, 2, 2, 2, 237, 240, 3, 2, 2, 2,
|
||||
238, 236, 3, 2, 2, 2, 238, 239, 3, 2, 2, 2, 239, 241, 3, 2, 2, 2, 240,
|
||||
238, 3, 2, 2, 2, 241, 243, 5, 55, 28, 2, 242, 238, 3, 2, 2, 2, 242, 243,
|
||||
3, 2, 2, 2, 243, 54, 3, 2, 2, 2, 244, 245, 9, 13, 2, 2, 245, 56, 3, 2,
|
||||
2, 2, 246, 254, 9, 14, 2, 2, 247, 249, 9, 15, 2, 2, 248, 247, 3, 2, 2,
|
||||
2, 249, 252, 3, 2, 2, 2, 250, 248, 3, 2, 2, 2, 250, 251, 3, 2, 2, 2, 251,
|
||||
253, 3, 2, 2, 2, 252, 250, 3, 2, 2, 2, 253, 255, 9, 14, 2, 2, 254, 250,
|
||||
3, 2, 2, 2, 254, 255, 3, 2, 2, 2, 255, 58, 3, 2, 2, 2, 256, 259, 5, 61,
|
||||
31, 2, 257, 259, 9, 14, 2, 2, 258, 256, 3, 2, 2, 2, 258, 257, 3, 2, 2,
|
||||
2, 259, 60, 3, 2, 2, 2, 260, 265, 9, 16, 2, 2, 261, 265, 10, 17, 2, 2,
|
||||
262, 263, 9, 18, 2, 2, 263, 265, 9, 19, 2, 2, 264, 260, 3, 2, 2, 2, 264,
|
||||
261, 3, 2, 2, 2, 264, 262, 3, 2, 2, 2, 265, 62, 3, 2, 2, 2, 26, 2, 133,
|
||||
143, 157, 165, 167, 175, 177, 185, 192, 195, 201, 206, 214, 217, 224, 231,
|
||||
236, 238, 242, 250, 254, 258, 264, 4, 2, 3, 2, 2, 90, 2,
|
||||
28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 3, 2, 3, 2,
|
||||
3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8,
|
||||
3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10,
|
||||
3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3,
|
||||
13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16,
|
||||
3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3,
|
||||
17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18,
|
||||
3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 6, 19, 142, 10,
|
||||
19, 13, 19, 14, 19, 143, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 7, 20,
|
||||
152, 10, 20, 12, 20, 14, 20, 155, 11, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3,
|
||||
20, 3, 21, 3, 21, 3, 21, 3, 21, 7, 21, 166, 10, 21, 12, 21, 14, 21, 169,
|
||||
11, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 7, 22, 176, 10, 22, 12, 22,
|
||||
14, 22, 179, 11, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 6, 23, 186, 10,
|
||||
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,
|
||||
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,
|
||||
3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 5, 27, 225, 10, 27, 3, 27, 5, 27, 228,
|
||||
10, 27, 3, 27, 3, 27, 3, 27, 6, 27, 233, 10, 27, 13, 27, 14, 27, 234, 3,
|
||||
27, 3, 27, 3, 27, 3, 27, 3, 27, 5, 27, 242, 10, 27, 3, 28, 3, 28, 3, 28,
|
||||
7, 28, 247, 10, 28, 12, 28, 14, 28, 250, 11, 28, 3, 28, 5, 28, 253, 10,
|
||||
28, 3, 29, 3, 29, 3, 30, 3, 30, 7, 30, 259, 10, 30, 12, 30, 14, 30, 262,
|
||||
11, 30, 3, 30, 5, 30, 265, 10, 30, 3, 31, 3, 31, 5, 31, 269, 10, 31, 3,
|
||||
32, 3, 32, 3, 32, 3, 32, 5, 32, 275, 10, 32, 3, 153, 2, 33, 3, 3, 5, 4,
|
||||
7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14,
|
||||
27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23,
|
||||
45, 24, 47, 25, 49, 26, 51, 2, 53, 2, 55, 2, 57, 2, 59, 2, 61, 2, 63, 2,
|
||||
3, 2, 20, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 12, 12, 15, 15, 4, 2, 36,
|
||||
36, 94, 94, 6, 2, 12, 12, 15, 15, 94, 94, 98, 98, 4, 2, 11, 11, 34, 34,
|
||||
6, 2, 12, 12, 15, 15, 36, 36, 98, 98, 4, 2, 71, 71, 103, 103, 4, 2, 45,
|
||||
45, 47, 47, 10, 2, 36, 36, 41, 41, 94, 94, 100, 100, 104, 104, 112, 112,
|
||||
116, 116, 118, 118, 3, 2, 50, 53, 3, 2, 50, 57, 5, 2, 50, 59, 67, 72, 99,
|
||||
104, 3, 2, 50, 59, 4, 2, 50, 59, 97, 97, 6, 2, 38, 38, 67, 92, 97, 97,
|
||||
99, 124, 4, 2, 2, 129, 55298, 56321, 3, 2, 55298, 56321, 3, 2, 56322, 57345,
|
||||
2, 293, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3,
|
||||
2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17,
|
||||
3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2,
|
||||
25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2,
|
||||
2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 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, 47, 3, 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, 2, 2, 9, 71, 3, 2, 2, 2, 11, 73, 3, 2, 2, 2, 13, 75, 3, 2, 2, 2, 15,
|
||||
77, 3, 2, 2, 2, 17, 87, 3, 2, 2, 2, 19, 89, 3, 2, 2, 2, 21, 91, 3, 2, 2,
|
||||
2, 23, 99, 3, 2, 2, 2, 25, 101, 3, 2, 2, 2, 27, 103, 3, 2, 2, 2, 29, 106,
|
||||
3, 2, 2, 2, 31, 111, 3, 2, 2, 2, 33, 120, 3, 2, 2, 2, 35, 132, 3, 2, 2,
|
||||
2, 37, 141, 3, 2, 2, 2, 39, 147, 3, 2, 2, 2, 41, 161, 3, 2, 2, 2, 43, 172,
|
||||
3, 2, 2, 2, 45, 182, 3, 2, 2, 2, 47, 191, 3, 2, 2, 2, 49, 207, 3, 2, 2,
|
||||
2, 51, 214, 3, 2, 2, 2, 53, 241, 3, 2, 2, 2, 55, 243, 3, 2, 2, 2, 57, 254,
|
||||
3, 2, 2, 2, 59, 256, 3, 2, 2, 2, 61, 268, 3, 2, 2, 2, 63, 274, 3, 2, 2,
|
||||
2, 65, 66, 7, 63, 2, 2, 66, 4, 3, 2, 2, 2, 67, 68, 7, 42, 2, 2, 68, 6,
|
||||
3, 2, 2, 2, 69, 70, 7, 43, 2, 2, 70, 8, 3, 2, 2, 2, 71, 72, 7, 125, 2,
|
||||
2, 72, 10, 3, 2, 2, 2, 73, 74, 7, 127, 2, 2, 74, 12, 3, 2, 2, 2, 75, 76,
|
||||
7, 44, 2, 2, 76, 14, 3, 2, 2, 2, 77, 78, 7, 118, 2, 2, 78, 79, 7, 107,
|
||||
2, 2, 79, 80, 7, 111, 2, 2, 80, 81, 7, 103, 2, 2, 81, 82, 7, 48, 2, 2,
|
||||
82, 83, 7, 86, 2, 2, 83, 84, 7, 107, 2, 2, 84, 85, 7, 111, 2, 2, 85, 86,
|
||||
7, 103, 2, 2, 86, 16, 3, 2, 2, 2, 87, 88, 7, 93, 2, 2, 88, 18, 3, 2, 2,
|
||||
2, 89, 90, 7, 95, 2, 2, 90, 20, 3, 2, 2, 2, 91, 92, 7, 116, 2, 2, 92, 93,
|
||||
7, 103, 2, 2, 93, 94, 7, 118, 2, 2, 94, 95, 7, 119, 2, 2, 95, 96, 7, 116,
|
||||
2, 2, 96, 97, 7, 112, 2, 2, 97, 98, 7, 117, 2, 2, 98, 22, 3, 2, 2, 2, 99,
|
||||
100, 7, 47, 2, 2, 100, 24, 3, 2, 2, 2, 101, 102, 7, 49, 2, 2, 102, 26,
|
||||
3, 2, 2, 2, 103, 104, 7, 49, 2, 2, 104, 105, 7, 60, 2, 2, 105, 28, 3, 2,
|
||||
2, 2, 106, 107, 7, 66, 2, 2, 107, 108, 7, 102, 2, 2, 108, 109, 7, 113,
|
||||
2, 2, 109, 110, 7, 101, 2, 2, 110, 30, 3, 2, 2, 2, 111, 112, 7, 66, 2,
|
||||
2, 112, 113, 7, 106, 2, 2, 113, 114, 7, 99, 2, 2, 114, 115, 7, 112, 2,
|
||||
2, 115, 116, 7, 102, 2, 2, 116, 117, 7, 110, 2, 2, 117, 118, 7, 103, 2,
|
||||
2, 118, 119, 7, 116, 2, 2, 119, 32, 3, 2, 2, 2, 120, 121, 7, 107, 2, 2,
|
||||
121, 122, 7, 112, 2, 2, 122, 123, 7, 118, 2, 2, 123, 124, 7, 103, 2, 2,
|
||||
124, 125, 7, 116, 2, 2, 125, 126, 7, 104, 2, 2, 126, 127, 7, 99, 2, 2,
|
||||
127, 128, 7, 101, 2, 2, 128, 129, 7, 103, 2, 2, 129, 130, 7, 125, 2, 2,
|
||||
130, 131, 7, 127, 2, 2, 131, 34, 3, 2, 2, 2, 132, 133, 7, 66, 2, 2, 133,
|
||||
134, 7, 117, 2, 2, 134, 135, 7, 103, 2, 2, 135, 136, 7, 116, 2, 2, 136,
|
||||
137, 7, 120, 2, 2, 137, 138, 7, 103, 2, 2, 138, 139, 7, 116, 2, 2, 139,
|
||||
36, 3, 2, 2, 2, 140, 142, 9, 2, 2, 2, 141, 140, 3, 2, 2, 2, 142, 143, 3,
|
||||
2, 2, 2, 143, 141, 3, 2, 2, 2, 143, 144, 3, 2, 2, 2, 144, 145, 3, 2, 2,
|
||||
2, 145, 146, 8, 19, 2, 2, 146, 38, 3, 2, 2, 2, 147, 148, 7, 49, 2, 2, 148,
|
||||
149, 7, 44, 2, 2, 149, 153, 3, 2, 2, 2, 150, 152, 11, 2, 2, 2, 151, 150,
|
||||
3, 2, 2, 2, 152, 155, 3, 2, 2, 2, 153, 154, 3, 2, 2, 2, 153, 151, 3, 2,
|
||||
2, 2, 154, 156, 3, 2, 2, 2, 155, 153, 3, 2, 2, 2, 156, 157, 7, 44, 2, 2,
|
||||
157, 158, 7, 49, 2, 2, 158, 159, 3, 2, 2, 2, 159, 160, 8, 20, 3, 2, 160,
|
||||
40, 3, 2, 2, 2, 161, 162, 7, 49, 2, 2, 162, 163, 7, 49, 2, 2, 163, 167,
|
||||
3, 2, 2, 2, 164, 166, 10, 3, 2, 2, 165, 164, 3, 2, 2, 2, 166, 169, 3, 2,
|
||||
2, 2, 167, 165, 3, 2, 2, 2, 167, 168, 3, 2, 2, 2, 168, 170, 3, 2, 2, 2,
|
||||
169, 167, 3, 2, 2, 2, 170, 171, 8, 21, 3, 2, 171, 42, 3, 2, 2, 2, 172,
|
||||
177, 7, 36, 2, 2, 173, 176, 10, 4, 2, 2, 174, 176, 5, 53, 27, 2, 175, 173,
|
||||
3, 2, 2, 2, 175, 174, 3, 2, 2, 2, 176, 179, 3, 2, 2, 2, 177, 175, 3, 2,
|
||||
2, 2, 177, 178, 3, 2, 2, 2, 178, 180, 3, 2, 2, 2, 179, 177, 3, 2, 2, 2,
|
||||
180, 181, 7, 36, 2, 2, 181, 44, 3, 2, 2, 2, 182, 185, 7, 98, 2, 2, 183,
|
||||
186, 10, 5, 2, 2, 184, 186, 5, 53, 27, 2, 185, 183, 3, 2, 2, 2, 185, 184,
|
||||
3, 2, 2, 2, 186, 187, 3, 2, 2, 2, 187, 185, 3, 2, 2, 2, 187, 188, 3, 2,
|
||||
2, 2, 188, 189, 3, 2, 2, 2, 189, 190, 7, 98, 2, 2, 190, 46, 3, 2, 2, 2,
|
||||
191, 195, 7, 60, 2, 2, 192, 194, 9, 6, 2, 2, 193, 192, 3, 2, 2, 2, 194,
|
||||
197, 3, 2, 2, 2, 195, 193, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 205,
|
||||
3, 2, 2, 2, 197, 195, 3, 2, 2, 2, 198, 206, 5, 43, 22, 2, 199, 201, 10,
|
||||
7, 2, 2, 200, 199, 3, 2, 2, 2, 201, 204, 3, 2, 2, 2, 202, 200, 3, 2, 2,
|
||||
2, 202, 203, 3, 2, 2, 2, 203, 206, 3, 2, 2, 2, 204, 202, 3, 2, 2, 2, 205,
|
||||
198, 3, 2, 2, 2, 205, 202, 3, 2, 2, 2, 206, 48, 3, 2, 2, 2, 207, 211, 5,
|
||||
63, 32, 2, 208, 210, 5, 61, 31, 2, 209, 208, 3, 2, 2, 2, 210, 213, 3, 2,
|
||||
2, 2, 211, 209, 3, 2, 2, 2, 211, 212, 3, 2, 2, 2, 212, 50, 3, 2, 2, 2,
|
||||
213, 211, 3, 2, 2, 2, 214, 216, 9, 8, 2, 2, 215, 217, 9, 9, 2, 2, 216,
|
||||
215, 3, 2, 2, 2, 216, 217, 3, 2, 2, 2, 217, 218, 3, 2, 2, 2, 218, 219,
|
||||
5, 59, 30, 2, 219, 52, 3, 2, 2, 2, 220, 221, 7, 94, 2, 2, 221, 242, 9,
|
||||
10, 2, 2, 222, 227, 7, 94, 2, 2, 223, 225, 9, 11, 2, 2, 224, 223, 3, 2,
|
||||
2, 2, 224, 225, 3, 2, 2, 2, 225, 226, 3, 2, 2, 2, 226, 228, 9, 12, 2, 2,
|
||||
227, 224, 3, 2, 2, 2, 227, 228, 3, 2, 2, 2, 228, 229, 3, 2, 2, 2, 229,
|
||||
242, 9, 12, 2, 2, 230, 232, 7, 94, 2, 2, 231, 233, 7, 119, 2, 2, 232, 231,
|
||||
3, 2, 2, 2, 233, 234, 3, 2, 2, 2, 234, 232, 3, 2, 2, 2, 234, 235, 3, 2,
|
||||
2, 2, 235, 236, 3, 2, 2, 2, 236, 237, 5, 57, 29, 2, 237, 238, 5, 57, 29,
|
||||
2, 238, 239, 5, 57, 29, 2, 239, 240, 5, 57, 29, 2, 240, 242, 3, 2, 2, 2,
|
||||
241, 220, 3, 2, 2, 2, 241, 222, 3, 2, 2, 2, 241, 230, 3, 2, 2, 2, 242,
|
||||
54, 3, 2, 2, 2, 243, 252, 5, 57, 29, 2, 244, 247, 5, 57, 29, 2, 245, 247,
|
||||
7, 97, 2, 2, 246, 244, 3, 2, 2, 2, 246, 245, 3, 2, 2, 2, 247, 250, 3, 2,
|
||||
2, 2, 248, 246, 3, 2, 2, 2, 248, 249, 3, 2, 2, 2, 249, 251, 3, 2, 2, 2,
|
||||
250, 248, 3, 2, 2, 2, 251, 253, 5, 57, 29, 2, 252, 248, 3, 2, 2, 2, 252,
|
||||
253, 3, 2, 2, 2, 253, 56, 3, 2, 2, 2, 254, 255, 9, 13, 2, 2, 255, 58, 3,
|
||||
2, 2, 2, 256, 264, 9, 14, 2, 2, 257, 259, 9, 15, 2, 2, 258, 257, 3, 2,
|
||||
2, 2, 259, 262, 3, 2, 2, 2, 260, 258, 3, 2, 2, 2, 260, 261, 3, 2, 2, 2,
|
||||
261, 263, 3, 2, 2, 2, 262, 260, 3, 2, 2, 2, 263, 265, 9, 14, 2, 2, 264,
|
||||
260, 3, 2, 2, 2, 264, 265, 3, 2, 2, 2, 265, 60, 3, 2, 2, 2, 266, 269, 5,
|
||||
63, 32, 2, 267, 269, 9, 14, 2, 2, 268, 266, 3, 2, 2, 2, 268, 267, 3, 2,
|
||||
2, 2, 269, 62, 3, 2, 2, 2, 270, 275, 9, 16, 2, 2, 271, 275, 10, 17, 2,
|
||||
2, 272, 273, 9, 18, 2, 2, 273, 275, 9, 19, 2, 2, 274, 270, 3, 2, 2, 2,
|
||||
274, 271, 3, 2, 2, 2, 274, 272, 3, 2, 2, 2, 275, 64, 3, 2, 2, 2, 26, 2,
|
||||
143, 153, 167, 175, 177, 185, 187, 195, 202, 205, 211, 216, 224, 227, 234,
|
||||
241, 246, 248, 252, 260, 264, 268, 274, 4, 2, 3, 2, 2, 90, 2,
|
||||
}
|
||||
|
||||
var lexerChannelNames = []string{
|
||||
@@ -154,18 +156,19 @@ var lexerModeNames = []string{
|
||||
|
||||
var lexerLiteralNames = []string{
|
||||
"", "'='", "'('", "')'", "'{'", "'}'", "'*'", "'time.Time'", "'['", "']'",
|
||||
"'-'", "'/'", "'/:'", "'@doc'", "'@handler'", "'interface{}'", "'@server'",
|
||||
"'returns'", "'-'", "'/'", "'/:'", "'@doc'", "'@handler'", "'interface{}'",
|
||||
"'@server'",
|
||||
}
|
||||
|
||||
var lexerSymbolicNames = []string{
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", "", "ATDOC", "ATHANDLER",
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "ATDOC", "ATHANDLER",
|
||||
"INTERFACE", "ATSERVER", "WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING",
|
||||
"LINE_VALUE", "ID",
|
||||
}
|
||||
|
||||
var lexerRuleNames = []string{
|
||||
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
|
||||
"T__9", "T__10", "T__11", "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",
|
||||
"ID", "ExponentPart", "EscapeSequence", "HexDigits", "HexDigit", "Digits",
|
||||
"LetterOrDigit", "Letter",
|
||||
@@ -220,17 +223,18 @@ const (
|
||||
ApiParserLexerT__9 = 10
|
||||
ApiParserLexerT__10 = 11
|
||||
ApiParserLexerT__11 = 12
|
||||
ApiParserLexerATDOC = 13
|
||||
ApiParserLexerATHANDLER = 14
|
||||
ApiParserLexerINTERFACE = 15
|
||||
ApiParserLexerATSERVER = 16
|
||||
ApiParserLexerWS = 17
|
||||
ApiParserLexerCOMMENT = 18
|
||||
ApiParserLexerLINE_COMMENT = 19
|
||||
ApiParserLexerSTRING = 20
|
||||
ApiParserLexerRAW_STRING = 21
|
||||
ApiParserLexerLINE_VALUE = 22
|
||||
ApiParserLexerID = 23
|
||||
ApiParserLexerT__12 = 13
|
||||
ApiParserLexerATDOC = 14
|
||||
ApiParserLexerATHANDLER = 15
|
||||
ApiParserLexerINTERFACE = 16
|
||||
ApiParserLexerATSERVER = 17
|
||||
ApiParserLexerWS = 18
|
||||
ApiParserLexerCOMMENT = 19
|
||||
ApiParserLexerLINE_COMMENT = 20
|
||||
ApiParserLexerSTRING = 21
|
||||
ApiParserLexerRAW_STRING = 22
|
||||
ApiParserLexerLINE_VALUE = 23
|
||||
ApiParserLexerID = 24
|
||||
)
|
||||
|
||||
const COMEMNTS = 88
|
||||
|
||||
5235
tools/goctl/api/parser/g4/gen/api/apiparser_parser.go
Normal file → Executable file
5235
tools/goctl/api/parser/g4/gen/api/apiparser_parser.go
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
615
tools/goctl/api/parser/g4/gen/api/apiparser_parser1.go
Executable file
615
tools/goctl/api/parser/g4/gen/api/apiparser_parser1.go
Executable file
@@ -0,0 +1,615 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/zeromicro/antlr"
|
||||
)
|
||||
|
||||
// Part 1
|
||||
// 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 (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 {
|
||||
return s.GetToken(ApiParserParserSTRING, 0)
|
||||
}
|
||||
|
||||
func (s *SyntaxLitContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SyntaxLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *SyntaxLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitSyntaxLit(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) SyntaxLit() (localctx ISyntaxLitContext) {
|
||||
localctx = NewSyntaxLitContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 4, ApiParserParserRULE_syntaxLit)
|
||||
|
||||
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)
|
||||
match(p, "syntax")
|
||||
{
|
||||
p.SetState(88)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*SyntaxLitContext).syntaxToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(89)
|
||||
|
||||
_m := p.Match(ApiParserParserT__0)
|
||||
|
||||
localctx.(*SyntaxLitContext).assign = _m
|
||||
}
|
||||
checkVersion(p)
|
||||
{
|
||||
p.SetState(91)
|
||||
|
||||
_m := p.Match(ApiParserParserSTRING)
|
||||
|
||||
localctx.(*SyntaxLitContext).version = _m
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IImportSpecContext is an interface to support dynamic dispatch.
|
||||
type IImportSpecContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// IsImportSpecContext differentiates from other interfaces.
|
||||
IsImportSpecContext()
|
||||
}
|
||||
|
||||
type ImportSpecContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
}
|
||||
|
||||
func NewEmptyImportSpecContext() *ImportSpecContext {
|
||||
p := new(ImportSpecContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_importSpec
|
||||
return p
|
||||
}
|
||||
|
||||
func (*ImportSpecContext) IsImportSpecContext() {}
|
||||
|
||||
func NewImportSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportSpecContext {
|
||||
p := new(ImportSpecContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_importSpec
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *ImportSpecContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *ImportSpecContext) ImportLit() IImportLitContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportLitContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IImportLitContext)
|
||||
}
|
||||
|
||||
func (s *ImportSpecContext) ImportBlock() IImportBlockContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IImportBlockContext)
|
||||
}
|
||||
|
||||
func (s *ImportSpecContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *ImportSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *ImportSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitImportSpec(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) ImportSpec() (localctx IImportSpecContext) {
|
||||
localctx = NewImportSpecContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 6, ApiParserParserRULE_importSpec)
|
||||
|
||||
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(95)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 2, p.GetParserRuleContext()) {
|
||||
case 1:
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
{
|
||||
p.SetState(93)
|
||||
p.ImportLit()
|
||||
}
|
||||
|
||||
case 2:
|
||||
p.EnterOuterAlt(localctx, 2)
|
||||
{
|
||||
p.SetState(94)
|
||||
p.ImportBlock()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IImportLitContext is an interface to support dynamic dispatch.
|
||||
type IImportLitContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetImportToken returns the importToken token.
|
||||
GetImportToken() antlr.Token
|
||||
|
||||
// SetImportToken sets the importToken token.
|
||||
SetImportToken(antlr.Token)
|
||||
|
||||
// IsImportLitContext differentiates from other interfaces.
|
||||
IsImportLitContext()
|
||||
}
|
||||
|
||||
type ImportLitContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
importToken antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyImportLitContext() *ImportLitContext {
|
||||
p := new(ImportLitContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_importLit
|
||||
return p
|
||||
}
|
||||
|
||||
func (*ImportLitContext) IsImportLitContext() {}
|
||||
|
||||
func NewImportLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportLitContext {
|
||||
p := new(ImportLitContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_importLit
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *ImportLitContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *ImportLitContext) GetImportToken() antlr.Token { return s.importToken }
|
||||
|
||||
func (s *ImportLitContext) SetImportToken(v antlr.Token) { s.importToken = v }
|
||||
|
||||
func (s *ImportLitContext) ImportValue() IImportValueContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IImportValueContext)
|
||||
}
|
||||
|
||||
func (s *ImportLitContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *ImportLitContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *ImportLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *ImportLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitImportLit(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) ImportLit() (localctx IImportLitContext) {
|
||||
localctx = NewImportLitContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 8, ApiParserParserRULE_importLit)
|
||||
|
||||
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)
|
||||
match(p, "import")
|
||||
{
|
||||
p.SetState(98)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*ImportLitContext).importToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(99)
|
||||
p.ImportValue()
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IImportBlockContext is an interface to support dynamic dispatch.
|
||||
type IImportBlockContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetImportToken returns the importToken token.
|
||||
GetImportToken() antlr.Token
|
||||
|
||||
// SetImportToken sets the importToken token.
|
||||
SetImportToken(antlr.Token)
|
||||
|
||||
// IsImportBlockContext differentiates from other interfaces.
|
||||
IsImportBlockContext()
|
||||
}
|
||||
|
||||
type ImportBlockContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
importToken antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyImportBlockContext() *ImportBlockContext {
|
||||
p := new(ImportBlockContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_importBlock
|
||||
return p
|
||||
}
|
||||
|
||||
func (*ImportBlockContext) IsImportBlockContext() {}
|
||||
|
||||
func NewImportBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockContext {
|
||||
p := new(ImportBlockContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_importBlock
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *ImportBlockContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *ImportBlockContext) GetImportToken() antlr.Token { return s.importToken }
|
||||
|
||||
func (s *ImportBlockContext) SetImportToken(v antlr.Token) { s.importToken = v }
|
||||
|
||||
func (s *ImportBlockContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *ImportBlockContext) AllImportBlockValue() []IImportBlockValueContext {
|
||||
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem())
|
||||
tst := make([]IImportBlockValueContext, len(ts))
|
||||
|
||||
for i, t := range ts {
|
||||
if t != nil {
|
||||
tst[i] = t.(IImportBlockValueContext)
|
||||
}
|
||||
}
|
||||
|
||||
return tst
|
||||
}
|
||||
|
||||
func (s *ImportBlockContext) ImportBlockValue(i int) IImportBlockValueContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem(), i)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IImportBlockValueContext)
|
||||
}
|
||||
|
||||
func (s *ImportBlockContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *ImportBlockContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *ImportBlockContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitImportBlock(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) ImportBlock() (localctx IImportBlockContext) {
|
||||
localctx = NewImportBlockContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 10, ApiParserParserRULE_importBlock)
|
||||
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)
|
||||
match(p, "import")
|
||||
{
|
||||
p.SetState(102)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*ImportBlockContext).importToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(103)
|
||||
p.Match(ApiParserParserT__1)
|
||||
}
|
||||
p.SetState(105)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserSTRING {
|
||||
{
|
||||
p.SetState(104)
|
||||
p.ImportBlockValue()
|
||||
}
|
||||
|
||||
p.SetState(107)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
{
|
||||
p.SetState(109)
|
||||
p.Match(ApiParserParserT__2)
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IImportBlockValueContext is an interface to support dynamic dispatch.
|
||||
type IImportBlockValueContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// IsImportBlockValueContext differentiates from other interfaces.
|
||||
IsImportBlockValueContext()
|
||||
}
|
||||
|
||||
type ImportBlockValueContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
}
|
||||
|
||||
func NewEmptyImportBlockValueContext() *ImportBlockValueContext {
|
||||
p := new(ImportBlockValueContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_importBlockValue
|
||||
return p
|
||||
}
|
||||
|
||||
func (*ImportBlockValueContext) IsImportBlockValueContext() {}
|
||||
|
||||
func NewImportBlockValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockValueContext {
|
||||
p := new(ImportBlockValueContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_importBlockValue
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *ImportBlockValueContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *ImportBlockValueContext) ImportValue() IImportValueContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IImportValueContext)
|
||||
}
|
||||
|
||||
func (s *ImportBlockValueContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *ImportBlockValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *ImportBlockValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitImportBlockValue(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) ImportBlockValue() (localctx IImportBlockValueContext) {
|
||||
localctx = NewImportBlockValueContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 12, ApiParserParserRULE_importBlockValue)
|
||||
|
||||
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(111)
|
||||
p.ImportValue()
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IImportValueContext is an interface to support dynamic dispatch.
|
||||
type IImportValueContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// IsImportValueContext differentiates from other interfaces.
|
||||
IsImportValueContext()
|
||||
}
|
||||
|
||||
type ImportValueContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
}
|
||||
|
||||
func NewEmptyImportValueContext() *ImportValueContext {
|
||||
p := new(ImportValueContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_importValue
|
||||
return p
|
||||
}
|
||||
|
||||
func (*ImportValueContext) IsImportValueContext() {}
|
||||
|
||||
func NewImportValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportValueContext {
|
||||
p := new(ImportValueContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_importValue
|
||||
|
||||
return p
|
||||
}
|
||||
656
tools/goctl/api/parser/g4/gen/api/apiparser_parser2.go
Executable file
656
tools/goctl/api/parser/g4/gen/api/apiparser_parser2.go
Executable file
@@ -0,0 +1,656 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/zeromicro/antlr"
|
||||
)
|
||||
|
||||
// Part 2
|
||||
// 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 (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 {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
infoToken antlr.Token
|
||||
lp antlr.Token
|
||||
rp antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyInfoSpecContext() *InfoSpecContext {
|
||||
p := new(InfoSpecContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_infoSpec
|
||||
return p
|
||||
}
|
||||
|
||||
func (*InfoSpecContext) IsInfoSpecContext() {}
|
||||
|
||||
func NewInfoSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InfoSpecContext {
|
||||
p := new(InfoSpecContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_infoSpec
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *InfoSpecContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *InfoSpecContext) GetInfoToken() antlr.Token { return s.infoToken }
|
||||
|
||||
func (s *InfoSpecContext) GetLp() antlr.Token { return s.lp }
|
||||
|
||||
func (s *InfoSpecContext) GetRp() antlr.Token { return s.rp }
|
||||
|
||||
func (s *InfoSpecContext) SetInfoToken(v antlr.Token) { s.infoToken = v }
|
||||
|
||||
func (s *InfoSpecContext) SetLp(v antlr.Token) { s.lp = v }
|
||||
|
||||
func (s *InfoSpecContext) SetRp(v antlr.Token) { s.rp = v }
|
||||
|
||||
func (s *InfoSpecContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *InfoSpecContext) 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 *InfoSpecContext) KvLit(i int) IKvLitContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IKvLitContext)
|
||||
}
|
||||
|
||||
func (s *InfoSpecContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *InfoSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *InfoSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitInfoSpec(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) InfoSpec() (localctx IInfoSpecContext) {
|
||||
localctx = NewInfoSpecContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 16, ApiParserParserRULE_infoSpec)
|
||||
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)
|
||||
match(p, "info")
|
||||
{
|
||||
p.SetState(117)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*InfoSpecContext).infoToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(118)
|
||||
|
||||
_m := p.Match(ApiParserParserT__1)
|
||||
|
||||
localctx.(*InfoSpecContext).lp = _m
|
||||
}
|
||||
p.SetState(120)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserID {
|
||||
{
|
||||
p.SetState(119)
|
||||
p.KvLit()
|
||||
}
|
||||
|
||||
p.SetState(122)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
{
|
||||
p.SetState(124)
|
||||
|
||||
_m := p.Match(ApiParserParserT__2)
|
||||
|
||||
localctx.(*InfoSpecContext).rp = _m
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// ITypeSpecContext is an interface to support dynamic dispatch.
|
||||
type ITypeSpecContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// IsTypeSpecContext differentiates from other interfaces.
|
||||
IsTypeSpecContext()
|
||||
}
|
||||
|
||||
type TypeSpecContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
}
|
||||
|
||||
func NewEmptyTypeSpecContext() *TypeSpecContext {
|
||||
p := new(TypeSpecContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_typeSpec
|
||||
return p
|
||||
}
|
||||
|
||||
func (*TypeSpecContext) IsTypeSpecContext() {}
|
||||
|
||||
func NewTypeSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeSpecContext {
|
||||
p := new(TypeSpecContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_typeSpec
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *TypeSpecContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *TypeSpecContext) TypeLit() ITypeLitContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(ITypeLitContext)
|
||||
}
|
||||
|
||||
func (s *TypeSpecContext) TypeBlock() ITypeBlockContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(ITypeBlockContext)
|
||||
}
|
||||
|
||||
func (s *TypeSpecContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *TypeSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *TypeSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitTypeSpec(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) TypeSpec() (localctx ITypeSpecContext) {
|
||||
localctx = NewTypeSpecContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 18, ApiParserParserRULE_typeSpec)
|
||||
|
||||
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(128)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 5, p.GetParserRuleContext()) {
|
||||
case 1:
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
{
|
||||
p.SetState(126)
|
||||
p.TypeLit()
|
||||
}
|
||||
|
||||
case 2:
|
||||
p.EnterOuterAlt(localctx, 2)
|
||||
{
|
||||
p.SetState(127)
|
||||
p.TypeBlock()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// ITypeLitContext is an interface to support dynamic dispatch.
|
||||
type ITypeLitContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetTypeToken returns the typeToken token.
|
||||
GetTypeToken() antlr.Token
|
||||
|
||||
// SetTypeToken sets the typeToken token.
|
||||
SetTypeToken(antlr.Token)
|
||||
|
||||
// IsTypeLitContext differentiates from other interfaces.
|
||||
IsTypeLitContext()
|
||||
}
|
||||
|
||||
type TypeLitContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
typeToken antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyTypeLitContext() *TypeLitContext {
|
||||
p := new(TypeLitContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_typeLit
|
||||
return p
|
||||
}
|
||||
|
||||
func (*TypeLitContext) IsTypeLitContext() {}
|
||||
|
||||
func NewTypeLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitContext {
|
||||
p := new(TypeLitContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_typeLit
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *TypeLitContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *TypeLitContext) GetTypeToken() antlr.Token { return s.typeToken }
|
||||
|
||||
func (s *TypeLitContext) SetTypeToken(v antlr.Token) { s.typeToken = v }
|
||||
|
||||
func (s *TypeLitContext) TypeLitBody() ITypeLitBodyContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitBodyContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(ITypeLitBodyContext)
|
||||
}
|
||||
|
||||
func (s *TypeLitContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *TypeLitContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *TypeLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *TypeLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitTypeLit(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) TypeLit() (localctx ITypeLitContext) {
|
||||
localctx = NewTypeLitContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 20, ApiParserParserRULE_typeLit)
|
||||
|
||||
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)
|
||||
match(p, "type")
|
||||
{
|
||||
p.SetState(131)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*TypeLitContext).typeToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(132)
|
||||
p.TypeLitBody()
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// ITypeBlockContext is an interface to support dynamic dispatch.
|
||||
type ITypeBlockContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetTypeToken returns the typeToken token.
|
||||
GetTypeToken() antlr.Token
|
||||
|
||||
// GetLp returns the lp token.
|
||||
GetLp() antlr.Token
|
||||
|
||||
// GetRp returns the rp token.
|
||||
GetRp() antlr.Token
|
||||
|
||||
// SetTypeToken sets the typeToken token.
|
||||
SetTypeToken(antlr.Token)
|
||||
|
||||
// SetLp sets the lp token.
|
||||
SetLp(antlr.Token)
|
||||
|
||||
// SetRp sets the rp token.
|
||||
SetRp(antlr.Token)
|
||||
|
||||
// IsTypeBlockContext differentiates from other interfaces.
|
||||
IsTypeBlockContext()
|
||||
}
|
||||
|
||||
type TypeBlockContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
typeToken antlr.Token
|
||||
lp antlr.Token
|
||||
rp antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyTypeBlockContext() *TypeBlockContext {
|
||||
p := new(TypeBlockContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_typeBlock
|
||||
return p
|
||||
}
|
||||
|
||||
func (*TypeBlockContext) IsTypeBlockContext() {}
|
||||
|
||||
func NewTypeBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockContext {
|
||||
p := new(TypeBlockContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_typeBlock
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *TypeBlockContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *TypeBlockContext) GetTypeToken() antlr.Token { return s.typeToken }
|
||||
|
||||
func (s *TypeBlockContext) GetLp() antlr.Token { return s.lp }
|
||||
|
||||
func (s *TypeBlockContext) GetRp() antlr.Token { return s.rp }
|
||||
|
||||
func (s *TypeBlockContext) SetTypeToken(v antlr.Token) { s.typeToken = v }
|
||||
|
||||
func (s *TypeBlockContext) SetLp(v antlr.Token) { s.lp = v }
|
||||
|
||||
func (s *TypeBlockContext) SetRp(v antlr.Token) { s.rp = v }
|
||||
|
||||
func (s *TypeBlockContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *TypeBlockContext) AllTypeBlockBody() []ITypeBlockBodyContext {
|
||||
ts := s.GetTypedRuleContexts(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem())
|
||||
tst := make([]ITypeBlockBodyContext, len(ts))
|
||||
|
||||
for i, t := range ts {
|
||||
if t != nil {
|
||||
tst[i] = t.(ITypeBlockBodyContext)
|
||||
}
|
||||
}
|
||||
|
||||
return tst
|
||||
}
|
||||
|
||||
func (s *TypeBlockContext) TypeBlockBody(i int) ITypeBlockBodyContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem(), i)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(ITypeBlockBodyContext)
|
||||
}
|
||||
|
||||
func (s *TypeBlockContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *TypeBlockContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *TypeBlockContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitTypeBlock(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) TypeBlock() (localctx ITypeBlockContext) {
|
||||
localctx = NewTypeBlockContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 22, ApiParserParserRULE_typeBlock)
|
||||
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)
|
||||
match(p, "type")
|
||||
{
|
||||
p.SetState(135)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*TypeBlockContext).typeToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(136)
|
||||
|
||||
_m := p.Match(ApiParserParserT__1)
|
||||
|
||||
localctx.(*TypeBlockContext).lp = _m
|
||||
}
|
||||
p.SetState(140)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
for _la == ApiParserParserID {
|
||||
{
|
||||
p.SetState(137)
|
||||
p.TypeBlockBody()
|
||||
}
|
||||
|
||||
p.SetState(142)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
{
|
||||
p.SetState(143)
|
||||
|
||||
_m := p.Match(ApiParserParserT__2)
|
||||
|
||||
localctx.(*TypeBlockContext).rp = _m
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
634
tools/goctl/api/parser/g4/gen/api/apiparser_parser3.go
Executable file
634
tools/goctl/api/parser/g4/gen/api/apiparser_parser3.go
Executable file
@@ -0,0 +1,634 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/zeromicro/antlr"
|
||||
)
|
||||
|
||||
// Part 3
|
||||
// The apiparser_parser.go file was split into multiple files because it
|
||||
// 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.
|
||||
type ITypeBlockBodyContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// IsTypeBlockBodyContext differentiates from other interfaces.
|
||||
IsTypeBlockBodyContext()
|
||||
}
|
||||
|
||||
type TypeBlockBodyContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
}
|
||||
|
||||
func NewEmptyTypeBlockBodyContext() *TypeBlockBodyContext {
|
||||
p := new(TypeBlockBodyContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_typeBlockBody
|
||||
return p
|
||||
}
|
||||
|
||||
func (*TypeBlockBodyContext) IsTypeBlockBodyContext() {}
|
||||
|
||||
func NewTypeBlockBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockBodyContext {
|
||||
p := new(TypeBlockBodyContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_typeBlockBody
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *TypeBlockBodyContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *TypeBlockBodyContext) TypeBlockStruct() ITypeBlockStructContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockStructContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(ITypeBlockStructContext)
|
||||
}
|
||||
|
||||
func (s *TypeBlockBodyContext) TypeBlockAlias() ITypeBlockAliasContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockAliasContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(ITypeBlockAliasContext)
|
||||
}
|
||||
|
||||
func (s *TypeBlockBodyContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *TypeBlockBodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *TypeBlockBodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitTypeBlockBody(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) TypeBlockBody() (localctx ITypeBlockBodyContext) {
|
||||
localctx = NewTypeBlockBodyContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 26, ApiParserParserRULE_typeBlockBody)
|
||||
|
||||
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(151)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 8, p.GetParserRuleContext()) {
|
||||
case 1:
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
{
|
||||
p.SetState(149)
|
||||
p.TypeBlockStruct()
|
||||
}
|
||||
|
||||
case 2:
|
||||
p.EnterOuterAlt(localctx, 2)
|
||||
{
|
||||
p.SetState(150)
|
||||
p.TypeBlockAlias()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// ITypeStructContext is an interface to support dynamic dispatch.
|
||||
type ITypeStructContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetStructName returns the structName token.
|
||||
GetStructName() antlr.Token
|
||||
|
||||
// GetStructToken returns the structToken token.
|
||||
GetStructToken() antlr.Token
|
||||
|
||||
// GetLbrace returns the lbrace token.
|
||||
GetLbrace() antlr.Token
|
||||
|
||||
// GetRbrace returns the rbrace token.
|
||||
GetRbrace() antlr.Token
|
||||
|
||||
// SetStructName sets the structName token.
|
||||
SetStructName(antlr.Token)
|
||||
|
||||
// SetStructToken sets the structToken token.
|
||||
SetStructToken(antlr.Token)
|
||||
|
||||
// SetLbrace sets the lbrace token.
|
||||
SetLbrace(antlr.Token)
|
||||
|
||||
// SetRbrace sets the rbrace token.
|
||||
SetRbrace(antlr.Token)
|
||||
|
||||
// IsTypeStructContext differentiates from other interfaces.
|
||||
IsTypeStructContext()
|
||||
}
|
||||
|
||||
type TypeStructContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
structName antlr.Token
|
||||
structToken antlr.Token
|
||||
lbrace antlr.Token
|
||||
rbrace antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyTypeStructContext() *TypeStructContext {
|
||||
p := new(TypeStructContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_typeStruct
|
||||
return p
|
||||
}
|
||||
|
||||
func (*TypeStructContext) IsTypeStructContext() {}
|
||||
|
||||
func NewTypeStructContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeStructContext {
|
||||
p := new(TypeStructContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_typeStruct
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *TypeStructContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *TypeStructContext) GetStructName() antlr.Token { return s.structName }
|
||||
|
||||
func (s *TypeStructContext) GetStructToken() antlr.Token { return s.structToken }
|
||||
|
||||
func (s *TypeStructContext) GetLbrace() antlr.Token { return s.lbrace }
|
||||
|
||||
func (s *TypeStructContext) GetRbrace() antlr.Token { return s.rbrace }
|
||||
|
||||
func (s *TypeStructContext) SetStructName(v antlr.Token) { s.structName = v }
|
||||
|
||||
func (s *TypeStructContext) SetStructToken(v antlr.Token) { s.structToken = v }
|
||||
|
||||
func (s *TypeStructContext) SetLbrace(v antlr.Token) { s.lbrace = v }
|
||||
|
||||
func (s *TypeStructContext) SetRbrace(v antlr.Token) { s.rbrace = v }
|
||||
|
||||
func (s *TypeStructContext) AllID() []antlr.TerminalNode {
|
||||
return s.GetTokens(ApiParserParserID)
|
||||
}
|
||||
|
||||
func (s *TypeStructContext) ID(i int) antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, i)
|
||||
}
|
||||
|
||||
func (s *TypeStructContext) 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 *TypeStructContext) Field(i int) IFieldContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IFieldContext)
|
||||
}
|
||||
|
||||
func (s *TypeStructContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *TypeStructContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *TypeStructContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitTypeStruct(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) TypeStruct() (localctx ITypeStructContext) {
|
||||
localctx = NewTypeStructContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 28, ApiParserParserRULE_typeStruct)
|
||||
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(154)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*TypeStructContext).structName = _m
|
||||
}
|
||||
p.SetState(156)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserID {
|
||||
{
|
||||
p.SetState(155)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*TypeStructContext).structToken = _m
|
||||
}
|
||||
}
|
||||
{
|
||||
p.SetState(158)
|
||||
|
||||
_m := p.Match(ApiParserParserT__3)
|
||||
|
||||
localctx.(*TypeStructContext).lbrace = _m
|
||||
}
|
||||
p.SetState(162)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext())
|
||||
|
||||
for _alt != 2 && _alt != antlr.ATNInvalidAltNumber {
|
||||
if _alt == 1 {
|
||||
{
|
||||
p.SetState(159)
|
||||
p.Field()
|
||||
}
|
||||
}
|
||||
p.SetState(164)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext())
|
||||
}
|
||||
{
|
||||
p.SetState(165)
|
||||
|
||||
_m := p.Match(ApiParserParserT__4)
|
||||
|
||||
localctx.(*TypeStructContext).rbrace = _m
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// ITypeAliasContext is an interface to support dynamic dispatch.
|
||||
type ITypeAliasContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetAlias returns the alias token.
|
||||
GetAlias() antlr.Token
|
||||
|
||||
// GetAssign returns the assign token.
|
||||
GetAssign() antlr.Token
|
||||
|
||||
// SetAlias sets the alias token.
|
||||
SetAlias(antlr.Token)
|
||||
|
||||
// SetAssign sets the assign token.
|
||||
SetAssign(antlr.Token)
|
||||
|
||||
// IsTypeAliasContext differentiates from other interfaces.
|
||||
IsTypeAliasContext()
|
||||
}
|
||||
|
||||
type TypeAliasContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
alias antlr.Token
|
||||
assign antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyTypeAliasContext() *TypeAliasContext {
|
||||
p := new(TypeAliasContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_typeAlias
|
||||
return p
|
||||
}
|
||||
|
||||
func (*TypeAliasContext) IsTypeAliasContext() {}
|
||||
|
||||
func NewTypeAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeAliasContext {
|
||||
p := new(TypeAliasContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_typeAlias
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *TypeAliasContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *TypeAliasContext) GetAlias() antlr.Token { return s.alias }
|
||||
|
||||
func (s *TypeAliasContext) GetAssign() antlr.Token { return s.assign }
|
||||
|
||||
func (s *TypeAliasContext) SetAlias(v antlr.Token) { s.alias = v }
|
||||
|
||||
func (s *TypeAliasContext) SetAssign(v antlr.Token) { s.assign = v }
|
||||
|
||||
func (s *TypeAliasContext) DataType() IDataTypeContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IDataTypeContext)
|
||||
}
|
||||
|
||||
func (s *TypeAliasContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *TypeAliasContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *TypeAliasContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *TypeAliasContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitTypeAlias(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) TypeAlias() (localctx ITypeAliasContext) {
|
||||
localctx = NewTypeAliasContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 30, ApiParserParserRULE_typeAlias)
|
||||
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)
|
||||
checkKeyword(p)
|
||||
{
|
||||
p.SetState(168)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*TypeAliasContext).alias = _m
|
||||
}
|
||||
p.SetState(170)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserT__0 {
|
||||
{
|
||||
p.SetState(169)
|
||||
|
||||
_m := p.Match(ApiParserParserT__0)
|
||||
|
||||
localctx.(*TypeAliasContext).assign = _m
|
||||
}
|
||||
}
|
||||
{
|
||||
p.SetState(172)
|
||||
p.DataType()
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// ITypeBlockStructContext is an interface to support dynamic dispatch.
|
||||
type ITypeBlockStructContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetStructName returns the structName token.
|
||||
GetStructName() antlr.Token
|
||||
|
||||
// GetStructToken returns the structToken token.
|
||||
GetStructToken() antlr.Token
|
||||
|
||||
// GetLbrace returns the lbrace token.
|
||||
GetLbrace() antlr.Token
|
||||
|
||||
// GetRbrace returns the rbrace token.
|
||||
GetRbrace() antlr.Token
|
||||
|
||||
// SetStructName sets the structName token.
|
||||
SetStructName(antlr.Token)
|
||||
|
||||
// SetStructToken sets the structToken token.
|
||||
SetStructToken(antlr.Token)
|
||||
|
||||
// SetLbrace sets the lbrace token.
|
||||
SetLbrace(antlr.Token)
|
||||
|
||||
// SetRbrace sets the rbrace token.
|
||||
SetRbrace(antlr.Token)
|
||||
|
||||
// IsTypeBlockStructContext differentiates from other interfaces.
|
||||
IsTypeBlockStructContext()
|
||||
}
|
||||
613
tools/goctl/api/parser/g4/gen/api/apiparser_parser4.go
Executable file
613
tools/goctl/api/parser/g4/gen/api/apiparser_parser4.go
Executable file
@@ -0,0 +1,613 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/zeromicro/antlr"
|
||||
)
|
||||
|
||||
// Part 4
|
||||
// The apiparser_parser.go file was split into multiple files because it
|
||||
// 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.
|
||||
type ITypeBlockAliasContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetAlias returns the alias token.
|
||||
GetAlias() antlr.Token
|
||||
|
||||
// GetAssign returns the assign token.
|
||||
GetAssign() antlr.Token
|
||||
|
||||
// SetAlias sets the alias token.
|
||||
SetAlias(antlr.Token)
|
||||
|
||||
// SetAssign sets the assign token.
|
||||
SetAssign(antlr.Token)
|
||||
|
||||
// IsTypeBlockAliasContext differentiates from other interfaces.
|
||||
IsTypeBlockAliasContext()
|
||||
}
|
||||
|
||||
type TypeBlockAliasContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
alias antlr.Token
|
||||
assign antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyTypeBlockAliasContext() *TypeBlockAliasContext {
|
||||
p := new(TypeBlockAliasContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_typeBlockAlias
|
||||
return p
|
||||
}
|
||||
|
||||
func (*TypeBlockAliasContext) IsTypeBlockAliasContext() {}
|
||||
|
||||
func NewTypeBlockAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockAliasContext {
|
||||
p := new(TypeBlockAliasContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_typeBlockAlias
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *TypeBlockAliasContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *TypeBlockAliasContext) GetAlias() antlr.Token { return s.alias }
|
||||
|
||||
func (s *TypeBlockAliasContext) GetAssign() antlr.Token { return s.assign }
|
||||
|
||||
func (s *TypeBlockAliasContext) SetAlias(v antlr.Token) { s.alias = v }
|
||||
|
||||
func (s *TypeBlockAliasContext) SetAssign(v antlr.Token) { s.assign = v }
|
||||
|
||||
func (s *TypeBlockAliasContext) DataType() IDataTypeContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IDataTypeContext)
|
||||
}
|
||||
|
||||
func (s *TypeBlockAliasContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *TypeBlockAliasContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *TypeBlockAliasContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *TypeBlockAliasContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitTypeBlockAlias(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) TypeBlockAlias() (localctx ITypeBlockAliasContext) {
|
||||
localctx = NewTypeBlockAliasContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 34, ApiParserParserRULE_typeBlockAlias)
|
||||
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)
|
||||
checkKeyword(p)
|
||||
{
|
||||
p.SetState(189)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*TypeBlockAliasContext).alias = _m
|
||||
}
|
||||
p.SetState(191)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserT__0 {
|
||||
{
|
||||
p.SetState(190)
|
||||
|
||||
_m := p.Match(ApiParserParserT__0)
|
||||
|
||||
localctx.(*TypeBlockAliasContext).assign = _m
|
||||
}
|
||||
}
|
||||
{
|
||||
p.SetState(193)
|
||||
p.DataType()
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IFieldContext is an interface to support dynamic dispatch.
|
||||
type IFieldContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// IsFieldContext differentiates from other interfaces.
|
||||
IsFieldContext()
|
||||
}
|
||||
|
||||
type FieldContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
}
|
||||
|
||||
func NewEmptyFieldContext() *FieldContext {
|
||||
p := new(FieldContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_field
|
||||
return p
|
||||
}
|
||||
|
||||
func (*FieldContext) IsFieldContext() {}
|
||||
|
||||
func NewFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FieldContext {
|
||||
p := new(FieldContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_field
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *FieldContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *FieldContext) NormalField() INormalFieldContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*INormalFieldContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(INormalFieldContext)
|
||||
}
|
||||
|
||||
func (s *FieldContext) AnonymousFiled() IAnonymousFiledContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IAnonymousFiledContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IAnonymousFiledContext)
|
||||
}
|
||||
|
||||
func (s *FieldContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *FieldContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *FieldContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitField(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) Field() (localctx IFieldContext) {
|
||||
localctx = NewFieldContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 36, ApiParserParserRULE_field)
|
||||
|
||||
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(198)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 15, p.GetParserRuleContext()) {
|
||||
case 1:
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
p.SetState(195)
|
||||
|
||||
if !(isNormal(p)) {
|
||||
panic(antlr.NewFailedPredicateException(p, "isNormal(p)", ""))
|
||||
}
|
||||
{
|
||||
p.SetState(196)
|
||||
p.NormalField()
|
||||
}
|
||||
|
||||
case 2:
|
||||
p.EnterOuterAlt(localctx, 2)
|
||||
{
|
||||
p.SetState(197)
|
||||
p.AnonymousFiled()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// INormalFieldContext is an interface to support dynamic dispatch.
|
||||
type INormalFieldContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetFieldName returns the fieldName token.
|
||||
GetFieldName() antlr.Token
|
||||
|
||||
// GetTag returns the tag token.
|
||||
GetTag() antlr.Token
|
||||
|
||||
// SetFieldName sets the fieldName token.
|
||||
SetFieldName(antlr.Token)
|
||||
|
||||
// SetTag sets the tag token.
|
||||
SetTag(antlr.Token)
|
||||
|
||||
// IsNormalFieldContext differentiates from other interfaces.
|
||||
IsNormalFieldContext()
|
||||
}
|
||||
|
||||
type NormalFieldContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
fieldName antlr.Token
|
||||
tag antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyNormalFieldContext() *NormalFieldContext {
|
||||
p := new(NormalFieldContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_normalField
|
||||
return p
|
||||
}
|
||||
|
||||
func (*NormalFieldContext) IsNormalFieldContext() {}
|
||||
|
||||
func NewNormalFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *NormalFieldContext {
|
||||
p := new(NormalFieldContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_normalField
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *NormalFieldContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *NormalFieldContext) GetFieldName() antlr.Token { return s.fieldName }
|
||||
|
||||
func (s *NormalFieldContext) GetTag() antlr.Token { return s.tag }
|
||||
|
||||
func (s *NormalFieldContext) SetFieldName(v antlr.Token) { s.fieldName = v }
|
||||
|
||||
func (s *NormalFieldContext) SetTag(v antlr.Token) { s.tag = v }
|
||||
|
||||
func (s *NormalFieldContext) DataType() IDataTypeContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IDataTypeContext)
|
||||
}
|
||||
|
||||
func (s *NormalFieldContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *NormalFieldContext) RAW_STRING() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserRAW_STRING, 0)
|
||||
}
|
||||
|
||||
func (s *NormalFieldContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *NormalFieldContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *NormalFieldContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitNormalField(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) NormalField() (localctx INormalFieldContext) {
|
||||
localctx = NewNormalFieldContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 38, ApiParserParserRULE_normalField)
|
||||
|
||||
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)
|
||||
checkKeyword(p)
|
||||
{
|
||||
p.SetState(201)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*NormalFieldContext).fieldName = _m
|
||||
}
|
||||
{
|
||||
p.SetState(202)
|
||||
p.DataType()
|
||||
}
|
||||
p.SetState(204)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
if p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 16, p.GetParserRuleContext()) == 1 {
|
||||
{
|
||||
p.SetState(203)
|
||||
|
||||
_m := p.Match(ApiParserParserRAW_STRING)
|
||||
|
||||
localctx.(*NormalFieldContext).tag = _m
|
||||
}
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IAnonymousFiledContext is an interface to support dynamic dispatch.
|
||||
type IAnonymousFiledContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetStar returns the star token.
|
||||
GetStar() antlr.Token
|
||||
|
||||
// SetStar sets the star token.
|
||||
SetStar(antlr.Token)
|
||||
|
||||
// IsAnonymousFiledContext differentiates from other interfaces.
|
||||
IsAnonymousFiledContext()
|
||||
}
|
||||
617
tools/goctl/api/parser/g4/gen/api/apiparser_parser5.go
Executable file
617
tools/goctl/api/parser/g4/gen/api/apiparser_parser5.go
Executable file
@@ -0,0 +1,617 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/zeromicro/antlr"
|
||||
)
|
||||
|
||||
// Part 5
|
||||
// The apiparser_parser.go file was split into multiple files because it
|
||||
// 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) {
|
||||
localctx = NewDataTypeContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 42, ApiParserParserRULE_dataType)
|
||||
|
||||
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(219)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 18, p.GetParserRuleContext()) {
|
||||
case 1:
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
isInterface(p)
|
||||
{
|
||||
p.SetState(212)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
|
||||
case 2:
|
||||
p.EnterOuterAlt(localctx, 2)
|
||||
{
|
||||
p.SetState(213)
|
||||
p.MapType()
|
||||
}
|
||||
|
||||
case 3:
|
||||
p.EnterOuterAlt(localctx, 3)
|
||||
{
|
||||
p.SetState(214)
|
||||
p.ArrayType()
|
||||
}
|
||||
|
||||
case 4:
|
||||
p.EnterOuterAlt(localctx, 4)
|
||||
{
|
||||
p.SetState(215)
|
||||
|
||||
_m := p.Match(ApiParserParserINTERFACE)
|
||||
|
||||
localctx.(*DataTypeContext).inter = _m
|
||||
}
|
||||
|
||||
case 5:
|
||||
p.EnterOuterAlt(localctx, 5)
|
||||
{
|
||||
p.SetState(216)
|
||||
|
||||
_m := p.Match(ApiParserParserT__6)
|
||||
|
||||
localctx.(*DataTypeContext).time = _m
|
||||
}
|
||||
|
||||
case 6:
|
||||
p.EnterOuterAlt(localctx, 6)
|
||||
{
|
||||
p.SetState(217)
|
||||
p.PointerType()
|
||||
}
|
||||
|
||||
case 7:
|
||||
p.EnterOuterAlt(localctx, 7)
|
||||
{
|
||||
p.SetState(218)
|
||||
p.TypeStruct()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IPointerTypeContext is an interface to support dynamic dispatch.
|
||||
type IPointerTypeContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetStar returns the star token.
|
||||
GetStar() antlr.Token
|
||||
|
||||
// SetStar sets the star token.
|
||||
SetStar(antlr.Token)
|
||||
|
||||
// IsPointerTypeContext differentiates from other interfaces.
|
||||
IsPointerTypeContext()
|
||||
}
|
||||
|
||||
type PointerTypeContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
star antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyPointerTypeContext() *PointerTypeContext {
|
||||
p := new(PointerTypeContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_pointerType
|
||||
return p
|
||||
}
|
||||
|
||||
func (*PointerTypeContext) IsPointerTypeContext() {}
|
||||
|
||||
func NewPointerTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PointerTypeContext {
|
||||
p := new(PointerTypeContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_pointerType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *PointerTypeContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *PointerTypeContext) GetStar() antlr.Token { return s.star }
|
||||
|
||||
func (s *PointerTypeContext) SetStar(v antlr.Token) { s.star = v }
|
||||
|
||||
func (s *PointerTypeContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *PointerTypeContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *PointerTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *PointerTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitPointerType(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) PointerType() (localctx IPointerTypeContext) {
|
||||
localctx = NewPointerTypeContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 44, ApiParserParserRULE_pointerType)
|
||||
|
||||
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(221)
|
||||
|
||||
_m := p.Match(ApiParserParserT__5)
|
||||
|
||||
localctx.(*PointerTypeContext).star = _m
|
||||
}
|
||||
checkKeyword(p)
|
||||
{
|
||||
p.SetState(223)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IMapTypeContext is an interface to support dynamic dispatch.
|
||||
type IMapTypeContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetMapToken returns the mapToken token.
|
||||
GetMapToken() antlr.Token
|
||||
|
||||
// GetLbrack returns the lbrack token.
|
||||
GetLbrack() antlr.Token
|
||||
|
||||
// GetKey returns the key token.
|
||||
GetKey() antlr.Token
|
||||
|
||||
// GetRbrack returns the rbrack token.
|
||||
GetRbrack() antlr.Token
|
||||
|
||||
// SetMapToken sets the mapToken token.
|
||||
SetMapToken(antlr.Token)
|
||||
|
||||
// SetLbrack sets the lbrack token.
|
||||
SetLbrack(antlr.Token)
|
||||
|
||||
// SetKey sets the key token.
|
||||
SetKey(antlr.Token)
|
||||
|
||||
// SetRbrack sets the rbrack token.
|
||||
SetRbrack(antlr.Token)
|
||||
|
||||
// GetValue returns the value rule contexts.
|
||||
GetValue() IDataTypeContext
|
||||
|
||||
// SetValue sets the value rule contexts.
|
||||
SetValue(IDataTypeContext)
|
||||
|
||||
// IsMapTypeContext differentiates from other interfaces.
|
||||
IsMapTypeContext()
|
||||
}
|
||||
|
||||
type MapTypeContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
mapToken antlr.Token
|
||||
lbrack antlr.Token
|
||||
key antlr.Token
|
||||
rbrack antlr.Token
|
||||
value IDataTypeContext
|
||||
}
|
||||
|
||||
func NewEmptyMapTypeContext() *MapTypeContext {
|
||||
p := new(MapTypeContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_mapType
|
||||
return p
|
||||
}
|
||||
|
||||
func (*MapTypeContext) IsMapTypeContext() {}
|
||||
|
||||
func NewMapTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MapTypeContext {
|
||||
p := new(MapTypeContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_mapType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *MapTypeContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *MapTypeContext) GetMapToken() antlr.Token { return s.mapToken }
|
||||
|
||||
func (s *MapTypeContext) GetLbrack() antlr.Token { return s.lbrack }
|
||||
|
||||
func (s *MapTypeContext) GetKey() antlr.Token { return s.key }
|
||||
|
||||
func (s *MapTypeContext) GetRbrack() antlr.Token { return s.rbrack }
|
||||
|
||||
func (s *MapTypeContext) SetMapToken(v antlr.Token) { s.mapToken = v }
|
||||
|
||||
func (s *MapTypeContext) SetLbrack(v antlr.Token) { s.lbrack = v }
|
||||
|
||||
func (s *MapTypeContext) SetKey(v antlr.Token) { s.key = v }
|
||||
|
||||
func (s *MapTypeContext) SetRbrack(v antlr.Token) { s.rbrack = v }
|
||||
|
||||
func (s *MapTypeContext) GetValue() IDataTypeContext { return s.value }
|
||||
|
||||
func (s *MapTypeContext) SetValue(v IDataTypeContext) { s.value = v }
|
||||
|
||||
func (s *MapTypeContext) AllID() []antlr.TerminalNode {
|
||||
return s.GetTokens(ApiParserParserID)
|
||||
}
|
||||
|
||||
func (s *MapTypeContext) ID(i int) antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, i)
|
||||
}
|
||||
|
||||
func (s *MapTypeContext) DataType() IDataTypeContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IDataTypeContext)
|
||||
}
|
||||
|
||||
func (s *MapTypeContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *MapTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *MapTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitMapType(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) MapType() (localctx IMapTypeContext) {
|
||||
localctx = NewMapTypeContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 46, ApiParserParserRULE_mapType)
|
||||
|
||||
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)
|
||||
match(p, "map")
|
||||
{
|
||||
p.SetState(226)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*MapTypeContext).mapToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(227)
|
||||
|
||||
_m := p.Match(ApiParserParserT__7)
|
||||
|
||||
localctx.(*MapTypeContext).lbrack = _m
|
||||
}
|
||||
checkKey(p)
|
||||
{
|
||||
p.SetState(229)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*MapTypeContext).key = _m
|
||||
}
|
||||
{
|
||||
p.SetState(230)
|
||||
|
||||
_m := p.Match(ApiParserParserT__8)
|
||||
|
||||
localctx.(*MapTypeContext).rbrack = _m
|
||||
}
|
||||
{
|
||||
p.SetState(231)
|
||||
|
||||
_x := p.DataType()
|
||||
|
||||
localctx.(*MapTypeContext).value = _x
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
612
tools/goctl/api/parser/g4/gen/api/apiparser_parser6.go
Executable file
612
tools/goctl/api/parser/g4/gen/api/apiparser_parser6.go
Executable file
@@ -0,0 +1,612 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/zeromicro/antlr"
|
||||
)
|
||||
|
||||
// Part 6
|
||||
// The apiparser_parser.go file was split into multiple files because it
|
||||
// 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 {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
lp antlr.Token
|
||||
rp antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyAtServerContext() *AtServerContext {
|
||||
p := new(AtServerContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_atServer
|
||||
return p
|
||||
}
|
||||
|
||||
func (*AtServerContext) IsAtServerContext() {}
|
||||
|
||||
func NewAtServerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtServerContext {
|
||||
p := new(AtServerContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_atServer
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *AtServerContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *AtServerContext) GetLp() antlr.Token { return s.lp }
|
||||
|
||||
func (s *AtServerContext) GetRp() antlr.Token { return s.rp }
|
||||
|
||||
func (s *AtServerContext) SetLp(v antlr.Token) { s.lp = v }
|
||||
|
||||
func (s *AtServerContext) SetRp(v antlr.Token) { s.rp = v }
|
||||
|
||||
func (s *AtServerContext) ATSERVER() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserATSERVER, 0)
|
||||
}
|
||||
|
||||
func (s *AtServerContext) 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 *AtServerContext) KvLit(i int) IKvLitContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IKvLitContext)
|
||||
}
|
||||
|
||||
func (s *AtServerContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *AtServerContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *AtServerContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitAtServer(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) AtServer() (localctx IAtServerContext) {
|
||||
localctx = NewAtServerContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 52, ApiParserParserRULE_atServer)
|
||||
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(242)
|
||||
p.Match(ApiParserParserATSERVER)
|
||||
}
|
||||
{
|
||||
p.SetState(243)
|
||||
|
||||
_m := p.Match(ApiParserParserT__1)
|
||||
|
||||
localctx.(*AtServerContext).lp = _m
|
||||
}
|
||||
p.SetState(245)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserID {
|
||||
{
|
||||
p.SetState(244)
|
||||
p.KvLit()
|
||||
}
|
||||
|
||||
p.SetState(247)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
{
|
||||
p.SetState(249)
|
||||
|
||||
_m := p.Match(ApiParserParserT__2)
|
||||
|
||||
localctx.(*AtServerContext).rp = _m
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IServiceApiContext is an interface to support dynamic dispatch.
|
||||
type IServiceApiContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetServiceToken returns the serviceToken token.
|
||||
GetServiceToken() antlr.Token
|
||||
|
||||
// GetLbrace returns the lbrace token.
|
||||
GetLbrace() antlr.Token
|
||||
|
||||
// GetRbrace returns the rbrace token.
|
||||
GetRbrace() antlr.Token
|
||||
|
||||
// SetServiceToken sets the serviceToken token.
|
||||
SetServiceToken(antlr.Token)
|
||||
|
||||
// SetLbrace sets the lbrace token.
|
||||
SetLbrace(antlr.Token)
|
||||
|
||||
// SetRbrace sets the rbrace token.
|
||||
SetRbrace(antlr.Token)
|
||||
|
||||
// IsServiceApiContext differentiates from other interfaces.
|
||||
IsServiceApiContext()
|
||||
}
|
||||
|
||||
type ServiceApiContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
serviceToken antlr.Token
|
||||
lbrace antlr.Token
|
||||
rbrace antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyServiceApiContext() *ServiceApiContext {
|
||||
p := new(ServiceApiContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_serviceApi
|
||||
return p
|
||||
}
|
||||
|
||||
func (*ServiceApiContext) IsServiceApiContext() {}
|
||||
|
||||
func NewServiceApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceApiContext {
|
||||
p := new(ServiceApiContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_serviceApi
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *ServiceApiContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *ServiceApiContext) GetServiceToken() antlr.Token { return s.serviceToken }
|
||||
|
||||
func (s *ServiceApiContext) GetLbrace() antlr.Token { return s.lbrace }
|
||||
|
||||
func (s *ServiceApiContext) GetRbrace() antlr.Token { return s.rbrace }
|
||||
|
||||
func (s *ServiceApiContext) SetServiceToken(v antlr.Token) { s.serviceToken = v }
|
||||
|
||||
func (s *ServiceApiContext) SetLbrace(v antlr.Token) { s.lbrace = v }
|
||||
|
||||
func (s *ServiceApiContext) SetRbrace(v antlr.Token) { s.rbrace = v }
|
||||
|
||||
func (s *ServiceApiContext) ServiceName() IServiceNameContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceNameContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IServiceNameContext)
|
||||
}
|
||||
|
||||
func (s *ServiceApiContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *ServiceApiContext) AllServiceRoute() []IServiceRouteContext {
|
||||
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem())
|
||||
tst := make([]IServiceRouteContext, len(ts))
|
||||
|
||||
for i, t := range ts {
|
||||
if t != nil {
|
||||
tst[i] = t.(IServiceRouteContext)
|
||||
}
|
||||
}
|
||||
|
||||
return tst
|
||||
}
|
||||
|
||||
func (s *ServiceApiContext) ServiceRoute(i int) IServiceRouteContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem(), i)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IServiceRouteContext)
|
||||
}
|
||||
|
||||
func (s *ServiceApiContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *ServiceApiContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *ServiceApiContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitServiceApi(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) ServiceApi() (localctx IServiceApiContext) {
|
||||
localctx = NewServiceApiContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 54, ApiParserParserRULE_serviceApi)
|
||||
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)
|
||||
match(p, "service")
|
||||
{
|
||||
p.SetState(252)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*ServiceApiContext).serviceToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(253)
|
||||
p.ServiceName()
|
||||
}
|
||||
{
|
||||
p.SetState(254)
|
||||
|
||||
_m := p.Match(ApiParserParserT__3)
|
||||
|
||||
localctx.(*ServiceApiContext).lbrace = _m
|
||||
}
|
||||
p.SetState(258)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
for ((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<ApiParserParserATDOC)|(1<<ApiParserParserATHANDLER)|(1<<ApiParserParserATSERVER))) != 0 {
|
||||
{
|
||||
p.SetState(255)
|
||||
p.ServiceRoute()
|
||||
}
|
||||
|
||||
p.SetState(260)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
{
|
||||
p.SetState(261)
|
||||
|
||||
_m := p.Match(ApiParserParserT__4)
|
||||
|
||||
localctx.(*ServiceApiContext).rbrace = _m
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
643
tools/goctl/api/parser/g4/gen/api/apiparser_parser7.go
Executable file
643
tools/goctl/api/parser/g4/gen/api/apiparser_parser7.go
Executable file
@@ -0,0 +1,643 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/zeromicro/antlr"
|
||||
)
|
||||
|
||||
// Part 7
|
||||
// The apiparser_parser.go file was split into multiple files because it
|
||||
// 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.
|
||||
type IAtHandlerContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// IsAtHandlerContext differentiates from other interfaces.
|
||||
IsAtHandlerContext()
|
||||
}
|
||||
|
||||
type AtHandlerContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
}
|
||||
|
||||
func NewEmptyAtHandlerContext() *AtHandlerContext {
|
||||
p := new(AtHandlerContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_atHandler
|
||||
return p
|
||||
}
|
||||
|
||||
func (*AtHandlerContext) IsAtHandlerContext() {}
|
||||
|
||||
func NewAtHandlerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtHandlerContext {
|
||||
p := new(AtHandlerContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_atHandler
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *AtHandlerContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *AtHandlerContext) ATHANDLER() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserATHANDLER, 0)
|
||||
}
|
||||
|
||||
func (s *AtHandlerContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *AtHandlerContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *AtHandlerContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *AtHandlerContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitAtHandler(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) AtHandler() (localctx IAtHandlerContext) {
|
||||
localctx = NewAtHandlerContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 60, ApiParserParserRULE_atHandler)
|
||||
|
||||
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(287)
|
||||
p.Match(ApiParserParserATHANDLER)
|
||||
}
|
||||
{
|
||||
p.SetState(288)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IRouteContext is an interface to support dynamic dispatch.
|
||||
type IRouteContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetHttpMethod returns the httpMethod token.
|
||||
GetHttpMethod() antlr.Token
|
||||
|
||||
// SetHttpMethod sets the httpMethod token.
|
||||
SetHttpMethod(antlr.Token)
|
||||
|
||||
// GetRequest returns the request rule contexts.
|
||||
GetRequest() IBodyContext
|
||||
|
||||
// GetResponse returns the response rule contexts.
|
||||
GetResponse() IReplybodyContext
|
||||
|
||||
// SetRequest sets the request rule contexts.
|
||||
SetRequest(IBodyContext)
|
||||
|
||||
// SetResponse sets the response rule contexts.
|
||||
SetResponse(IReplybodyContext)
|
||||
|
||||
// IsRouteContext differentiates from other interfaces.
|
||||
IsRouteContext()
|
||||
}
|
||||
|
||||
type RouteContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
httpMethod antlr.Token
|
||||
request IBodyContext
|
||||
response IReplybodyContext
|
||||
}
|
||||
|
||||
func NewEmptyRouteContext() *RouteContext {
|
||||
p := new(RouteContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_route
|
||||
return p
|
||||
}
|
||||
|
||||
func (*RouteContext) IsRouteContext() {}
|
||||
|
||||
func NewRouteContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RouteContext {
|
||||
p := new(RouteContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_route
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *RouteContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *RouteContext) GetHttpMethod() antlr.Token { return s.httpMethod }
|
||||
|
||||
func (s *RouteContext) SetHttpMethod(v antlr.Token) { s.httpMethod = v }
|
||||
|
||||
func (s *RouteContext) GetRequest() IBodyContext { return s.request }
|
||||
|
||||
func (s *RouteContext) GetResponse() IReplybodyContext { return s.response }
|
||||
|
||||
func (s *RouteContext) SetRequest(v IBodyContext) { s.request = v }
|
||||
|
||||
func (s *RouteContext) SetResponse(v IReplybodyContext) { s.response = v }
|
||||
|
||||
func (s *RouteContext) Path() IPathContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IPathContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IPathContext)
|
||||
}
|
||||
|
||||
func (s *RouteContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *RouteContext) Body() IBodyContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IBodyContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IBodyContext)
|
||||
}
|
||||
|
||||
func (s *RouteContext) Replybody() IReplybodyContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IReplybodyContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IReplybodyContext)
|
||||
}
|
||||
|
||||
func (s *RouteContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *RouteContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *RouteContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitRoute(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) Route() (localctx IRouteContext) {
|
||||
localctx = NewRouteContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 62, ApiParserParserRULE_route)
|
||||
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)
|
||||
checkHTTPMethod(p)
|
||||
{
|
||||
p.SetState(291)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*RouteContext).httpMethod = _m
|
||||
}
|
||||
{
|
||||
p.SetState(292)
|
||||
p.Path()
|
||||
}
|
||||
p.SetState(294)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserT__1 {
|
||||
{
|
||||
p.SetState(293)
|
||||
|
||||
_x := p.Body()
|
||||
|
||||
localctx.(*RouteContext).request = _x
|
||||
}
|
||||
}
|
||||
p.SetState(297)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserT__9 {
|
||||
{
|
||||
p.SetState(296)
|
||||
|
||||
_x := p.Replybody()
|
||||
|
||||
localctx.(*RouteContext).response = _x
|
||||
}
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
712
tools/goctl/api/parser/g4/gen/api/apiparser_parser8.go
Executable file
712
tools/goctl/api/parser/g4/gen/api/apiparser_parser8.go
Executable file
@@ -0,0 +1,712 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/zeromicro/antlr"
|
||||
)
|
||||
|
||||
// Part 8
|
||||
// The apiparser_parser.go file was split into multiple files because it
|
||||
// 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{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitKvLit(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) KvLit() (localctx IKvLitContext) {
|
||||
localctx = NewKvLitContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 68, ApiParserParserRULE_kvLit)
|
||||
|
||||
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(312)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*KvLitContext).key = _m
|
||||
}
|
||||
checkKeyValue(p)
|
||||
{
|
||||
p.SetState(314)
|
||||
|
||||
_m := p.Match(ApiParserParserLINE_VALUE)
|
||||
|
||||
localctx.(*KvLitContext).value = _m
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IServiceNameContext is an interface to support dynamic dispatch.
|
||||
type IServiceNameContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// IsServiceNameContext differentiates from other interfaces.
|
||||
IsServiceNameContext()
|
||||
}
|
||||
|
||||
type ServiceNameContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
}
|
||||
|
||||
func NewEmptyServiceNameContext() *ServiceNameContext {
|
||||
p := new(ServiceNameContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_serviceName
|
||||
return p
|
||||
}
|
||||
|
||||
func (*ServiceNameContext) IsServiceNameContext() {}
|
||||
|
||||
func NewServiceNameContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceNameContext {
|
||||
p := new(ServiceNameContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_serviceName
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *ServiceNameContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *ServiceNameContext) AllID() []antlr.TerminalNode {
|
||||
return s.GetTokens(ApiParserParserID)
|
||||
}
|
||||
|
||||
func (s *ServiceNameContext) ID(i int) antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, i)
|
||||
}
|
||||
|
||||
func (s *ServiceNameContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *ServiceNameContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *ServiceNameContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitServiceName(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) ServiceName() (localctx IServiceNameContext) {
|
||||
localctx = NewServiceNameContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 70, ApiParserParserRULE_serviceName)
|
||||
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(320)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserID {
|
||||
{
|
||||
p.SetState(316)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
p.SetState(318)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserT__10 {
|
||||
{
|
||||
p.SetState(317)
|
||||
p.Match(ApiParserParserT__10)
|
||||
}
|
||||
}
|
||||
|
||||
p.SetState(322)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IPathContext is an interface to support dynamic dispatch.
|
||||
type IPathContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// IsPathContext differentiates from other interfaces.
|
||||
IsPathContext()
|
||||
}
|
||||
|
||||
type PathContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
}
|
||||
|
||||
func NewEmptyPathContext() *PathContext {
|
||||
p := new(PathContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_path
|
||||
return p
|
||||
}
|
||||
|
||||
func (*PathContext) IsPathContext() {}
|
||||
|
||||
func NewPathContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PathContext {
|
||||
p := new(PathContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_path
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *PathContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *PathContext) AllID() []antlr.TerminalNode {
|
||||
return s.GetTokens(ApiParserParserID)
|
||||
}
|
||||
|
||||
func (s *PathContext) ID(i int) antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, i)
|
||||
}
|
||||
|
||||
func (s *PathContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *PathContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *PathContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitPath(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) Path() (localctx IPathContext) {
|
||||
localctx = NewPathContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 72, ApiParserParserRULE_path)
|
||||
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.SetState(344)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 38, p.GetParserRuleContext()) {
|
||||
case 1:
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
p.SetState(339)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserT__11 || _la == ApiParserParserT__12 {
|
||||
p.SetState(339)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
switch p.GetTokenStream().LA(1) {
|
||||
case ApiParserParserT__11:
|
||||
{
|
||||
p.SetState(324)
|
||||
p.Match(ApiParserParserT__11)
|
||||
}
|
||||
|
||||
{
|
||||
p.SetState(325)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
p.SetState(330)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
for _la == ApiParserParserT__10 {
|
||||
{
|
||||
p.SetState(326)
|
||||
p.Match(ApiParserParserT__10)
|
||||
}
|
||||
{
|
||||
p.SetState(327)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
|
||||
p.SetState(332)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
|
||||
case ApiParserParserT__12:
|
||||
{
|
||||
p.SetState(333)
|
||||
p.Match(ApiParserParserT__12)
|
||||
}
|
||||
|
||||
{
|
||||
p.SetState(334)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
p.SetState(337)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserT__10 {
|
||||
{
|
||||
p.SetState(335)
|
||||
p.Match(ApiParserParserT__10)
|
||||
}
|
||||
{
|
||||
p.SetState(336)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
default:
|
||||
panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
|
||||
}
|
||||
|
||||
p.SetState(341)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
|
||||
case 2:
|
||||
p.EnterOuterAlt(localctx, 2)
|
||||
{
|
||||
p.SetState(343)
|
||||
p.Match(ApiParserParserT__11)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
35
tools/goctl/api/parser/g4/gen/api/apiparser_parser9.go
Executable file
35
tools/goctl/api/parser/g4/gen/api/apiparser_parser9.go
Executable file
@@ -0,0 +1,35 @@
|
||||
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))
|
||||
}
|
||||
}
|
||||
@@ -1,120 +1,119 @@
|
||||
// Code generated from tools/goctl/api/parser/g4/ApiParser.g4 by ANTLR 4.9. DO NOT EDIT.
|
||||
|
||||
package api // ApiParser
|
||||
|
||||
import "github.com/zeromicro/antlr"
|
||||
|
||||
// A complete Visitor for a parse tree produced by ApiParserParser.
|
||||
// ApiParserVisitor is a complete Visitor for a parse tree produced by ApiParserParser.
|
||||
type ApiParserVisitor interface {
|
||||
antlr.ParseTreeVisitor
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#api.
|
||||
// VisitApi is a parse tree produced by ApiParserParser#api.
|
||||
VisitApi(ctx *ApiContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#spec.
|
||||
// VisitSpec is a parse tree produced by ApiParserParser#spec.
|
||||
VisitSpec(ctx *SpecContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#syntaxLit.
|
||||
// VisitSyntaxLit is a parse tree produced by ApiParserParser#syntaxLit.
|
||||
VisitSyntaxLit(ctx *SyntaxLitContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#importSpec.
|
||||
// VisitImportSpec is a parse tree produced by ApiParserParser#importSpec.
|
||||
VisitImportSpec(ctx *ImportSpecContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#importLit.
|
||||
// VisitImportLit is a parse tree produced by ApiParserParser#importLit.
|
||||
VisitImportLit(ctx *ImportLitContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#importBlock.
|
||||
// VisitImportBlock is a parse tree produced by ApiParserParser#importBlock.
|
||||
VisitImportBlock(ctx *ImportBlockContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#importBlockValue.
|
||||
// VisitImportBlockValue is a parse tree produced by ApiParserParser#importBlockValue.
|
||||
VisitImportBlockValue(ctx *ImportBlockValueContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#importValue.
|
||||
// VisitImportValue is a parse tree produced by ApiParserParser#importValue.
|
||||
VisitImportValue(ctx *ImportValueContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#infoSpec.
|
||||
// VisitInfoSpec is a parse tree produced by ApiParserParser#infoSpec.
|
||||
VisitInfoSpec(ctx *InfoSpecContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#typeSpec.
|
||||
// VisitTypeSpec is a parse tree produced by ApiParserParser#typeSpec.
|
||||
VisitTypeSpec(ctx *TypeSpecContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#typeLit.
|
||||
// VisitTypeLit is a parse tree produced by ApiParserParser#typeLit.
|
||||
VisitTypeLit(ctx *TypeLitContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#typeBlock.
|
||||
// VisitTypeBlock is a parse tree produced by ApiParserParser#typeBlock.
|
||||
VisitTypeBlock(ctx *TypeBlockContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#typeLitBody.
|
||||
// VisitTypeLitBody is a parse tree produced by ApiParserParser#typeLitBody.
|
||||
VisitTypeLitBody(ctx *TypeLitBodyContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#typeBlockBody.
|
||||
// VisitTypeBlockBody is a parse tree produced by ApiParserParser#typeBlockBody.
|
||||
VisitTypeBlockBody(ctx *TypeBlockBodyContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#typeStruct.
|
||||
// VisitTypeStruct is a parse tree produced by ApiParserParser#typeStruct.
|
||||
VisitTypeStruct(ctx *TypeStructContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#typeAlias.
|
||||
// VisitTypeAlias is a parse tree produced by ApiParserParser#typeAlias.
|
||||
VisitTypeAlias(ctx *TypeAliasContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#typeBlockStruct.
|
||||
// VisitTypeBlockStruct is a parse tree produced by ApiParserParser#typeBlockStruct.
|
||||
VisitTypeBlockStruct(ctx *TypeBlockStructContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#typeBlockAlias.
|
||||
// VisitTypeBlockAlias is a parse tree produced by ApiParserParser#typeBlockAlias.
|
||||
VisitTypeBlockAlias(ctx *TypeBlockAliasContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#field.
|
||||
// VisitField is a parse tree produced by ApiParserParser#field.
|
||||
VisitField(ctx *FieldContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#normalField.
|
||||
// VisitNormalField is a parse tree produced by ApiParserParser#normalField.
|
||||
VisitNormalField(ctx *NormalFieldContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#anonymousFiled.
|
||||
// VisitAnonymousFiled is a parse tree produced by ApiParserParser#anonymousFiled.
|
||||
VisitAnonymousFiled(ctx *AnonymousFiledContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#dataType.
|
||||
// VisitDataType is a parse tree produced by ApiParserParser#dataType.
|
||||
VisitDataType(ctx *DataTypeContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#pointerType.
|
||||
// VisitPointerType is a parse tree produced by ApiParserParser#pointerType.
|
||||
VisitPointerType(ctx *PointerTypeContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#mapType.
|
||||
// VisitMapType is a parse tree produced by ApiParserParser#mapType.
|
||||
VisitMapType(ctx *MapTypeContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#arrayType.
|
||||
// VisitArrayType is a parse tree produced by ApiParserParser#arrayType.
|
||||
VisitArrayType(ctx *ArrayTypeContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#serviceSpec.
|
||||
// VisitServiceSpec is a parse tree produced by ApiParserParser#serviceSpec.
|
||||
VisitServiceSpec(ctx *ServiceSpecContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#atServer.
|
||||
// VisitAtServer is a parse tree produced by ApiParserParser#atServer.
|
||||
VisitAtServer(ctx *AtServerContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#serviceApi.
|
||||
// VisitServiceApi is a parse tree produced by ApiParserParser#serviceApi.
|
||||
VisitServiceApi(ctx *ServiceApiContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#serviceRoute.
|
||||
// VisitServiceRoute is a parse tree produced by ApiParserParser#serviceRoute.
|
||||
VisitServiceRoute(ctx *ServiceRouteContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#atDoc.
|
||||
// VisitAtDoc is a parse tree produced by ApiParserParser#atDoc.
|
||||
VisitAtDoc(ctx *AtDocContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#atHandler.
|
||||
// VisitAtHandler is a parse tree produced by ApiParserParser#atHandler.
|
||||
VisitAtHandler(ctx *AtHandlerContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#route.
|
||||
// VisitRoute is a parse tree produced by ApiParserParser#route.
|
||||
VisitRoute(ctx *RouteContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#body.
|
||||
// VisitBody is a parse tree produced by ApiParserParser#body.
|
||||
VisitBody(ctx *BodyContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#replybody.
|
||||
// VisitReplybody is a parse tree produced by ApiParserParser#replybody.
|
||||
VisitReplybody(ctx *ReplybodyContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#kvLit.
|
||||
// VisitKvLit is a parse tree produced by ApiParserParser#kvLit.
|
||||
VisitKvLit(ctx *KvLitContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#serviceName.
|
||||
// VisitServiceName is a parse tree produced by ApiParserParser#serviceName.
|
||||
VisitServiceName(ctx *ServiceNameContext) interface{}
|
||||
|
||||
// Visit a parse tree produced by ApiParserParser#path.
|
||||
// VisitPath is a parse tree produced by ApiParserParser#path.
|
||||
VisitPath(ctx *PathContext) interface{}
|
||||
}
|
||||
|
||||
79
tools/goctl/api/parser/g4/gen/api/file_splitor_test.go
Normal file
79
tools/goctl/api/parser/g4/gen/api/file_splitor_test.go
Normal file
@@ -0,0 +1,79 @@
|
||||
// DO NOT EDIT.
|
||||
// Tool: split apiparser_parser.go
|
||||
// The apiparser_parser.go file was split into multiple files because it
|
||||
// was too large and caused a possible memory overflow during goctl installation.
|
||||
package api
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFileSplitor(t *testing.T) {
|
||||
dir := "."
|
||||
data, err := ioutil.ReadFile(filepath.Join(dir, "apiparser_parser.go"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
r := bytes.NewReader(data)
|
||||
reader := bufio.NewReader(r)
|
||||
var lines, files int
|
||||
buffer := bytes.NewBuffer(nil)
|
||||
|
||||
for {
|
||||
fn, part := "apiparser_parser0.go", "main"
|
||||
if files > 0 {
|
||||
fn = fmt.Sprintf("apiparser_parser%d.go", files)
|
||||
part = fmt.Sprintf("%d", files)
|
||||
}
|
||||
fp := filepath.Join(dir, fn)
|
||||
buffer.Reset()
|
||||
if files > 0 {
|
||||
buffer.WriteString(fmt.Sprintf(`package api
|
||||
import "github.com/zeromicro/antlr"
|
||||
|
||||
// Part %s
|
||||
// The apiparser_parser.go file was split into multiple files because it
|
||||
// was too large and caused a possible memory overflow during goctl installation.
|
||||
`, part))
|
||||
}
|
||||
|
||||
var exit bool
|
||||
for {
|
||||
line, _, err := reader.ReadLine()
|
||||
buffer.Write(line)
|
||||
buffer.WriteRune('\n')
|
||||
if err != nil {
|
||||
fmt.Printf("%+v\n", err)
|
||||
exit = true
|
||||
break
|
||||
}
|
||||
lines += 1
|
||||
if string(line) == "}" && lines >= 650 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(fp, buffer.Bytes(), os.ModePerm)
|
||||
if err != nil {
|
||||
fmt.Printf("%+v\n", err)
|
||||
}
|
||||
if exit {
|
||||
break
|
||||
}
|
||||
lines = 0
|
||||
files += 1
|
||||
}
|
||||
|
||||
err = os.Rename(filepath.Join(dir, "apiparser_parser0.go"), filepath.Join(dir, "apiparser_parser.go"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
@@ -164,8 +164,8 @@ func TestRoute(t *testing.T) {
|
||||
_, err = parser.Accept(fn, `post foo/bar`)
|
||||
assert.Error(t, err)
|
||||
|
||||
_, err = parser.Accept(fn, `post /foo/bar return (Bar)`)
|
||||
assert.Error(t, err)
|
||||
_, err = parser.Accept(fn, `post /foo/bar returns (Bar)`)
|
||||
assert.Nil(t, err)
|
||||
|
||||
_, err = parser.Accept(fn, ` /foo/bar returns (Bar)`)
|
||||
assert.Error(t, err)
|
||||
@@ -174,7 +174,7 @@ func TestRoute(t *testing.T) {
|
||||
assert.Error(t, err)
|
||||
|
||||
_, err = parser.Accept(fn, ` post /foo/bar returns (int)`)
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, err)
|
||||
|
||||
_, err = parser.Accept(fn, ` post /foo/bar returns (*int)`)
|
||||
assert.Error(t, err)
|
||||
|
||||
51
tools/goctl/bug/bug.go
Normal file
51
tools/goctl/bug/bug.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package bug
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/internal/version"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
const (
|
||||
windows = "windows"
|
||||
darwin = "darwin"
|
||||
|
||||
windowsOpen = "start"
|
||||
darwinOpen = "open"
|
||||
linuxOpen = "xdg-open"
|
||||
|
||||
os = "OS"
|
||||
arch = "ARCH"
|
||||
goctlVersion = "GOCTL_VERSION"
|
||||
goVersion = "GO_VERSION"
|
||||
)
|
||||
|
||||
var openCmd = map[string]string{
|
||||
windows: windowsOpen,
|
||||
darwin: darwinOpen,
|
||||
}
|
||||
|
||||
func Action(_ *cli.Context) error {
|
||||
env := getEnv()
|
||||
content := fmt.Sprintf(issueTemplate, version.BuildVersion, env.string())
|
||||
content = url.QueryEscape(content)
|
||||
url := fmt.Sprintf("https://github.com/zeromicro/go-zero/issues/new?body=%s", content)
|
||||
|
||||
goos := runtime.GOOS
|
||||
var cmd string
|
||||
var args []string
|
||||
cmd, ok := openCmd[goos]
|
||||
if !ok {
|
||||
cmd = linuxOpen
|
||||
}
|
||||
if goos == windows {
|
||||
args = []string{"/c", "start"}
|
||||
}
|
||||
|
||||
args = append(args, url)
|
||||
return exec.Command(cmd, args...).Start()
|
||||
}
|
||||
34
tools/goctl/bug/env.go
Normal file
34
tools/goctl/bug/env.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package bug
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/internal/version"
|
||||
)
|
||||
|
||||
type env map[string]string
|
||||
|
||||
func (e env) string() string {
|
||||
if e == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
w := bytes.NewBuffer(nil)
|
||||
for k, v := range e {
|
||||
w.WriteString(fmt.Sprintf("%s = %q\n", k, v))
|
||||
}
|
||||
|
||||
return strings.TrimSuffix(w.String(), "\n")
|
||||
}
|
||||
|
||||
func getEnv() env {
|
||||
e := make(env)
|
||||
e[os] = runtime.GOOS
|
||||
e[arch] = runtime.GOARCH
|
||||
e[goctlVersion] = version.BuildVersion
|
||||
e[goVersion] = runtime.Version()
|
||||
return e
|
||||
}
|
||||
42
tools/goctl/bug/issue.go
Normal file
42
tools/goctl/bug/issue.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package bug
|
||||
|
||||
const issueTemplate = `
|
||||
<!-- Please answer these questions before submitting your issue. Thanks! -->
|
||||
|
||||
### What category of issue (<code>goctl</code> or <code>sdk</code>)?
|
||||
|
||||
### What type of issue (<code>feature</code>|<code>bug</code>|<code>suggestion</code>)?
|
||||
|
||||
### What version of Goctl are you using (<code>goctl --version</code>)?
|
||||
|
||||
<pre>
|
||||
$ goctl --version
|
||||
%s
|
||||
</pre>
|
||||
|
||||
### Does this issue reproduce with the latest release?
|
||||
|
||||
|
||||
### What operating system and processor architecture are you using ?
|
||||
<pre>
|
||||
%s
|
||||
</pre>
|
||||
|
||||
### What did you do?
|
||||
|
||||
<!--
|
||||
If possible, provide a recipe for reproducing the error.
|
||||
A complete runnable program is good.
|
||||
A link on play.golang.org is best.
|
||||
-->
|
||||
|
||||
|
||||
|
||||
### What did you expect to see?
|
||||
|
||||
|
||||
|
||||
### What did you see instead?
|
||||
|
||||
|
||||
`
|
||||
@@ -44,6 +44,13 @@ func DockerCommand(c *cli.Context) (err error) {
|
||||
goFile := c.String("go")
|
||||
home := c.String("home")
|
||||
version := c.String("version")
|
||||
remote := c.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := util.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
|
||||
if len(version) > 0 {
|
||||
version = version + "-"
|
||||
|
||||
37
tools/goctl/go.mod
Normal file
37
tools/goctl/go.mod
Normal file
@@ -0,0 +1,37 @@
|
||||
module github.com/tal-tech/go-zero/tools/goctl
|
||||
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0
|
||||
github.com/emicklei/proto v1.9.1
|
||||
github.com/fatih/structtag v1.2.0
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
github.com/iancoleman/strcase v0.2.0
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tal-tech/go-zero v1.2.5-0.20211230062155-e4ab51857606
|
||||
github.com/urfave/cli v1.22.5
|
||||
github.com/zeromicro/antlr v0.0.1
|
||||
github.com/zeromicro/ddl-parser v0.0.0-20210712021150-63520aca7348
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
|
||||
github.com/alicebob/miniredis/v2 v2.16.0 // indirect
|
||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/go-redis/redis v6.15.9+incompatible // indirect
|
||||
github.com/lib/pq v1.10.3 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.0.1 // indirect
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da // indirect
|
||||
go.opentelemetry.io/otel v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.1.0 // indirect
|
||||
go.uber.org/automaxprocs v1.4.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
)
|
||||
693
tools/goctl/go.sum
Normal file
693
tools/goctl/go.sum
Normal file
@@ -0,0 +1,693 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
|
||||
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
|
||||
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
|
||||
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
||||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
|
||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
|
||||
github.com/Azure/go-autorest/autorest v0.11.1/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw=
|
||||
github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQWWNcK9YU+MH96NgK+jErpbcg=
|
||||
github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A=
|
||||
github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.4.0/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k=
|
||||
github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8=
|
||||
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/ClickHouse/clickhouse-go v1.5.1/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI=
|
||||
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/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
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/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
|
||||
github.com/alicebob/miniredis/v2 v2.16.0 h1:ALkyFg7bSTEd1Mkrb4ppq4fnwjklA59dVtIehXCUZkU=
|
||||
github.com/alicebob/miniredis/v2 v2.16.0/go.mod h1:gquAfGbzn92jvtrSC69+6zZnwSODVXVpYDRaGhWaL6I=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec h1:EEyRvzmpEUZ+I8WmD5cw/vY8EqhambkOqy5iFr0908A=
|
||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
|
||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||||
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emicklei/proto v1.9.1 h1:MUgjFo5xlMwYv72TnF5xmmdKZ04u+dVbv6wdARv16D8=
|
||||
github.com/emicklei/proto v1.9.1/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
|
||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
||||
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
|
||||
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
|
||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
|
||||
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/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
||||
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
|
||||
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
|
||||
github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8=
|
||||
github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
|
||||
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg=
|
||||
github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
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/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
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/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.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
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-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.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.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
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/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
|
||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
|
||||
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
|
||||
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
|
||||
github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
|
||||
github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
|
||||
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/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
|
||||
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/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNEe7i7qA=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
|
||||
github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
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-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
|
||||
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c=
|
||||
github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE=
|
||||
github.com/openzipkin/zipkin-go v0.3.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ=
|
||||
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
||||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
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.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/rabbitmq/amqp091-go v1.1.0/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
||||
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
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.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.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tal-tech/go-zero v1.2.5-0.20211230062155-e4ab51857606 h1:u6Nm/S8pOqHDdjYs8aFBxDGC1BfjVmJoOus4g2RanZE=
|
||||
github.com/tal-tech/go-zero v1.2.5-0.20211230062155-e4ab51857606/go.mod h1:OM2UangPHFMJ+5boRUaeQ/z6xpVvqprZda/JUWG1D7Y=
|
||||
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
|
||||
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
|
||||
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da h1:NimzV1aGyq29m5ukMK0AMWEhFaL/lrEOaephfuoiARg=
|
||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
|
||||
github.com/zeromicro/antlr v0.0.1 h1:CQpIn/dc0pUjgGQ81y98s/NGOm2Hfru2NNio2I9mQgk=
|
||||
github.com/zeromicro/antlr v0.0.1/go.mod h1:nfpjEwFR6Q4xGDJMcZnCL9tEfQRgszMwu3rDz2Z+p5M=
|
||||
github.com/zeromicro/ddl-parser v0.0.0-20210712021150-63520aca7348 h1:OhxL9tn28gDeJVzreIUiE5oVxZCjL3tBJ0XBNw8p5R8=
|
||||
github.com/zeromicro/ddl-parser v0.0.0-20210712021150-63520aca7348/go.mod h1:ISU/8NuPyEpl9pa17Py9TBPetMjtsiHrb9f5XGiYbo8=
|
||||
go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
||||
go.etcd.io/etcd/client/v3 v3.5.1/go.mod h1:OnjH4M8OnAotwaB2l9bVgZzRFKru7/ZMoS46OtKyd3Q=
|
||||
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.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opentelemetry.io/otel v1.1.0 h1:8p0uMLcyyIx0KHNTgO8o3CW8A1aA+dJZJW6PvnMz0Wc=
|
||||
go.opentelemetry.io/otel v1.1.0/go.mod h1:7cww0OW51jQ8IaZChIEdqLwgh+44+7uiTdWsAL0wQpA=
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.1.0/go.mod h1:D/GIBwAdrFTTqCy1iITpC9nh5rgJpIbFVgkhlz2vCXk=
|
||||
go.opentelemetry.io/otel/exporters/zipkin v1.1.0/go.mod h1:LZwDnf1mVGTPMq9hdRUHfFBH30SuQvZ1BJaVywpg0VI=
|
||||
go.opentelemetry.io/otel/sdk v1.1.0 h1:j/1PngUJIDOddkCILQYTevrTIbWd494djgGkSsMit+U=
|
||||
go.opentelemetry.io/otel/sdk v1.1.0/go.mod h1:3aQvM6uLm6C4wJpHtT8Od3vNzeZ34Pqc6bps8MywWzo=
|
||||
go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o=
|
||||
go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI=
|
||||
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/automaxprocs v1.4.0 h1:CpDZl6aOlLhReez+8S3eEotD7Jx0Os++lemPlMULQP0=
|
||||
go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
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-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
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-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b h1:eB48h3HiRycXNy8E0Gf5e0hv7YT6Kt14L/D73G1fuwo=
|
||||
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/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-20190904154756-749cb33beabd/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-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68 h1:Ywe/f3fNleF8I6F6qv3MeFoSZ6CTf2zBMMa/7qVML8M=
|
||||
golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
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-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/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-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.2/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-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-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
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.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
|
||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20210928142010-c7af6a1a74c9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
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.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
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-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/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.25.0/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/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
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 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY=
|
||||
gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
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.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
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-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/api v0.20.12/go.mod h1:A2brwyEkVLM3wQGNnzoAa5JsQRzHK0uoOQ+bsnv7V68=
|
||||
k8s.io/apimachinery v0.20.12/go.mod h1:uM7hCI0NyBymUwgshMgZyte475lxhr+QH6h3cvdnzEc=
|
||||
k8s.io/client-go v0.20.12/go.mod h1:NBJj6Evp73Xy/4v/O/RDRaH0+3JoxNfjRxkyRgrdbsA=
|
||||
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM=
|
||||
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw=
|
||||
k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
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/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/new"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/tsgen"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/validate"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/bug"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/docker"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/internal/errorx"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/internal/version"
|
||||
@@ -34,6 +35,11 @@ import (
|
||||
const codeFailure = 1
|
||||
|
||||
var commands = []cli.Command{
|
||||
{
|
||||
Name: "bug",
|
||||
Usage: "report a bug",
|
||||
Action: bug.Action,
|
||||
},
|
||||
{
|
||||
Name: "upgrade",
|
||||
Usage: "upgrade goctl to latest version",
|
||||
@@ -48,8 +54,15 @@ var commands = []cli.Command{
|
||||
Usage: "the output api file",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
|
||||
"if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
},
|
||||
Action: apigen.ApiCommand,
|
||||
@@ -60,8 +73,19 @@ var commands = []cli.Command{
|
||||
Action: new.CreateServiceCommand,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
|
||||
"if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "style",
|
||||
Usage: "the file naming format, see [https://github.com/zeromicro/go-zero/blob/master/tools/goctl/config/readme.md]",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -128,8 +152,15 @@ var commands = []cli.Command{
|
||||
Usage: "the file naming format, see [https://github.com/tal-tech/go-zero/tree/master/tools/goctl/config/readme.md]",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
|
||||
"if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
},
|
||||
Action: gogen.GoCommand,
|
||||
@@ -249,8 +280,15 @@ var commands = []cli.Command{
|
||||
Value: 0,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
|
||||
"if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version",
|
||||
@@ -342,8 +380,15 @@ var commands = []cli.Command{
|
||||
Value: 10,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
|
||||
"if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
},
|
||||
Action: kube.DeploymentCommand,
|
||||
@@ -367,8 +412,15 @@ var commands = []cli.Command{
|
||||
Usage: "whether the command execution environment is from idea plugin. [optional]",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
|
||||
"if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
},
|
||||
Action: rpc.RPCNew,
|
||||
@@ -382,8 +434,15 @@ var commands = []cli.Command{
|
||||
Usage: "the target path of proto",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time," +
|
||||
" if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
},
|
||||
Action: rpc.RPCTemplate,
|
||||
@@ -417,8 +476,15 @@ var commands = []cli.Command{
|
||||
Usage: "whether the command execution environment is from idea plugin. [optional]",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
|
||||
"if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
},
|
||||
Action: rpc.RPC,
|
||||
@@ -462,8 +528,15 @@ var commands = []cli.Command{
|
||||
Usage: "the name of database [optional]",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
|
||||
"if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
},
|
||||
Action: model.MysqlDDL,
|
||||
@@ -497,8 +570,15 @@ var commands = []cli.Command{
|
||||
Usage: "for idea plugin [optional]",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
|
||||
"if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
},
|
||||
Action: model.MySqlDataSource,
|
||||
@@ -542,8 +622,15 @@ var commands = []cli.Command{
|
||||
Usage: "for idea plugin [optional]",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
|
||||
"if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
},
|
||||
Action: model.PostgreSqlDataSource,
|
||||
@@ -571,8 +658,15 @@ var commands = []cli.Command{
|
||||
Usage: "the file naming format, see [https://github.com/tal-tech/go-zero/tree/master/tools/goctl/config/readme.md]",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template",
|
||||
Name: "home",
|
||||
Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time," +
|
||||
" if they are, --remote has higher priority",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "remote",
|
||||
Usage: "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",
|
||||
},
|
||||
},
|
||||
Action: mongo.Action,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
### goctl 参数说明
|
||||
|
||||
`goctl api [go/java/ts] [-api user/user.api] [-dir ./src]`
|
||||
|
||||
|
||||
> api 后面接生成的语言,现支持go/java/typescript
|
||||
>
|
||||
> -api 自定义api所在路径
|
||||
@@ -140,51 +140,49 @@ service user-api {
|
||||
`goctl api go -api user/user.api -dir user`
|
||||
|
||||
```Plain Text
|
||||
|
||||
.
|
||||
├── internal
|
||||
│ ├── config
|
||||
│ │ └── config.go
|
||||
│ ├── handler
|
||||
│ │ ├── pinghandler.go
|
||||
│ │ ├── profile
|
||||
│ │ │ ├── createprofilehandler.go
|
||||
│ │ │ └── getprofilehandler.go
|
||||
│ │ ├── routes.go
|
||||
│ │ └── user
|
||||
│ │ ├── createuserhandler.go
|
||||
│ │ └── getuserhandler.go
|
||||
│ ├── logic
|
||||
│ │ ├── pinglogic.go
|
||||
│ │ ├── profile
|
||||
│ │ │ ├── createprofilelogic.go
|
||||
│ │ │ └── getprofilelogic.go
|
||||
│ │ └── user
|
||||
│ │ ├── createuserlogic.go
|
||||
│ │ └── getuserlogic.go
|
||||
│ ├── svc
|
||||
│ │ └── servicecontext.go
|
||||
│ └── types
|
||||
│ └── types.go
|
||||
└── user.go
|
||||
|
||||
.
|
||||
├── internal
|
||||
│ ├── config
|
||||
│ │ └── config.go
|
||||
│ ├── handler
|
||||
│ │ ├── pinghandler.go
|
||||
│ │ ├── profile
|
||||
│ │ │ ├── createprofilehandler.go
|
||||
│ │ │ └── getprofilehandler.go
|
||||
│ │ ├── routes.go
|
||||
│ │ └── user
|
||||
│ │ ├── createuserhandler.go
|
||||
│ │ └── getuserhandler.go
|
||||
│ ├── logic
|
||||
│ │ ├── pinglogic.go
|
||||
│ │ ├── profile
|
||||
│ │ │ ├── createprofilelogic.go
|
||||
│ │ │ └── getprofilelogic.go
|
||||
│ │ └── user
|
||||
│ │ ├── createuserlogic.go
|
||||
│ │ └── getuserlogic.go
|
||||
│ ├── svc
|
||||
│ │ └── servicecontext.go
|
||||
│ └── types
|
||||
│ └── types.go
|
||||
└── user.go
|
||||
```
|
||||
|
||||
生成的代码可以直接跑,有几个地方需要改:
|
||||
|
||||
|
||||
* 在`servicecontext.go`里面增加需要传递给logic的一些资源,比如mysql, redis,rpc等
|
||||
* 在定义的get/post/put/delete等请求的handler和logic里增加处理业务逻辑的代码
|
||||
|
||||
#### 根据定义好的api文件生成java代码
|
||||
|
||||
```Plain Text
|
||||
goctl api java -api user/user.api -dir ./src
|
||||
goctl api java -api user/user.api -dir ./src
|
||||
```
|
||||
|
||||
#### 根据定义好的api文件生成typescript代码
|
||||
|
||||
```Plain Text
|
||||
goctl api ts -api user/user.api -dir ./src -webapi ***
|
||||
goctl api ts -api user/user.api -dir ./src -webapi ***
|
||||
```
|
||||
|
||||
ts需要指定webapi所在目录
|
||||
@@ -192,5 +190,5 @@ ts需要指定webapi所在目录
|
||||
#### 根据定义好的api文件生成Dart代码
|
||||
|
||||
```Plain Text
|
||||
goctl api dart -api user/user.api -dir ./src
|
||||
goctl api dart -api user/user.api -dir ./src
|
||||
```
|
||||
|
||||
@@ -6,15 +6,15 @@ import (
|
||||
)
|
||||
|
||||
// BuildVersion is the version of goctl.
|
||||
const BuildVersion = "1.2.3"
|
||||
const BuildVersion = "1.2.4"
|
||||
|
||||
var tag = map[string]int{"pre-alpha": 0, "alpha": 1, "pre-bata": 2, "beta": 3, "released": 4, "": 5}
|
||||
|
||||
// GetGoctlVersion returns BuildVersion
|
||||
func GetGoctlVersion() string {
|
||||
return BuildVersion
|
||||
}
|
||||
|
||||
var tag = map[string]int{"pre-alpha": 0, "alpha": 1, "pre-bata": 2, "beta": 3, "released": 4, "": 5}
|
||||
|
||||
// IsVersionGreaterThan compares whether the current goctl version
|
||||
// is greater than the target version
|
||||
func IsVersionGreaterThan(version, target string) bool {
|
||||
@@ -24,7 +24,8 @@ func IsVersionGreaterThan(version, target string) bool {
|
||||
return true
|
||||
} else if versionNumber < targetVersionNumber {
|
||||
return false
|
||||
} else { // unchecked case, in normal, the goctl version does not contains suffix in release.
|
||||
} else {
|
||||
// unchecked case, in normal, the goctl version does not contain suffix in release.
|
||||
return tag[versionTag] > tag[targetTag]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,13 @@ type Deployment struct {
|
||||
func DeploymentCommand(c *cli.Context) error {
|
||||
nodePort := c.Int("nodePort")
|
||||
home := c.String("home")
|
||||
remote := c.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := util.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
|
||||
if len(home) > 0 {
|
||||
util.RegisterGoctlHome(home)
|
||||
|
||||
@@ -18,7 +18,13 @@ func Action(ctx *cli.Context) error {
|
||||
o := strings.TrimSpace(ctx.String("dir"))
|
||||
s := ctx.String("style")
|
||||
home := ctx.String("home")
|
||||
|
||||
remote := ctx.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := file.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
if len(home) > 0 {
|
||||
file.RegisterGoctlHome(home)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,13 @@ func MysqlDDL(ctx *cli.Context) error {
|
||||
style := ctx.String(flagStyle)
|
||||
database := ctx.String(flagDatabase)
|
||||
home := ctx.String(flagHome)
|
||||
|
||||
remote := ctx.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := file.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
if len(home) > 0 {
|
||||
file.RegisterGoctlHome(home)
|
||||
}
|
||||
@@ -62,7 +68,13 @@ func MySqlDataSource(ctx *cli.Context) error {
|
||||
idea := ctx.Bool(flagIdea)
|
||||
style := ctx.String(flagStyle)
|
||||
home := ctx.String("home")
|
||||
|
||||
remote := ctx.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := file.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
if len(home) > 0 {
|
||||
file.RegisterGoctlHome(home)
|
||||
}
|
||||
@@ -85,7 +97,13 @@ func PostgreSqlDataSource(ctx *cli.Context) error {
|
||||
style := ctx.String(flagStyle)
|
||||
schema := ctx.String(flagSchema)
|
||||
home := ctx.String("home")
|
||||
|
||||
remote := ctx.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := file.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
if len(home) > 0 {
|
||||
file.RegisterGoctlHome(home)
|
||||
}
|
||||
|
||||
@@ -7,11 +7,10 @@ import (
|
||||
"github.com/zeromicro/ddl-parser/parser"
|
||||
)
|
||||
|
||||
var commonMysqlDataTypeMap = map[int]string{
|
||||
var commonMysqlDataTypeMapInt = map[int]string{
|
||||
// For consistency, all integer types are converted to int64
|
||||
// number
|
||||
parser.Bool: "int64",
|
||||
parser.Boolean: "int64",
|
||||
parser.Bit: "byte",
|
||||
parser.TinyInt: "int64",
|
||||
parser.SmallInt: "int64",
|
||||
parser.MediumInt: "int64",
|
||||
@@ -29,6 +28,10 @@ var commonMysqlDataTypeMap = map[int]string{
|
||||
parser.Float8: "float64",
|
||||
parser.Double: "float64",
|
||||
parser.Decimal: "float64",
|
||||
parser.Dec: "float64",
|
||||
parser.Fixed: "float64",
|
||||
parser.Numeric: "float64",
|
||||
parser.Real: "float64",
|
||||
// date&time
|
||||
parser.Date: "time.Time",
|
||||
parser.DateTime: "time.Time",
|
||||
@@ -36,65 +39,93 @@ var commonMysqlDataTypeMap = map[int]string{
|
||||
parser.Time: "string",
|
||||
parser.Year: "int64",
|
||||
// string
|
||||
parser.Char: "string",
|
||||
parser.VarChar: "string",
|
||||
parser.Binary: "string",
|
||||
parser.VarBinary: "string",
|
||||
parser.TinyText: "string",
|
||||
parser.Text: "string",
|
||||
parser.MediumText: "string",
|
||||
parser.LongText: "string",
|
||||
parser.Enum: "string",
|
||||
parser.Set: "string",
|
||||
parser.Json: "string",
|
||||
parser.Blob: "string",
|
||||
parser.LongBlob: "string",
|
||||
parser.MediumBlob: "string",
|
||||
parser.TinyBlob: "string",
|
||||
parser.Char: "string",
|
||||
parser.VarChar: "string",
|
||||
parser.NVarChar: "string",
|
||||
parser.NChar: "string",
|
||||
parser.Character: "string",
|
||||
parser.LongVarChar: "string",
|
||||
parser.LineString: "string",
|
||||
parser.MultiLineString: "string",
|
||||
parser.Binary: "string",
|
||||
parser.VarBinary: "string",
|
||||
parser.TinyText: "string",
|
||||
parser.Text: "string",
|
||||
parser.MediumText: "string",
|
||||
parser.LongText: "string",
|
||||
parser.Enum: "string",
|
||||
parser.Set: "string",
|
||||
parser.Json: "string",
|
||||
parser.Blob: "string",
|
||||
parser.LongBlob: "string",
|
||||
parser.MediumBlob: "string",
|
||||
parser.TinyBlob: "string",
|
||||
// bool
|
||||
parser.Bool: "bool",
|
||||
parser.Boolean: "bool",
|
||||
}
|
||||
|
||||
var commonMysqlDataTypeMap2 = map[string]string{
|
||||
var commonMysqlDataTypeMapString = map[string]string{
|
||||
// For consistency, all integer types are converted to int64
|
||||
// bool
|
||||
"bool": "bool",
|
||||
"boolean": "bool",
|
||||
// number
|
||||
"bool": "int64",
|
||||
"boolean": "int64",
|
||||
"tinyint": "int64",
|
||||
"smallint": "int64",
|
||||
"mediumint": "int64",
|
||||
"int": "int64",
|
||||
"int1": "int64",
|
||||
"int2": "int64",
|
||||
"int3": "int64",
|
||||
"int4": "int64",
|
||||
"int8": "int64",
|
||||
"integer": "int64",
|
||||
"bigint": "int64",
|
||||
"float": "float64",
|
||||
"float4": "float64",
|
||||
"float8": "float64",
|
||||
"double": "float64",
|
||||
"decimal": "float64",
|
||||
// date&time
|
||||
"dec": "float64",
|
||||
"fixed": "float64",
|
||||
"real": "float64",
|
||||
"bit": "byte",
|
||||
// date & time
|
||||
"date": "time.Time",
|
||||
"datetime": "time.Time",
|
||||
"timestamp": "time.Time",
|
||||
"time": "string",
|
||||
"year": "int64",
|
||||
// string
|
||||
"char": "string",
|
||||
"varchar": "string",
|
||||
"binary": "string",
|
||||
"varbinary": "string",
|
||||
"tinytext": "string",
|
||||
"text": "string",
|
||||
"mediumtext": "string",
|
||||
"longtext": "string",
|
||||
"enum": "string",
|
||||
"set": "string",
|
||||
"json": "string",
|
||||
"jsonb": "string",
|
||||
"blob": "string",
|
||||
"longblob": "string",
|
||||
"mediumblob": "string",
|
||||
"tinyblob": "string",
|
||||
"linestring": "string",
|
||||
"multilinestring": "string",
|
||||
"nvarchar": "string",
|
||||
"nchar": "string",
|
||||
"char": "string",
|
||||
"character": "string",
|
||||
"varchar": "string",
|
||||
"binary": "string",
|
||||
"bytea": "string",
|
||||
"longvarbinary": "string",
|
||||
"varbinary": "string",
|
||||
"tinytext": "string",
|
||||
"text": "string",
|
||||
"mediumtext": "string",
|
||||
"longtext": "string",
|
||||
"enum": "string",
|
||||
"set": "string",
|
||||
"json": "string",
|
||||
"jsonb": "string",
|
||||
"blob": "string",
|
||||
"longblob": "string",
|
||||
"mediumblob": "string",
|
||||
"tinyblob": "string",
|
||||
}
|
||||
|
||||
// ConvertDataType converts mysql column type into golang type
|
||||
func ConvertDataType(dataBaseType int, isDefaultNull bool) (string, error) {
|
||||
tp, ok := commonMysqlDataTypeMap[dataBaseType]
|
||||
tp, ok := commonMysqlDataTypeMapInt[dataBaseType]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("unsupported database type: %v", dataBaseType)
|
||||
}
|
||||
@@ -104,7 +135,7 @@ func ConvertDataType(dataBaseType int, isDefaultNull bool) (string, error) {
|
||||
|
||||
// ConvertStringDataType converts mysql column type into golang type
|
||||
func ConvertStringDataType(dataBaseType string, isDefaultNull bool) (string, error) {
|
||||
tp, ok := commonMysqlDataTypeMap2[strings.ToLower(dataBaseType)]
|
||||
tp, ok := commonMysqlDataTypeMapString[strings.ToLower(dataBaseType)]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("unsupported database type: %s", dataBaseType)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func genFields(fields []*parser.Field) (string, error) {
|
||||
}
|
||||
|
||||
func genField(field *parser.Field) (string, error) {
|
||||
tag, err := genTag(field.Name.Source())
|
||||
tag, err := genTag(field.NameOriginal)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ type (
|
||||
|
||||
// Field describes a table field
|
||||
Field struct {
|
||||
NameOriginal string
|
||||
Name stringx.String
|
||||
DataType string
|
||||
Comment string
|
||||
@@ -47,6 +48,19 @@ type (
|
||||
KeyType int
|
||||
)
|
||||
|
||||
func parseNameOriginal(ts []*parser.Table) (nameOriginals [][]string) {
|
||||
var columns []string
|
||||
|
||||
for _, t := range ts {
|
||||
columns = []string{}
|
||||
for _, c := range t.Columns {
|
||||
columns = append(columns, c.Name)
|
||||
}
|
||||
nameOriginals = append(nameOriginals, columns)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Parse parses ddl into golang structure
|
||||
func Parse(filename, database string) ([]*Table, error) {
|
||||
p := parser.NewParser()
|
||||
@@ -55,6 +69,8 @@ func Parse(filename, database string) ([]*Table, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nameOriginals := parseNameOriginal(ts)
|
||||
|
||||
tables := GetSafeTables(ts)
|
||||
indexNameGen := func(column ...string) string {
|
||||
return strings.Join(column, "_")
|
||||
@@ -62,7 +78,7 @@ func Parse(filename, database string) ([]*Table, error) {
|
||||
|
||||
prefix := filepath.Base(filename)
|
||||
var list []*Table
|
||||
for _, e := range tables {
|
||||
for indexTable, e := range tables {
|
||||
columns := e.Columns
|
||||
|
||||
var (
|
||||
@@ -120,9 +136,10 @@ func Parse(filename, database string) ([]*Table, error) {
|
||||
|
||||
var fields []*Field
|
||||
// sort
|
||||
for _, c := range columns {
|
||||
for indexColumn, c := range columns {
|
||||
field, ok := fieldM[c.Name]
|
||||
if ok {
|
||||
field.NameOriginal = nameOriginals[indexTable][indexColumn]
|
||||
fields = append(fields, field)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,13 @@ func RPC(c *cli.Context) error {
|
||||
protoImportPath := c.StringSlice("proto_path")
|
||||
goOptions := c.StringSlice("go_opt")
|
||||
home := c.String("home")
|
||||
|
||||
remote := c.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := util.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
if len(home) > 0 {
|
||||
util.RegisterGoctlHome(home)
|
||||
}
|
||||
@@ -73,7 +79,13 @@ func RPCNew(c *cli.Context) error {
|
||||
}
|
||||
style := c.String("style")
|
||||
home := c.String("home")
|
||||
|
||||
remote := c.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := util.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
if len(home) > 0 {
|
||||
util.RegisterGoctlHome(home)
|
||||
}
|
||||
@@ -102,7 +114,13 @@ func RPCNew(c *cli.Context) error {
|
||||
func RPCTemplate(c *cli.Context) error {
|
||||
protoFile := c.String("o")
|
||||
home := c.String("home")
|
||||
|
||||
remote := c.String("remote")
|
||||
if len(remote) > 0 {
|
||||
repo, _ := util.CloneIntoGitHome(remote)
|
||||
if len(repo) > 0 {
|
||||
home = repo
|
||||
}
|
||||
}
|
||||
if len(home) > 0 {
|
||||
util.RegisterGoctlHome(home)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user