From afd9ff889e1211f11d74fbafa89793aeddd25e52 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 15 Apr 2021 19:49:17 +0800 Subject: [PATCH] chore: update code format. (#628) --- core/breaker/breaker_test.go | 3 +- core/codec/aesecb_test.go | 2 +- core/collection/rollingwindow_test.go | 2 +- core/errorx/callchain_test.go | 2 +- core/fx/retry.go | 2 +- core/fx/retry_test.go | 2 +- core/load/adaptiveshedder.go | 2 +- core/load/adaptiveshedder_test.go | 2 +- core/load/nopshedder.go | 6 +- core/logx/rotatelogger.go | 4 +- core/mapping/unmarshaler_test.go | 6 +- core/mapping/utils_test.go | 4 +- core/queue/queue_test.go | 3 +- core/service/servicegroup.go | 3 +- core/service/servicegroup_test.go | 4 +- core/stores/cache/cachenode_test.go | 2 +- core/stores/kv/store_test.go | 6 +- core/stores/mongo/collection_test.go | 3 +- core/stores/redis/redis.go | 1 - core/stores/redis/redis_test.go | 12 +- core/stores/redis/redislock.go | 3 +- core/stores/sqlx/orm_test.go | 78 ++-- core/stringx/replacer.go | 12 +- core/stringx/replacer_test.go | 10 +- rest/engine_test.go | 3 +- rest/handler/sheddinghandler_test.go | 3 +- tools/goctl/api/dartgen/genapi.go | 6 +- tools/goctl/api/dartgen/gendata.go | 6 +- tools/goctl/api/dartgen/genvars.go | 6 +- tools/goctl/api/docgen/doc.go | 4 +- tools/goctl/api/format/format.go | 4 +- tools/goctl/api/gogen/genconfig.go | 4 +- tools/goctl/api/gogen/genmiddleware.go | 2 +- tools/goctl/api/gogen/genroutes.go | 6 +- tools/goctl/api/gogen/gensvc.go | 6 +- tools/goctl/api/javagen/gencomponents.go | 6 +- tools/goctl/api/javagen/genpacket.go | 2 +- tools/goctl/api/javagen/util.go | 2 +- tools/goctl/api/ktgen/gen.go | 8 +- tools/goctl/api/parser/g4/ast/apiparser.go | 2 +- tools/goctl/api/parser/g4/ast/ast.go | 2 +- tools/goctl/api/parser/g4/ast/type.go | 2 - .../api/parser/g4/gen/api/apiparser_lexer.go | 6 +- .../api/parser/g4/gen/api/apiparser_parser.go | 414 +++++++++--------- .../goctl/api/parser/g4/gen/api/baseparser.go | 46 +- tools/goctl/api/parser/g4/test/info_test.go | 1 - .../goctl/api/parser/g4/test/service_test.go | 4 +- tools/goctl/api/parser/parser.go | 12 +- tools/goctl/api/util/util.go | 2 +- .../model/mongo/generate/generate_test.go | 2 +- .../goctl/model/sql/builderx/builder_test.go | 2 +- tools/goctl/model/sql/gen/gen.go | 2 +- tools/goctl/model/sql/gen/gen_test.go | 4 +- tools/goctl/model/sql/gen/keys_test.go | 2 - tools/goctl/model/sql/parser/parser.go | 2 +- tools/goctl/plugin/plugin.go | 4 +- tools/goctl/rpc/generator/gencall.go | 2 +- tools/goctl/rpc/generator/genlogic.go | 2 +- tools/goctl/rpc/parser/parser.go | 1 + tools/goctl/util/console/console.go | 6 +- tools/goctl/util/path.go | 4 +- tools/goctl/util/stringx/string.go | 2 +- tools/goctl/util/templatex.go | 2 +- zrpc/internal/balancer/p2c/p2c.go | 3 +- zrpc/internal/balancer/p2c/p2c_test.go | 3 +- zrpc/internal/mock/deposit.pb.go | 22 +- zrpc/internal/mock/depositserver.go | 3 +- .../sheddinginterceptor_test.go | 3 +- 68 files changed, 390 insertions(+), 414 deletions(-) diff --git a/core/breaker/breaker_test.go b/core/breaker/breaker_test.go index dec824f2..59e24494 100644 --- a/core/breaker/breaker_test.go +++ b/core/breaker/breaker_test.go @@ -122,8 +122,7 @@ func BenchmarkGoogleBreaker(b *testing.B) { } } -type mockedPromise struct { -} +type mockedPromise struct{} func (m *mockedPromise) Accept() { } diff --git a/core/codec/aesecb_test.go b/core/codec/aesecb_test.go index bb6e258f..46a93ad7 100644 --- a/core/codec/aesecb_test.go +++ b/core/codec/aesecb_test.go @@ -40,7 +40,7 @@ func TestAesEcbBase64(t *testing.T) { // more than 32 chars badKey2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ) - var key = []byte("q4t7w!z%C*F-JaNdRgUjXn2r5u8x/A?D") + key := []byte("q4t7w!z%C*F-JaNdRgUjXn2r5u8x/A?D") b64Key := base64.StdEncoding.EncodeToString(key) b64Val := base64.StdEncoding.EncodeToString([]byte(val)) _, err := EcbEncryptBase64(badKey1, val) diff --git a/core/collection/rollingwindow_test.go b/core/collection/rollingwindow_test.go index 0d1b2569..577da52c 100644 --- a/core/collection/rollingwindow_test.go +++ b/core/collection/rollingwindow_test.go @@ -139,7 +139,7 @@ func TestRollingWindowBucketTimeBoundary(t *testing.T) { func TestRollingWindowDataRace(t *testing.T) { const size = 3 r := NewRollingWindow(size, duration) - var stop = make(chan bool) + stop := make(chan bool) go func() { for { select { diff --git a/core/errorx/callchain_test.go b/core/errorx/callchain_test.go index 31ebbc0b..234dd5cb 100644 --- a/core/errorx/callchain_test.go +++ b/core/errorx/callchain_test.go @@ -8,7 +8,7 @@ import ( ) func TestChain(t *testing.T) { - var errDummy = errors.New("dummy") + errDummy := errors.New("dummy") assert.Nil(t, Chain(func() error { return nil }, func() error { diff --git a/core/fx/retry.go b/core/fx/retry.go index 40475e0f..b9d9aaff 100644 --- a/core/fx/retry.go +++ b/core/fx/retry.go @@ -15,7 +15,7 @@ type ( // DoWithRetry runs fn, and retries if failed. Default to retry 3 times. func DoWithRetry(fn func() error, opts ...RetryOption) error { - var options = newRetryOptions() + options := newRetryOptions() for _, opt := range opts { opt(options) } diff --git a/core/fx/retry_test.go b/core/fx/retry_test.go index 1664b6ed..520ec914 100644 --- a/core/fx/retry_test.go +++ b/core/fx/retry_test.go @@ -30,7 +30,7 @@ func TestRetry(t *testing.T) { return errors.New("any") })) - var total = 2 * defaultRetryTimes + total := 2 * defaultRetryTimes times = 0 assert.Nil(t, DoWithRetry(func() error { times++ diff --git a/core/load/adaptiveshedder.go b/core/load/adaptiveshedder.go index afec3933..8d6737be 100644 --- a/core/load/adaptiveshedder.go +++ b/core/load/adaptiveshedder.go @@ -168,7 +168,7 @@ func (as *adaptiveShedder) maxPass() int64 { } func (as *adaptiveShedder) minRt() float64 { - var result = defaultMinRt + result := defaultMinRt as.rtCounter.Reduce(func(b *collection.Bucket) { if b.Count <= 0 { diff --git a/core/load/adaptiveshedder_test.go b/core/load/adaptiveshedder_test.go index 7be62b7e..1f9e4b3a 100644 --- a/core/load/adaptiveshedder_test.go +++ b/core/load/adaptiveshedder_test.go @@ -201,7 +201,7 @@ func BenchmarkAdaptiveShedder_Allow(b *testing.B) { logx.Disable() bench := func(b *testing.B) { - var shedder = NewAdaptiveShedder() + shedder := NewAdaptiveShedder() proba := mathx.NewProba() for i := 0; i < 6000; i++ { p, err := shedder.Allow() diff --git a/core/load/nopshedder.go b/core/load/nopshedder.go index 9de5e51c..e0aed367 100644 --- a/core/load/nopshedder.go +++ b/core/load/nopshedder.go @@ -1,7 +1,6 @@ package load -type nopShedder struct { -} +type nopShedder struct{} func newNopShedder() Shedder { return nopShedder{} @@ -11,8 +10,7 @@ func (s nopShedder) Allow() (Promise, error) { return nopPromise{}, nil } -type nopPromise struct { -} +type nopPromise struct{} func (p nopPromise) Pass() { } diff --git a/core/logx/rotatelogger.go b/core/logx/rotatelogger.go index c615f070..3219ca96 100644 --- a/core/logx/rotatelogger.go +++ b/core/logx/rotatelogger.go @@ -22,8 +22,8 @@ const ( dateFormat = "2006-01-02" hoursPerDay = 24 bufferSize = 100 - defaultDirMode = 0755 - defaultFileMode = 0600 + defaultDirMode = 0o755 + defaultFileMode = 0o600 ) // ErrLogFileClosed is an error that indicates the log file is already closed. diff --git a/core/mapping/unmarshaler_test.go b/core/mapping/unmarshaler_test.go index 65b4ea7e..94d80e56 100644 --- a/core/mapping/unmarshaler_test.go +++ b/core/mapping/unmarshaler_test.go @@ -752,7 +752,7 @@ func TestUnmarshalJsonNumberInt64(t *testing.T) { for i := 0; i <= maxUintBitsToTest; i++ { var intValue int64 = 1 << uint(i) strValue := strconv.FormatInt(intValue, 10) - var number = json.Number(strValue) + number := json.Number(strValue) m := map[string]interface{}{ "ID": number, } @@ -768,7 +768,7 @@ func TestUnmarshalJsonNumberUint64(t *testing.T) { for i := 0; i <= maxUintBitsToTest; i++ { var intValue uint64 = 1 << uint(i) strValue := strconv.FormatUint(intValue, 10) - var number = json.Number(strValue) + number := json.Number(strValue) m := map[string]interface{}{ "ID": number, } @@ -784,7 +784,7 @@ func TestUnmarshalJsonNumberUint64Ptr(t *testing.T) { for i := 0; i <= maxUintBitsToTest; i++ { var intValue uint64 = 1 << uint(i) strValue := strconv.FormatUint(intValue, 10) - var number = json.Number(strValue) + number := json.Number(strValue) m := map[string]interface{}{ "ID": number, } diff --git a/core/mapping/utils_test.go b/core/mapping/utils_test.go index 6e56929c..8a864589 100644 --- a/core/mapping/utils_test.go +++ b/core/mapping/utils_test.go @@ -16,8 +16,8 @@ type Foo struct { } func TestDeferInt(t *testing.T) { - var i = 1 - var s = "hello" + i := 1 + s := "hello" number := struct { f float64 }{ diff --git a/core/queue/queue_test.go b/core/queue/queue_test.go index 41ca7480..06ba3c0b 100644 --- a/core/queue/queue_test.go +++ b/core/queue/queue_test.go @@ -84,8 +84,7 @@ func (p *mockedProducer) Produce() (string, bool) { return "", false } -type mockedListener struct { -} +type mockedListener struct{} func (l *mockedListener) OnPause() { } diff --git a/core/service/servicegroup.go b/core/service/servicegroup.go index 98d6ff2d..4585bf08 100644 --- a/core/service/servicegroup.go +++ b/core/service/servicegroup.go @@ -95,8 +95,7 @@ func WithStarter(start Starter) Service { } type ( - stopper struct { - } + stopper struct{} startOnlyService struct { start func() diff --git a/core/service/servicegroup_test.go b/core/service/servicegroup_test.go index 7f2165dd..b7a52ba3 100644 --- a/core/service/servicegroup_test.go +++ b/core/service/servicegroup_test.go @@ -70,7 +70,7 @@ func TestServiceGroup_WithStart(t *testing.T) { wait.Add(len(multipliers)) group := NewServiceGroup() for _, multiplier := range multipliers { - var mul = multiplier + mul := multiplier group.Add(WithStart(func() { lock.Lock() want *= mul @@ -97,7 +97,7 @@ func TestServiceGroup_WithStarter(t *testing.T) { wait.Add(len(multipliers)) group := NewServiceGroup() for _, multiplier := range multipliers { - var mul = multiplier + mul := multiplier group.Add(WithStarter(mockedStarter{ fn: func() { lock.Lock() diff --git a/core/stores/cache/cachenode_test.go b/core/stores/cache/cachenode_test.go index b4979e58..95c86a5c 100644 --- a/core/stores/cache/cachenode_test.go +++ b/core/stores/cache/cachenode_test.go @@ -129,7 +129,7 @@ func TestCacheNode_TakeNotFound(t *testing.T) { assert.True(t, cn.IsNotFound(cn.Get("any", &str))) store.Del("any") - var errDummy = errors.New("dummy") + errDummy := errors.New("dummy") err = cn.Take(&str, "any", func(v interface{}) error { return errDummy }) diff --git a/core/stores/kv/store_test.go b/core/stores/kv/store_test.go index ba789c2d..54d21da7 100644 --- a/core/stores/kv/store_test.go +++ b/core/stores/kv/store_test.go @@ -12,8 +12,10 @@ import ( "github.com/tal-tech/go-zero/core/stringx" ) -var s1, _ = miniredis.Run() -var s2, _ = miniredis.Run() +var ( + s1, _ = miniredis.Run() + s2, _ = miniredis.Run() +) func TestRedis_Exists(t *testing.T) { store := clusterStore{dispatcher: hash.NewConsistentHash()} diff --git a/core/stores/mongo/collection_test.go b/core/stores/mongo/collection_test.go index 4723bf58..ddf452c3 100644 --- a/core/stores/mongo/collection_test.go +++ b/core/stores/mongo/collection_test.go @@ -279,8 +279,7 @@ func (p *mockPromise) Reject(reason string) { p.reason = reason } -type dropBreaker struct { -} +type dropBreaker struct{} func (d *dropBreaker) Name() string { return "dummy" diff --git a/core/stores/redis/redis.go b/core/stores/redis/redis.go index 8e68e659..d60cd4cf 100644 --- a/core/stores/redis/redis.go +++ b/core/stores/redis/redis.go @@ -945,7 +945,6 @@ func (s *Redis) Pipelined(fn func(Pipeliner) error) (err error) { _, err = conn.Pipelined(fn) return err - }, acceptable) return diff --git a/core/stores/redis/redis_test.go b/core/stores/redis/redis_test.go index 10e4cc28..f3a1500c 100644 --- a/core/stores/redis/redis_test.go +++ b/core/stores/redis/redis_test.go @@ -384,7 +384,6 @@ func TestRedis_BitCount(t *testing.T) { val, err = client.BitCount("key", 2, 2) assert.Nil(t, err) assert.Equal(t, int64(0), val) - }) } @@ -401,7 +400,7 @@ func TestRedis_BitOpAnd(t *testing.T) { assert.Equal(t, int64(1), val) valStr, err := client.Get("destKey") assert.Nil(t, err) - //destKey binary 110000 ascii 0 + // destKey binary 110000 ascii 0 assert.Equal(t, "0", valStr) }) } @@ -454,9 +453,10 @@ func TestRedis_BitOpXor(t *testing.T) { assert.Equal(t, "\xf0", valStr) }) } + func TestRedis_BitPos(t *testing.T) { runOnRedis(t, func(client *Redis) { - //11111111 11110000 00000000 + // 11111111 11110000 00000000 err := client.Set("key", "\xff\xf0\x00") assert.Nil(t, err) @@ -481,7 +481,6 @@ func TestRedis_BitPos(t *testing.T) { val, err = client.BitPos("key", 1, 2, 2) assert.Nil(t, err) assert.Equal(t, int64(-1), val) - }) } @@ -1035,7 +1034,7 @@ func TestRedisBlpopEx(t *testing.T) { func TestRedisGeo(t *testing.T) { runOnRedis(t, func(client *Redis) { client.Ping() - var geoLocation = []*GeoLocation{{Longitude: 13.361389, Latitude: 38.115556, Name: "Palermo"}, {Longitude: 15.087269, Latitude: 37.502669, Name: "Catania"}} + geoLocation := []*GeoLocation{{Longitude: 13.361389, Latitude: 38.115556, Name: "Palermo"}, {Longitude: 15.087269, Latitude: 37.502669, Name: "Catania"}} v, err := client.GeoAdd("sicily", geoLocation...) assert.Nil(t, err) assert.Equal(t, int64(2), v) @@ -1053,7 +1052,7 @@ func TestRedisGeo(t *testing.T) { assert.Nil(t, err) assert.Equal(t, int64(v4[0].Dist), int64(190)) assert.Equal(t, int64(v4[1].Dist), int64(56)) - var geoLocation2 = []*GeoLocation{{Longitude: 13.583333, Latitude: 37.316667, Name: "Agrigento"}} + geoLocation2 := []*GeoLocation{{Longitude: 13.583333, Latitude: 37.316667, Name: "Agrigento"}} v5, err := client.GeoAdd("sicily", geoLocation2...) assert.Nil(t, err) assert.Equal(t, int64(1), v5) @@ -1087,7 +1086,6 @@ func runOnRedis(t *testing.T, fn func(client *Redis)) { } }() fn(NewRedis(s.Addr(), NodeType)) - } func runOnRedisTLS(t *testing.T, fn func(client *Redis)) { diff --git a/core/stores/redis/redislock.go b/core/stores/redis/redislock.go index 61659a51..06637a75 100644 --- a/core/stores/redis/redislock.go +++ b/core/stores/redis/redislock.go @@ -53,7 +53,8 @@ func NewRedisLock(store *Redis, key string) *RedisLock { 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)}) + rl.id, strconv.Itoa(int(seconds)*millisPerSecond + tolerance), + }) if err == red.Nil { return false, nil } else if err != nil { diff --git a/core/stores/sqlx/orm_test.go b/core/stores/sqlx/orm_test.go index 91f05648..17bea417 100644 --- a/core/stores/sqlx/orm_test.go +++ b/core/stores/sqlx/orm_test.go @@ -206,7 +206,7 @@ func TestUnmarshalRowString(t *testing.T) { } func TestUnmarshalRowStruct(t *testing.T) { - var value = new(struct { + value := new(struct { Name string Age int }) @@ -224,7 +224,7 @@ func TestUnmarshalRowStruct(t *testing.T) { } func TestUnmarshalRowStructWithTags(t *testing.T) { - var value = new(struct { + value := new(struct { Age int `db:"age"` Name string `db:"name"` }) @@ -242,7 +242,7 @@ func TestUnmarshalRowStructWithTags(t *testing.T) { } func TestUnmarshalRowStructWithTagsWrongColumns(t *testing.T) { - var value = new(struct { + value := new(struct { Age *int `db:"age"` Name string `db:"name"` }) @@ -259,7 +259,7 @@ func TestUnmarshalRowStructWithTagsWrongColumns(t *testing.T) { func TestUnmarshalRowsBool(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []bool{true, false} + expect := []bool{true, false} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("1\n0") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -273,7 +273,7 @@ func TestUnmarshalRowsBool(t *testing.T) { func TestUnmarshalRowsInt(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []int{2, 3} + expect := []int{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -287,7 +287,7 @@ func TestUnmarshalRowsInt(t *testing.T) { func TestUnmarshalRowsInt8(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []int8{2, 3} + expect := []int8{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -301,7 +301,7 @@ func TestUnmarshalRowsInt8(t *testing.T) { func TestUnmarshalRowsInt16(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []int16{2, 3} + expect := []int16{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -315,7 +315,7 @@ func TestUnmarshalRowsInt16(t *testing.T) { func TestUnmarshalRowsInt32(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []int32{2, 3} + expect := []int32{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -329,7 +329,7 @@ func TestUnmarshalRowsInt32(t *testing.T) { func TestUnmarshalRowsInt64(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []int64{2, 3} + expect := []int64{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -343,7 +343,7 @@ func TestUnmarshalRowsInt64(t *testing.T) { func TestUnmarshalRowsUint(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []uint{2, 3} + expect := []uint{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -357,7 +357,7 @@ func TestUnmarshalRowsUint(t *testing.T) { func TestUnmarshalRowsUint8(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []uint8{2, 3} + expect := []uint8{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -371,7 +371,7 @@ func TestUnmarshalRowsUint8(t *testing.T) { func TestUnmarshalRowsUint16(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []uint16{2, 3} + expect := []uint16{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -385,7 +385,7 @@ func TestUnmarshalRowsUint16(t *testing.T) { func TestUnmarshalRowsUint32(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []uint32{2, 3} + expect := []uint32{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -399,7 +399,7 @@ func TestUnmarshalRowsUint32(t *testing.T) { func TestUnmarshalRowsUint64(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []uint64{2, 3} + expect := []uint64{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -413,7 +413,7 @@ func TestUnmarshalRowsUint64(t *testing.T) { func TestUnmarshalRowsFloat32(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []float32{2, 3} + expect := []float32{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -427,7 +427,7 @@ func TestUnmarshalRowsFloat32(t *testing.T) { func TestUnmarshalRowsFloat64(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []float64{2, 3} + expect := []float64{2, 3} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -441,7 +441,7 @@ func TestUnmarshalRowsFloat64(t *testing.T) { func TestUnmarshalRowsString(t *testing.T) { runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []string{"hello", "world"} + expect := []string{"hello", "world"} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("hello\nworld") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -457,7 +457,7 @@ func TestUnmarshalRowsBoolPtr(t *testing.T) { yes := true no := false runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*bool{&yes, &no} + expect := []*bool{&yes, &no} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("1\n0") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -473,7 +473,7 @@ func TestUnmarshalRowsIntPtr(t *testing.T) { two := 2 three := 3 runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*int{&two, &three} + expect := []*int{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -489,7 +489,7 @@ func TestUnmarshalRowsInt8Ptr(t *testing.T) { two := int8(2) three := int8(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*int8{&two, &three} + expect := []*int8{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -505,7 +505,7 @@ func TestUnmarshalRowsInt16Ptr(t *testing.T) { two := int16(2) three := int16(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*int16{&two, &three} + expect := []*int16{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -521,7 +521,7 @@ func TestUnmarshalRowsInt32Ptr(t *testing.T) { two := int32(2) three := int32(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*int32{&two, &three} + expect := []*int32{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -537,7 +537,7 @@ func TestUnmarshalRowsInt64Ptr(t *testing.T) { two := int64(2) three := int64(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*int64{&two, &three} + expect := []*int64{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -553,7 +553,7 @@ func TestUnmarshalRowsUintPtr(t *testing.T) { two := uint(2) three := uint(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*uint{&two, &three} + expect := []*uint{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -569,7 +569,7 @@ func TestUnmarshalRowsUint8Ptr(t *testing.T) { two := uint8(2) three := uint8(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*uint8{&two, &three} + expect := []*uint8{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -585,7 +585,7 @@ func TestUnmarshalRowsUint16Ptr(t *testing.T) { two := uint16(2) three := uint16(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*uint16{&two, &three} + expect := []*uint16{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -601,7 +601,7 @@ func TestUnmarshalRowsUint32Ptr(t *testing.T) { two := uint32(2) three := uint32(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*uint32{&two, &three} + expect := []*uint32{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -617,7 +617,7 @@ func TestUnmarshalRowsUint64Ptr(t *testing.T) { two := uint64(2) three := uint64(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*uint64{&two, &three} + expect := []*uint64{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -633,7 +633,7 @@ func TestUnmarshalRowsFloat32Ptr(t *testing.T) { two := float32(2) three := float32(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*float32{&two, &three} + expect := []*float32{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -649,7 +649,7 @@ func TestUnmarshalRowsFloat64Ptr(t *testing.T) { two := float64(2) three := float64(3) runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*float64{&two, &three} + expect := []*float64{&two, &three} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("2\n3") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -665,7 +665,7 @@ func TestUnmarshalRowsStringPtr(t *testing.T) { hello := "hello" world := "world" runOrmTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) { - var expect = []*string{&hello, &world} + expect := []*string{&hello, &world} rs := sqlmock.NewRows([]string{"value"}).FromCSVString("hello\nworld") mock.ExpectQuery("select (.+) from users where user=?").WithArgs("anyone").WillReturnRows(rs) @@ -678,7 +678,7 @@ func TestUnmarshalRowsStringPtr(t *testing.T) { } func TestUnmarshalRowsStruct(t *testing.T) { - var expect = []struct { + expect := []struct { Name string Age int64 }{ @@ -711,7 +711,7 @@ func TestUnmarshalRowsStruct(t *testing.T) { } func TestUnmarshalRowsStructWithNullStringType(t *testing.T) { - var expect = []struct { + expect := []struct { Name string NullString sql.NullString }{ @@ -752,7 +752,7 @@ func TestUnmarshalRowsStructWithNullStringType(t *testing.T) { } func TestUnmarshalRowsStructWithTags(t *testing.T) { - var expect = []struct { + expect := []struct { Name string Age int64 }{ @@ -789,7 +789,7 @@ func TestUnmarshalRowsStructAndEmbeddedAnonymousStructWithTags(t *testing.T) { Value int64 `db:"value"` } - var expect = []struct { + expect := []struct { Name string Age int64 Value int64 @@ -831,7 +831,7 @@ func TestUnmarshalRowsStructAndEmbeddedStructPtrAnonymousWithTags(t *testing.T) Value int64 `db:"value"` } - var expect = []struct { + expect := []struct { Name string Age int64 Value int64 @@ -869,7 +869,7 @@ func TestUnmarshalRowsStructAndEmbeddedStructPtrAnonymousWithTags(t *testing.T) } func TestUnmarshalRowsStructPtr(t *testing.T) { - var expect = []*struct { + expect := []*struct { Name string Age int64 }{ @@ -902,7 +902,7 @@ func TestUnmarshalRowsStructPtr(t *testing.T) { } func TestUnmarshalRowsStructWithTagsPtr(t *testing.T) { - var expect = []*struct { + expect := []*struct { Name string Age int64 }{ @@ -935,7 +935,7 @@ func TestUnmarshalRowsStructWithTagsPtr(t *testing.T) { } func TestUnmarshalRowsStructWithTagsPtrWithInnerPtr(t *testing.T) { - var expect = []*struct { + expect := []*struct { Name string Age int64 }{ diff --git a/core/stringx/replacer.go b/core/stringx/replacer.go index 1baf8c4f..00c93195 100644 --- a/core/stringx/replacer.go +++ b/core/stringx/replacer.go @@ -16,7 +16,7 @@ type ( // NewReplacer returns a Replacer. func NewReplacer(mapping map[string]string) Replacer { - var rep = &replacer{ + rep := &replacer{ mapping: mapping, } for k := range mapping { @@ -28,9 +28,9 @@ func NewReplacer(mapping map[string]string) Replacer { func (r *replacer) Replace(text string) string { var builder strings.Builder - var chars = []rune(text) - var size = len(chars) - var start = -1 + chars := []rune(text) + size := len(chars) + start := -1 for i := 0; i < size; i++ { child, ok := r.children[chars[i]] @@ -42,12 +42,12 @@ func (r *replacer) Replace(text string) string { if start < 0 { start = i } - var end = -1 + end := -1 if child.end { end = i + 1 } - var j = i + 1 + j := i + 1 for ; j < size; j++ { grandchild, ok := child.children[chars[j]] if !ok { diff --git a/core/stringx/replacer_test.go b/core/stringx/replacer_test.go index c739b2a7..89e3a1ec 100644 --- a/core/stringx/replacer_test.go +++ b/core/stringx/replacer_test.go @@ -7,7 +7,7 @@ import ( ) func TestReplacer_Replace(t *testing.T) { - var mapping = map[string]string{ + mapping := map[string]string{ "一二三四": "1234", "二三": "23", "二": "2", @@ -16,28 +16,28 @@ func TestReplacer_Replace(t *testing.T) { } func TestReplacer_ReplaceSingleChar(t *testing.T) { - var mapping = map[string]string{ + mapping := map[string]string{ "二": "2", } assert.Equal(t, "零一2三四五", NewReplacer(mapping).Replace("零一二三四五")) } func TestReplacer_ReplaceExceedRange(t *testing.T) { - var mapping = map[string]string{ + mapping := map[string]string{ "二三四五六": "23456", } assert.Equal(t, "零一二三四五", NewReplacer(mapping).Replace("零一二三四五")) } func TestReplacer_ReplacePartialMatch(t *testing.T) { - var mapping = map[string]string{ + mapping := map[string]string{ "二三四七": "2347", } assert.Equal(t, "零一二三四五", NewReplacer(mapping).Replace("零一二三四五")) } func TestReplacer_ReplaceMultiMatches(t *testing.T) { - var mapping = map[string]string{ + mapping := map[string]string{ "二三": "23", } assert.Equal(t, "零一23四五一23四五", NewReplacer(mapping).Replace("零一二三四五一二三四五")) diff --git a/rest/engine_test.go b/rest/engine_test.go index e4a87ad0..eff1c12e 100644 --- a/rest/engine_test.go +++ b/rest/engine_test.go @@ -154,8 +154,7 @@ Verbose: true } } -type mockedRouter struct { -} +type mockedRouter struct{} func (m mockedRouter) ServeHTTP(writer http.ResponseWriter, request *http.Request) { } diff --git a/rest/handler/sheddinghandler_test.go b/rest/handler/sheddinghandler_test.go index 9a10bf81..1c010c88 100644 --- a/rest/handler/sheddinghandler_test.go +++ b/rest/handler/sheddinghandler_test.go @@ -94,8 +94,7 @@ func (s mockShedder) Allow() (load.Promise, error) { return nil, load.ErrServiceOverloaded } -type mockPromise struct { -} +type mockPromise struct{} func (p mockPromise) Pass() { } diff --git a/tools/goctl/api/dartgen/genapi.go b/tools/goctl/api/dartgen/genapi.go index 4c988431..3a87e158 100644 --- a/tools/goctl/api/dartgen/genapi.go +++ b/tools/goctl/api/dartgen/genapi.go @@ -29,7 +29,7 @@ Future {{pathToFuncName .Path}}( {{if ne .Method "get"}}{{with .RequestType}}{{. {{end}}` func genApi(dir string, api *spec.ApiSpec) error { - err := os.MkdirAll(dir, 0755) + err := os.MkdirAll(dir, 0o755) if err != nil { return err } @@ -39,7 +39,7 @@ func genApi(dir string, api *spec.ApiSpec) error { return err } - file, err := os.OpenFile(dir+api.Service.Name+".dart", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + file, err := os.OpenFile(dir+api.Service.Name+".dart", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644) if err != nil { return err } @@ -60,7 +60,7 @@ func genApiFile(dir string) error { if fileExists(path) { return nil } - apiFile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + apiFile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644) if err != nil { return err } diff --git a/tools/goctl/api/dartgen/gendata.go b/tools/goctl/api/dartgen/gendata.go index ebaca72a..f3d3d83f 100644 --- a/tools/goctl/api/dartgen/gendata.go +++ b/tools/goctl/api/dartgen/gendata.go @@ -32,7 +32,7 @@ class {{.Name}}{ ` func genData(dir string, api *spec.ApiSpec) error { - err := os.MkdirAll(dir, 0755) + err := os.MkdirAll(dir, 0o755) if err != nil { return err } @@ -42,7 +42,7 @@ func genData(dir string, api *spec.ApiSpec) error { return err } - file, err := os.OpenFile(dir+api.Service.Name+".dart", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + file, err := os.OpenFile(dir+api.Service.Name+".dart", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644) if err != nil { return err } @@ -64,7 +64,7 @@ func genTokens(dir string) error { return nil } - tokensFile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + tokensFile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644) if err != nil { return err } diff --git a/tools/goctl/api/dartgen/genvars.go b/tools/goctl/api/dartgen/genvars.go index 01bfa3a8..c6b90a56 100644 --- a/tools/goctl/api/dartgen/genvars.go +++ b/tools/goctl/api/dartgen/genvars.go @@ -41,20 +41,20 @@ Future getTokens() async { ` func genVars(dir string) error { - err := os.MkdirAll(dir, 0755) + err := os.MkdirAll(dir, 0o755) if err != nil { return err } if !fileExists(dir + "vars.dart") { - err = ioutil.WriteFile(dir+"vars.dart", []byte(`const serverHost='demo-crm.xiaoheiban.cn';`), 0644) + err = ioutil.WriteFile(dir+"vars.dart", []byte(`const serverHost='demo-crm.xiaoheiban.cn';`), 0o644) if err != nil { return err } } if !fileExists(dir + "kv.dart") { - err = ioutil.WriteFile(dir+"kv.dart", []byte(varTemplate), 0644) + err = ioutil.WriteFile(dir+"kv.dart", []byte(varTemplate), 0o644) if err != nil { return err } diff --git a/tools/goctl/api/docgen/doc.go b/tools/goctl/api/docgen/doc.go index 5ad264a1..dba54186 100644 --- a/tools/goctl/api/docgen/doc.go +++ b/tools/goctl/api/docgen/doc.go @@ -84,7 +84,7 @@ func buildDoc(route spec.Type) (string, error) { return "", nil } - var tps = make([]spec.Type, 0) + tps := make([]spec.Type, 0) tps = append(tps, route) if definedType, ok := route.(spec.DefineStruct); ok { associatedTypes(definedType, &tps) @@ -98,7 +98,7 @@ func buildDoc(route spec.Type) (string, error) { } func associatedTypes(tp spec.DefineStruct, tps *[]spec.Type) { - var hasAdded = false + hasAdded := false for _, item := range *tps { if item.Name() == tp.Name() { hasAdded = true diff --git a/tools/goctl/api/format/format.go b/tools/goctl/api/format/format.go index 7e944da5..fc877bf1 100644 --- a/tools/goctl/api/format/format.go +++ b/tools/goctl/api/format/format.go @@ -107,8 +107,8 @@ func apiFormat(data string) (string, error) { var builder strings.Builder s := bufio.NewScanner(strings.NewReader(data)) - var tapCount = 0 - var newLineCount = 0 + tapCount := 0 + newLineCount := 0 var preLine string for s.Scan() { line := strings.TrimSpace(s.Text()) diff --git a/tools/goctl/api/gogen/genconfig.go b/tools/goctl/api/gogen/genconfig.go index 369edec5..ce84aba3 100644 --- a/tools/goctl/api/gogen/genconfig.go +++ b/tools/goctl/api/gogen/genconfig.go @@ -35,12 +35,12 @@ func genConfig(dir string, cfg *config.Config, api *spec.ApiSpec) error { return err } - var authNames = getAuths(api) + authNames := getAuths(api) var auths []string for _, item := range authNames { auths = append(auths, fmt.Sprintf("%s %s", item, jwtTemplate)) } - var authImportStr = fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL) + authImportStr := fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL) return genFile(fileGenConfig{ dir: dir, diff --git a/tools/goctl/api/gogen/genmiddleware.go b/tools/goctl/api/gogen/genmiddleware.go index 727673b6..1200cce7 100644 --- a/tools/goctl/api/gogen/genmiddleware.go +++ b/tools/goctl/api/gogen/genmiddleware.go @@ -31,7 +31,7 @@ func (m *{{.name}})Handle(next http.HandlerFunc) http.HandlerFunc { ` func genMiddleware(dir string, cfg *config.Config, api *spec.ApiSpec) error { - var middlewares = getMiddleware(api) + middlewares := getMiddleware(api) for _, item := range middlewares { middlewareFilename := strings.TrimSuffix(strings.ToLower(item), "middleware") + "_middleware" filename, err := format.FileNamingFormat(cfg.NamingFormat, middlewareFilename) diff --git a/tools/goctl/api/gogen/genroutes.go b/tools/goctl/api/gogen/genroutes.go index d097eb87..98f89672 100644 --- a/tools/goctl/api/gogen/genroutes.go +++ b/tools/goctl/api/gogen/genroutes.go @@ -95,11 +95,11 @@ func genRoutes(dir string, cfg *config.Config, api *spec.ApiSpec) error { var routes string if len(g.middlewares) > 0 { gbuilder.WriteString("\n}...,") - var params = g.middlewares + params := g.middlewares for i := range params { params[i] = "serverCtx." + params[i] } - var middlewareStr = strings.Join(params, ", ") + middlewareStr := strings.Join(params, ", ") routes = fmt.Sprintf("rest.WithMiddlewares(\n[]rest.Middleware{ %s }, \n %s \n),", middlewareStr, strings.TrimSpace(gbuilder.String())) } else { @@ -146,7 +146,7 @@ func genRoutes(dir string, cfg *config.Config, api *spec.ApiSpec) error { } func genRouteImports(parentPkg string, api *spec.ApiSpec) string { - var importSet = collection.NewSet() + importSet := collection.NewSet() importSet.AddStr(fmt.Sprintf("\"%s\"", util.JoinPackages(parentPkg, contextDir))) for _, group := range api.Service.Groups { for _, route := range group.Routes { diff --git a/tools/goctl/api/gogen/gensvc.go b/tools/goctl/api/gogen/gensvc.go index 43adbc42..1d0c893c 100644 --- a/tools/goctl/api/gogen/gensvc.go +++ b/tools/goctl/api/gogen/gensvc.go @@ -39,7 +39,7 @@ func genServiceContext(dir string, cfg *config.Config, api *spec.ApiSpec) error return err } - var authNames = getAuths(api) + authNames := getAuths(api) var auths []string for _, item := range authNames { auths = append(auths, fmt.Sprintf("%s config.AuthConfig", item)) @@ -52,7 +52,7 @@ func genServiceContext(dir string, cfg *config.Config, api *spec.ApiSpec) error var middlewareStr string var middlewareAssignment string - var middlewares = getMiddleware(api) + middlewares := getMiddleware(api) for _, item := range middlewares { middlewareStr += fmt.Sprintf("%s rest.Middleware\n", item) @@ -61,7 +61,7 @@ func genServiceContext(dir string, cfg *config.Config, api *spec.ApiSpec) error fmt.Sprintf("middleware.New%s().%s", strings.Title(name), "Handle")) } - var configImport = "\"" + ctlutil.JoinPackages(parentPkg, configDir) + "\"" + configImport := "\"" + ctlutil.JoinPackages(parentPkg, configDir) + "\"" if len(middlewareStr) > 0 { configImport += "\n\t\"" + ctlutil.JoinPackages(parentPkg, middlewareDir) + "\"" configImport += fmt.Sprintf("\n\t\"%s/rest\"", vars.ProjectOpenSourceURL) diff --git a/tools/goctl/api/javagen/gencomponents.go b/tools/goctl/api/javagen/gencomponents.go index 98bbff73..f3842c80 100644 --- a/tools/goctl/api/javagen/gencomponents.go +++ b/tools/goctl/api/javagen/gencomponents.go @@ -277,15 +277,15 @@ func (c *componentsContext) buildConstructor() (string, string, error) { } func (c *componentsContext) genGetSet(writer io.Writer, indent int) error { - var members = c.members + members := c.members for _, member := range members { javaType, err := specTypeToJava(member.Type) if err != nil { return nil } - var property = util.Title(member.Name) - var templateStr = getSetTemplate + property := util.Title(member.Name) + templateStr := getSetTemplate if javaType == "boolean" { templateStr = boolTemplate property = strings.TrimPrefix(property, "Is") diff --git a/tools/goctl/api/javagen/genpacket.go b/tools/goctl/api/javagen/genpacket.go index a6b17b90..1f0e4422 100644 --- a/tools/goctl/api/javagen/genpacket.go +++ b/tools/goctl/api/javagen/genpacket.go @@ -67,7 +67,7 @@ func createWith(dir string, api *spec.ApiSpec, route spec.Route, packetName stri } defer fp.Close() - var hasRequestBody = false + hasRequestBody := false if route.RequestType != nil { if defineStruct, ok := route.RequestType.(spec.DefineStruct); ok { hasRequestBody = len(defineStruct.GetBodyMembers()) > 0 || len(defineStruct.GetFormMembers()) > 0 diff --git a/tools/goctl/api/javagen/util.go b/tools/goctl/api/javagen/util.go index 80a70b05..57ee2fb5 100644 --- a/tools/goctl/api/javagen/util.go +++ b/tools/goctl/api/javagen/util.go @@ -61,7 +61,7 @@ func writeIndent(writer io.Writer, indent int) { } func indentString(indent int) string { - var result = "" + result := "" for i := 0; i < indent; i++ { result += "\t" } diff --git a/tools/goctl/api/ktgen/gen.go b/tools/goctl/api/ktgen/gen.go index b8ab3ba1..1cbfb2eb 100644 --- a/tools/goctl/api/ktgen/gen.go +++ b/tools/goctl/api/ktgen/gen.go @@ -98,7 +98,7 @@ object {{with .Info}}{{.Title}}{{end}}{ ) func genBase(dir, pkg string, api *spec.ApiSpec) error { - e := os.MkdirAll(dir, 0755) + e := os.MkdirAll(dir, 0o755) if e != nil { return e } @@ -108,7 +108,7 @@ func genBase(dir, pkg string, api *spec.ApiSpec) error { return nil } - file, e := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) + file, e := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o644) if e != nil { return e } @@ -146,12 +146,12 @@ func genApi(dir, pkg string, api *spec.ApiSpec) error { api.Info.Title = name api.Info.Desc = desc - e := os.MkdirAll(dir, 0755) + e := os.MkdirAll(dir, 0o755) if e != nil { return e } - file, e := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) + file, e := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0o644) if e != nil { return e } diff --git a/tools/goctl/api/parser/g4/ast/apiparser.go b/tools/goctl/api/parser/g4/ast/apiparser.go index 2edeaec2..3fe9abee 100644 --- a/tools/goctl/api/parser/g4/ast/apiparser.go +++ b/tools/goctl/api/parser/g4/ast/apiparser.go @@ -175,7 +175,7 @@ func (p *Parser) valid(mainApi *Api, nestedApi *Api) error { for _, g := range list { handler := g.GetHandler() if handler.IsNotNil() { - var handlerName = handler.Text() + handlerName := handler.Text() handlerMap[handlerName] = Holder path := fmt.Sprintf("%s://%s", g.Route.Method.Text(), g.Route.Path.Text()) routeMap[path] = Holder diff --git a/tools/goctl/api/parser/g4/ast/ast.go b/tools/goctl/api/parser/g4/ast/ast.go index 9a608930..e5f05c36 100644 --- a/tools/goctl/api/parser/g4/ast/ast.go +++ b/tools/goctl/api/parser/g4/ast/ast.go @@ -289,7 +289,7 @@ func (v *ApiVisitor) getHiddenTokensToLeft(t TokenStream, channel int, containsC if index > 0 { allTokens := ct.GetAllTokens() - var flag = false + flag := false for i := index; i >= 0; i-- { tk := allTokens[i] if tk.GetChannel() == antlr.LexerDefaultTokenChannel { diff --git a/tools/goctl/api/parser/g4/ast/type.go b/tools/goctl/api/parser/g4/ast/type.go index b105419c..97aa5f4c 100644 --- a/tools/goctl/api/parser/g4/ast/type.go +++ b/tools/goctl/api/parser/g4/ast/type.go @@ -128,7 +128,6 @@ func (v *ApiVisitor) VisitTypeBlock(ctx *api.TypeBlockContext) interface{} { var types []TypeExpr for _, each := range list { types = append(types, each.Accept(v).(TypeExpr)) - } return types } @@ -155,7 +154,6 @@ func (v *ApiVisitor) VisitTypeStruct(ctx *api.TypeStructContext) interface{} { st.Name = v.newExprWithToken(ctx.GetStructName()) if util.UnExport(ctx.GetStructName().GetText()) { - } if ctx.GetStructToken() != nil { structExpr := v.newExprWithToken(ctx.GetStructToken()) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_lexer.go b/tools/goctl/api/parser/g4/gen/api/apiparser_lexer.go index e825fc09..e1f791bb 100644 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_lexer.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_lexer.go @@ -10,8 +10,10 @@ import ( ) // Suppress unused import error -var _ = fmt.Printf -var _ = unicode.IsLetter +var ( + _ = fmt.Printf + _ = unicode.IsLetter +) var serializedLexerAtn = []uint16{ 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 25, 266, diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go index 106fef5f..c46cc150 100644 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go @@ -10,9 +10,11 @@ import ( ) // Suppress unused import errors -var _ = fmt.Printf -var _ = reflect.Copy -var _ = strconv.Itoa +var ( + _ = fmt.Printf + _ = reflect.Copy + _ = strconv.Itoa +) var parserATN = []uint16{ 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 25, 348, @@ -167,10 +169,12 @@ var parserATN = []uint16{ 185, 193, 200, 206, 209, 221, 240, 249, 260, 266, 270, 276, 281, 284, 287, 296, 299, 302, 306, 312, 322, 326, 334, 341, 343, 345, } + var literalNames = []string{ "", "'='", "'('", "')'", "'{'", "'}'", "'*'", "'time.Time'", "'['", "']'", "'-'", "'/'", "'/:'", "'@doc'", "'@handler'", "'interface{}'", "'@server'", } + var symbolicNames = []string{ "", "", "", "", "", "", "", "", "", "", "", "", "", "ATDOC", "ATHANDLER", "INTERFACE", "ATSERVER", "WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING", @@ -301,7 +305,7 @@ type ApiContext struct { } func NewEmptyApiContext() *ApiContext { - var p = new(ApiContext) + p := new(ApiContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_api return p @@ -310,7 +314,7 @@ func NewEmptyApiContext() *ApiContext { func (*ApiContext) IsApiContext() {} func NewApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ApiContext { - var p = new(ApiContext) + p := new(ApiContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -323,8 +327,8 @@ func NewApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invoking func (s *ApiContext) GetParser() antlr.Parser { return s.parser } func (s *ApiContext) AllSpec() []ISpecContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ISpecContext)(nil)).Elem()) - var tst = make([]ISpecContext, len(ts)) + ts := s.GetTypedRuleContexts(reflect.TypeOf((*ISpecContext)(nil)).Elem()) + tst := make([]ISpecContext, len(ts)) for i, t := range ts { if t != nil { @@ -336,7 +340,7 @@ func (s *ApiContext) AllSpec() []ISpecContext { } func (s *ApiContext) Spec(i int) ISpecContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ISpecContext)(nil)).Elem(), i) + t := s.GetTypedRuleContext(reflect.TypeOf((*ISpecContext)(nil)).Elem(), i) if t == nil { return nil @@ -420,7 +424,7 @@ type SpecContext struct { } func NewEmptySpecContext() *SpecContext { - var p = new(SpecContext) + p := new(SpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_spec return p @@ -429,7 +433,7 @@ func NewEmptySpecContext() *SpecContext { func (*SpecContext) IsSpecContext() {} func NewSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SpecContext { - var p = new(SpecContext) + p := new(SpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -442,7 +446,7 @@ func NewSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokin func (s *SpecContext) GetParser() antlr.Parser { return s.parser } func (s *SpecContext) SyntaxLit() ISyntaxLitContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ISyntaxLitContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*ISyntaxLitContext)(nil)).Elem(), 0) if t == nil { return nil @@ -452,7 +456,7 @@ func (s *SpecContext) SyntaxLit() ISyntaxLitContext { } func (s *SpecContext) ImportSpec() IImportSpecContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportSpecContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IImportSpecContext)(nil)).Elem(), 0) if t == nil { return nil @@ -462,7 +466,7 @@ func (s *SpecContext) ImportSpec() IImportSpecContext { } func (s *SpecContext) InfoSpec() IInfoSpecContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IInfoSpecContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IInfoSpecContext)(nil)).Elem(), 0) if t == nil { return nil @@ -472,7 +476,7 @@ func (s *SpecContext) InfoSpec() IInfoSpecContext { } func (s *SpecContext) TypeSpec() ITypeSpecContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeSpecContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeSpecContext)(nil)).Elem(), 0) if t == nil { return nil @@ -482,7 +486,7 @@ func (s *SpecContext) TypeSpec() ITypeSpecContext { } func (s *SpecContext) ServiceSpec() IServiceSpecContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceSpecContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceSpecContext)(nil)).Elem(), 0) if t == nil { return nil @@ -610,7 +614,7 @@ type SyntaxLitContext struct { } func NewEmptySyntaxLitContext() *SyntaxLitContext { - var p = new(SyntaxLitContext) + p := new(SyntaxLitContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_syntaxLit return p @@ -619,7 +623,7 @@ func NewEmptySyntaxLitContext() *SyntaxLitContext { func (*SyntaxLitContext) IsSyntaxLitContext() {} func NewSyntaxLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SyntaxLitContext { - var p = new(SyntaxLitContext) + p := new(SyntaxLitContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -694,14 +698,14 @@ func (p *ApiParserParser) SyntaxLit() (localctx ISyntaxLitContext) { { p.SetState(88) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*SyntaxLitContext).syntaxToken = _m } { p.SetState(89) - var _m = p.Match(ApiParserParserT__0) + _m := p.Match(ApiParserParserT__0) localctx.(*SyntaxLitContext).assign = _m } @@ -709,7 +713,7 @@ func (p *ApiParserParser) SyntaxLit() (localctx ISyntaxLitContext) { { p.SetState(91) - var _m = p.Match(ApiParserParserSTRING) + _m := p.Match(ApiParserParserSTRING) localctx.(*SyntaxLitContext).version = _m } @@ -734,7 +738,7 @@ type ImportSpecContext struct { } func NewEmptyImportSpecContext() *ImportSpecContext { - var p = new(ImportSpecContext) + p := new(ImportSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_importSpec return p @@ -743,7 +747,7 @@ func NewEmptyImportSpecContext() *ImportSpecContext { func (*ImportSpecContext) IsImportSpecContext() {} func NewImportSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportSpecContext { - var p = new(ImportSpecContext) + p := new(ImportSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -756,7 +760,7 @@ func NewImportSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, i func (s *ImportSpecContext) GetParser() antlr.Parser { return s.parser } func (s *ImportSpecContext) ImportLit() IImportLitContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportLitContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IImportLitContext)(nil)).Elem(), 0) if t == nil { return nil @@ -766,7 +770,7 @@ func (s *ImportSpecContext) ImportLit() IImportLitContext { } func (s *ImportSpecContext) ImportBlock() IImportBlockContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockContext)(nil)).Elem(), 0) if t == nil { return nil @@ -859,7 +863,7 @@ type ImportLitContext struct { } func NewEmptyImportLitContext() *ImportLitContext { - var p = new(ImportLitContext) + p := new(ImportLitContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_importLit return p @@ -868,7 +872,7 @@ func NewEmptyImportLitContext() *ImportLitContext { func (*ImportLitContext) IsImportLitContext() {} func NewImportLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportLitContext { - var p = new(ImportLitContext) + p := new(ImportLitContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -885,7 +889,7 @@ func (s *ImportLitContext) GetImportToken() antlr.Token { return s.importToken } func (s *ImportLitContext) SetImportToken(v antlr.Token) { s.importToken = v } func (s *ImportLitContext) ImportValue() IImportValueContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0) if t == nil { return nil @@ -941,7 +945,7 @@ func (p *ApiParserParser) ImportLit() (localctx IImportLitContext) { { p.SetState(98) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*ImportLitContext).importToken = _m } @@ -977,7 +981,7 @@ type ImportBlockContext struct { } func NewEmptyImportBlockContext() *ImportBlockContext { - var p = new(ImportBlockContext) + p := new(ImportBlockContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_importBlock return p @@ -986,7 +990,7 @@ func NewEmptyImportBlockContext() *ImportBlockContext { func (*ImportBlockContext) IsImportBlockContext() {} func NewImportBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockContext { - var p = new(ImportBlockContext) + p := new(ImportBlockContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -1007,8 +1011,8 @@ func (s *ImportBlockContext) ID() antlr.TerminalNode { } func (s *ImportBlockContext) AllImportBlockValue() []IImportBlockValueContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem()) - var tst = make([]IImportBlockValueContext, len(ts)) + ts := s.GetTypedRuleContexts(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem()) + tst := make([]IImportBlockValueContext, len(ts)) for i, t := range ts { if t != nil { @@ -1020,7 +1024,7 @@ func (s *ImportBlockContext) AllImportBlockValue() []IImportBlockValueContext { } func (s *ImportBlockContext) ImportBlockValue(i int) IImportBlockValueContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem(), i) + t := s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem(), i) if t == nil { return nil @@ -1073,7 +1077,7 @@ func (p *ApiParserParser) ImportBlock() (localctx IImportBlockContext) { { p.SetState(102) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*ImportBlockContext).importToken = _m } @@ -1120,7 +1124,7 @@ type ImportBlockValueContext struct { } func NewEmptyImportBlockValueContext() *ImportBlockValueContext { - var p = new(ImportBlockValueContext) + p := new(ImportBlockValueContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_importBlockValue return p @@ -1129,7 +1133,7 @@ func NewEmptyImportBlockValueContext() *ImportBlockValueContext { func (*ImportBlockValueContext) IsImportBlockValueContext() {} func NewImportBlockValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockValueContext { - var p = new(ImportBlockValueContext) + p := new(ImportBlockValueContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -1142,7 +1146,7 @@ func NewImportBlockValueContext(parser antlr.Parser, parent antlr.ParserRuleCont func (s *ImportBlockValueContext) GetParser() antlr.Parser { return s.parser } func (s *ImportBlockValueContext) ImportValue() IImportValueContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0) if t == nil { return nil @@ -1215,7 +1219,7 @@ type ImportValueContext struct { } func NewEmptyImportValueContext() *ImportValueContext { - var p = new(ImportValueContext) + p := new(ImportValueContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_importValue return p @@ -1224,7 +1228,7 @@ func NewEmptyImportValueContext() *ImportValueContext { func (*ImportValueContext) IsImportValueContext() {} func NewImportValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportValueContext { - var p = new(ImportValueContext) + p := new(ImportValueContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -1326,7 +1330,7 @@ type InfoSpecContext struct { } func NewEmptyInfoSpecContext() *InfoSpecContext { - var p = new(InfoSpecContext) + p := new(InfoSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_infoSpec return p @@ -1335,7 +1339,7 @@ func NewEmptyInfoSpecContext() *InfoSpecContext { func (*InfoSpecContext) IsInfoSpecContext() {} func NewInfoSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InfoSpecContext { - var p = new(InfoSpecContext) + p := new(InfoSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -1364,8 +1368,8 @@ func (s *InfoSpecContext) ID() antlr.TerminalNode { } func (s *InfoSpecContext) AllKvLit() []IKvLitContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem()) - var tst = make([]IKvLitContext, len(ts)) + ts := s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem()) + tst := make([]IKvLitContext, len(ts)) for i, t := range ts { if t != nil { @@ -1377,7 +1381,7 @@ func (s *InfoSpecContext) AllKvLit() []IKvLitContext { } func (s *InfoSpecContext) KvLit(i int) IKvLitContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i) + t := s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i) if t == nil { return nil @@ -1430,14 +1434,14 @@ func (p *ApiParserParser) InfoSpec() (localctx IInfoSpecContext) { { p.SetState(117) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*InfoSpecContext).infoToken = _m } { p.SetState(118) - var _m = p.Match(ApiParserParserT__1) + _m := p.Match(ApiParserParserT__1) localctx.(*InfoSpecContext).lp = _m } @@ -1458,7 +1462,7 @@ func (p *ApiParserParser) InfoSpec() (localctx IInfoSpecContext) { { p.SetState(124) - var _m = p.Match(ApiParserParserT__2) + _m := p.Match(ApiParserParserT__2) localctx.(*InfoSpecContext).rp = _m } @@ -1483,7 +1487,7 @@ type TypeSpecContext struct { } func NewEmptyTypeSpecContext() *TypeSpecContext { - var p = new(TypeSpecContext) + p := new(TypeSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeSpec return p @@ -1492,7 +1496,7 @@ func NewEmptyTypeSpecContext() *TypeSpecContext { func (*TypeSpecContext) IsTypeSpecContext() {} func NewTypeSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeSpecContext { - var p = new(TypeSpecContext) + p := new(TypeSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -1505,7 +1509,7 @@ func NewTypeSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, inv func (s *TypeSpecContext) GetParser() antlr.Parser { return s.parser } func (s *TypeSpecContext) TypeLit() ITypeLitContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitContext)(nil)).Elem(), 0) if t == nil { return nil @@ -1515,7 +1519,7 @@ func (s *TypeSpecContext) TypeLit() ITypeLitContext { } func (s *TypeSpecContext) TypeBlock() ITypeBlockContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockContext)(nil)).Elem(), 0) if t == nil { return nil @@ -1608,7 +1612,7 @@ type TypeLitContext struct { } func NewEmptyTypeLitContext() *TypeLitContext { - var p = new(TypeLitContext) + p := new(TypeLitContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeLit return p @@ -1617,7 +1621,7 @@ func NewEmptyTypeLitContext() *TypeLitContext { func (*TypeLitContext) IsTypeLitContext() {} func NewTypeLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitContext { - var p = new(TypeLitContext) + p := new(TypeLitContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -1634,7 +1638,7 @@ func (s *TypeLitContext) GetTypeToken() antlr.Token { return s.typeToken } func (s *TypeLitContext) SetTypeToken(v antlr.Token) { s.typeToken = v } func (s *TypeLitContext) TypeLitBody() ITypeLitBodyContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitBodyContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitBodyContext)(nil)).Elem(), 0) if t == nil { return nil @@ -1690,7 +1694,7 @@ func (p *ApiParserParser) TypeLit() (localctx ITypeLitContext) { { p.SetState(131) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*TypeLitContext).typeToken = _m } @@ -1740,7 +1744,7 @@ type TypeBlockContext struct { } func NewEmptyTypeBlockContext() *TypeBlockContext { - var p = new(TypeBlockContext) + p := new(TypeBlockContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeBlock return p @@ -1749,7 +1753,7 @@ func NewEmptyTypeBlockContext() *TypeBlockContext { func (*TypeBlockContext) IsTypeBlockContext() {} func NewTypeBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockContext { - var p = new(TypeBlockContext) + p := new(TypeBlockContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -1778,8 +1782,8 @@ func (s *TypeBlockContext) ID() antlr.TerminalNode { } func (s *TypeBlockContext) AllTypeBlockBody() []ITypeBlockBodyContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem()) - var tst = make([]ITypeBlockBodyContext, len(ts)) + ts := s.GetTypedRuleContexts(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem()) + tst := make([]ITypeBlockBodyContext, len(ts)) for i, t := range ts { if t != nil { @@ -1791,7 +1795,7 @@ func (s *TypeBlockContext) AllTypeBlockBody() []ITypeBlockBodyContext { } func (s *TypeBlockContext) TypeBlockBody(i int) ITypeBlockBodyContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem(), i) + t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem(), i) if t == nil { return nil @@ -1844,14 +1848,14 @@ func (p *ApiParserParser) TypeBlock() (localctx ITypeBlockContext) { { p.SetState(135) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*TypeBlockContext).typeToken = _m } { p.SetState(136) - var _m = p.Match(ApiParserParserT__1) + _m := p.Match(ApiParserParserT__1) localctx.(*TypeBlockContext).lp = _m } @@ -1872,7 +1876,7 @@ func (p *ApiParserParser) TypeBlock() (localctx ITypeBlockContext) { { p.SetState(143) - var _m = p.Match(ApiParserParserT__2) + _m := p.Match(ApiParserParserT__2) localctx.(*TypeBlockContext).rp = _m } @@ -1897,7 +1901,7 @@ type TypeLitBodyContext struct { } func NewEmptyTypeLitBodyContext() *TypeLitBodyContext { - var p = new(TypeLitBodyContext) + p := new(TypeLitBodyContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeLitBody return p @@ -1906,7 +1910,7 @@ func NewEmptyTypeLitBodyContext() *TypeLitBodyContext { func (*TypeLitBodyContext) IsTypeLitBodyContext() {} func NewTypeLitBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitBodyContext { - var p = new(TypeLitBodyContext) + p := new(TypeLitBodyContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -1919,7 +1923,7 @@ func NewTypeLitBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, func (s *TypeLitBodyContext) GetParser() antlr.Parser { return s.parser } func (s *TypeLitBodyContext) TypeStruct() ITypeStructContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0) if t == nil { return nil @@ -1929,7 +1933,7 @@ func (s *TypeLitBodyContext) TypeStruct() ITypeStructContext { } func (s *TypeLitBodyContext) TypeAlias() ITypeAliasContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeAliasContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeAliasContext)(nil)).Elem(), 0) if t == nil { return nil @@ -2015,7 +2019,7 @@ type TypeBlockBodyContext struct { } func NewEmptyTypeBlockBodyContext() *TypeBlockBodyContext { - var p = new(TypeBlockBodyContext) + p := new(TypeBlockBodyContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeBlockBody return p @@ -2024,7 +2028,7 @@ func NewEmptyTypeBlockBodyContext() *TypeBlockBodyContext { func (*TypeBlockBodyContext) IsTypeBlockBodyContext() {} func NewTypeBlockBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockBodyContext { - var p = new(TypeBlockBodyContext) + p := new(TypeBlockBodyContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -2037,7 +2041,7 @@ func NewTypeBlockBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext func (s *TypeBlockBodyContext) GetParser() antlr.Parser { return s.parser } func (s *TypeBlockBodyContext) TypeBlockStruct() ITypeBlockStructContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockStructContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockStructContext)(nil)).Elem(), 0) if t == nil { return nil @@ -2047,7 +2051,7 @@ func (s *TypeBlockBodyContext) TypeBlockStruct() ITypeBlockStructContext { } func (s *TypeBlockBodyContext) TypeBlockAlias() ITypeBlockAliasContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockAliasContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockAliasContext)(nil)).Elem(), 0) if t == nil { return nil @@ -2161,7 +2165,7 @@ type TypeStructContext struct { } func NewEmptyTypeStructContext() *TypeStructContext { - var p = new(TypeStructContext) + p := new(TypeStructContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeStruct return p @@ -2170,7 +2174,7 @@ func NewEmptyTypeStructContext() *TypeStructContext { func (*TypeStructContext) IsTypeStructContext() {} func NewTypeStructContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeStructContext { - var p = new(TypeStructContext) + p := new(TypeStructContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -2207,8 +2211,8 @@ func (s *TypeStructContext) ID(i int) antlr.TerminalNode { } func (s *TypeStructContext) AllField() []IFieldContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem()) - var tst = make([]IFieldContext, len(ts)) + ts := s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem()) + tst := make([]IFieldContext, len(ts)) for i, t := range ts { if t != nil { @@ -2220,7 +2224,7 @@ func (s *TypeStructContext) AllField() []IFieldContext { } func (s *TypeStructContext) Field(i int) IFieldContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i) + t := s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i) if t == nil { return nil @@ -2275,7 +2279,7 @@ func (p *ApiParserParser) TypeStruct() (localctx ITypeStructContext) { { p.SetState(154) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*TypeStructContext).structName = _m } @@ -2287,16 +2291,15 @@ func (p *ApiParserParser) TypeStruct() (localctx ITypeStructContext) { { p.SetState(155) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*TypeStructContext).structToken = _m } - } { p.SetState(158) - var _m = p.Match(ApiParserParserT__3) + _m := p.Match(ApiParserParserT__3) localctx.(*TypeStructContext).lbrace = _m } @@ -2310,7 +2313,6 @@ func (p *ApiParserParser) TypeStruct() (localctx ITypeStructContext) { p.SetState(159) p.Field() } - } p.SetState(164) p.GetErrorHandler().Sync(p) @@ -2319,7 +2321,7 @@ func (p *ApiParserParser) TypeStruct() (localctx ITypeStructContext) { { p.SetState(165) - var _m = p.Match(ApiParserParserT__4) + _m := p.Match(ApiParserParserT__4) localctx.(*TypeStructContext).rbrace = _m } @@ -2358,7 +2360,7 @@ type TypeAliasContext struct { } func NewEmptyTypeAliasContext() *TypeAliasContext { - var p = new(TypeAliasContext) + p := new(TypeAliasContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeAlias return p @@ -2367,7 +2369,7 @@ func NewEmptyTypeAliasContext() *TypeAliasContext { func (*TypeAliasContext) IsTypeAliasContext() {} func NewTypeAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeAliasContext { - var p = new(TypeAliasContext) + p := new(TypeAliasContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -2388,7 +2390,7 @@ 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 { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) if t == nil { return nil @@ -2445,7 +2447,7 @@ func (p *ApiParserParser) TypeAlias() (localctx ITypeAliasContext) { { p.SetState(168) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*TypeAliasContext).alias = _m } @@ -2457,11 +2459,10 @@ func (p *ApiParserParser) TypeAlias() (localctx ITypeAliasContext) { { p.SetState(169) - var _m = p.Match(ApiParserParserT__0) + _m := p.Match(ApiParserParserT__0) localctx.(*TypeAliasContext).assign = _m } - } { p.SetState(172) @@ -2516,7 +2517,7 @@ type TypeBlockStructContext struct { } func NewEmptyTypeBlockStructContext() *TypeBlockStructContext { - var p = new(TypeBlockStructContext) + p := new(TypeBlockStructContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeBlockStruct return p @@ -2525,7 +2526,7 @@ func NewEmptyTypeBlockStructContext() *TypeBlockStructContext { func (*TypeBlockStructContext) IsTypeBlockStructContext() {} func NewTypeBlockStructContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockStructContext { - var p = new(TypeBlockStructContext) + p := new(TypeBlockStructContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -2562,8 +2563,8 @@ func (s *TypeBlockStructContext) ID(i int) antlr.TerminalNode { } func (s *TypeBlockStructContext) AllField() []IFieldContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem()) - var tst = make([]IFieldContext, len(ts)) + ts := s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem()) + tst := make([]IFieldContext, len(ts)) for i, t := range ts { if t != nil { @@ -2575,7 +2576,7 @@ func (s *TypeBlockStructContext) AllField() []IFieldContext { } func (s *TypeBlockStructContext) Field(i int) IFieldContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i) + t := s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i) if t == nil { return nil @@ -2630,7 +2631,7 @@ func (p *ApiParserParser) TypeBlockStruct() (localctx ITypeBlockStructContext) { { p.SetState(175) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*TypeBlockStructContext).structName = _m } @@ -2642,16 +2643,15 @@ func (p *ApiParserParser) TypeBlockStruct() (localctx ITypeBlockStructContext) { { p.SetState(176) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*TypeBlockStructContext).structToken = _m } - } { p.SetState(179) - var _m = p.Match(ApiParserParserT__3) + _m := p.Match(ApiParserParserT__3) localctx.(*TypeBlockStructContext).lbrace = _m } @@ -2665,7 +2665,6 @@ func (p *ApiParserParser) TypeBlockStruct() (localctx ITypeBlockStructContext) { p.SetState(180) p.Field() } - } p.SetState(185) p.GetErrorHandler().Sync(p) @@ -2674,7 +2673,7 @@ func (p *ApiParserParser) TypeBlockStruct() (localctx ITypeBlockStructContext) { { p.SetState(186) - var _m = p.Match(ApiParserParserT__4) + _m := p.Match(ApiParserParserT__4) localctx.(*TypeBlockStructContext).rbrace = _m } @@ -2713,7 +2712,7 @@ type TypeBlockAliasContext struct { } func NewEmptyTypeBlockAliasContext() *TypeBlockAliasContext { - var p = new(TypeBlockAliasContext) + p := new(TypeBlockAliasContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeBlockAlias return p @@ -2722,7 +2721,7 @@ func NewEmptyTypeBlockAliasContext() *TypeBlockAliasContext { func (*TypeBlockAliasContext) IsTypeBlockAliasContext() {} func NewTypeBlockAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockAliasContext { - var p = new(TypeBlockAliasContext) + p := new(TypeBlockAliasContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -2743,7 +2742,7 @@ 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 { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) if t == nil { return nil @@ -2800,7 +2799,7 @@ func (p *ApiParserParser) TypeBlockAlias() (localctx ITypeBlockAliasContext) { { p.SetState(189) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*TypeBlockAliasContext).alias = _m } @@ -2812,11 +2811,10 @@ func (p *ApiParserParser) TypeBlockAlias() (localctx ITypeBlockAliasContext) { { p.SetState(190) - var _m = p.Match(ApiParserParserT__0) + _m := p.Match(ApiParserParserT__0) localctx.(*TypeBlockAliasContext).assign = _m } - } { p.SetState(193) @@ -2843,7 +2841,7 @@ type FieldContext struct { } func NewEmptyFieldContext() *FieldContext { - var p = new(FieldContext) + p := new(FieldContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_field return p @@ -2852,7 +2850,7 @@ func NewEmptyFieldContext() *FieldContext { func (*FieldContext) IsFieldContext() {} func NewFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FieldContext { - var p = new(FieldContext) + p := new(FieldContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -2865,7 +2863,7 @@ func NewFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invoki func (s *FieldContext) GetParser() antlr.Parser { return s.parser } func (s *FieldContext) NormalField() INormalFieldContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*INormalFieldContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*INormalFieldContext)(nil)).Elem(), 0) if t == nil { return nil @@ -2875,7 +2873,7 @@ func (s *FieldContext) NormalField() INormalFieldContext { } func (s *FieldContext) AnonymousFiled() IAnonymousFiledContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IAnonymousFiledContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IAnonymousFiledContext)(nil)).Elem(), 0) if t == nil { return nil @@ -2980,7 +2978,7 @@ type NormalFieldContext struct { } func NewEmptyNormalFieldContext() *NormalFieldContext { - var p = new(NormalFieldContext) + p := new(NormalFieldContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_normalField return p @@ -2989,7 +2987,7 @@ func NewEmptyNormalFieldContext() *NormalFieldContext { func (*NormalFieldContext) IsNormalFieldContext() {} func NewNormalFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *NormalFieldContext { - var p = new(NormalFieldContext) + p := new(NormalFieldContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -3010,7 +3008,7 @@ 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 { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) if t == nil { return nil @@ -3070,7 +3068,7 @@ func (p *ApiParserParser) NormalField() (localctx INormalFieldContext) { { p.SetState(201) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*NormalFieldContext).fieldName = _m } @@ -3085,11 +3083,10 @@ func (p *ApiParserParser) NormalField() (localctx INormalFieldContext) { { p.SetState(203) - var _m = p.Match(ApiParserParserRAW_STRING) + _m := p.Match(ApiParserParserRAW_STRING) localctx.(*NormalFieldContext).tag = _m } - } return localctx @@ -3119,7 +3116,7 @@ type AnonymousFiledContext struct { } func NewEmptyAnonymousFiledContext() *AnonymousFiledContext { - var p = new(AnonymousFiledContext) + p := new(AnonymousFiledContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_anonymousFiled return p @@ -3128,7 +3125,7 @@ func NewEmptyAnonymousFiledContext() *AnonymousFiledContext { func (*AnonymousFiledContext) IsAnonymousFiledContext() {} func NewAnonymousFiledContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AnonymousFiledContext { - var p = new(AnonymousFiledContext) + p := new(AnonymousFiledContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -3196,11 +3193,10 @@ func (p *ApiParserParser) AnonymousFiled() (localctx IAnonymousFiledContext) { { p.SetState(206) - var _m = p.Match(ApiParserParserT__5) + _m := p.Match(ApiParserParserT__5) localctx.(*AnonymousFiledContext).star = _m } - } { p.SetState(209) @@ -3241,7 +3237,7 @@ type DataTypeContext struct { } func NewEmptyDataTypeContext() *DataTypeContext { - var p = new(DataTypeContext) + p := new(DataTypeContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_dataType return p @@ -3250,7 +3246,7 @@ func NewEmptyDataTypeContext() *DataTypeContext { func (*DataTypeContext) IsDataTypeContext() {} func NewDataTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DataTypeContext { - var p = new(DataTypeContext) + p := new(DataTypeContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -3275,7 +3271,7 @@ func (s *DataTypeContext) ID() antlr.TerminalNode { } func (s *DataTypeContext) MapType() IMapTypeContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IMapTypeContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IMapTypeContext)(nil)).Elem(), 0) if t == nil { return nil @@ -3285,7 +3281,7 @@ func (s *DataTypeContext) MapType() IMapTypeContext { } func (s *DataTypeContext) ArrayType() IArrayTypeContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IArrayTypeContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IArrayTypeContext)(nil)).Elem(), 0) if t == nil { return nil @@ -3299,7 +3295,7 @@ func (s *DataTypeContext) INTERFACE() antlr.TerminalNode { } func (s *DataTypeContext) PointerType() IPointerTypeContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IPointerTypeContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IPointerTypeContext)(nil)).Elem(), 0) if t == nil { return nil @@ -3309,7 +3305,7 @@ func (s *DataTypeContext) PointerType() IPointerTypeContext { } func (s *DataTypeContext) TypeStruct() ITypeStructContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0) if t == nil { return nil @@ -3386,7 +3382,7 @@ func (p *ApiParserParser) DataType() (localctx IDataTypeContext) { { p.SetState(215) - var _m = p.Match(ApiParserParserINTERFACE) + _m := p.Match(ApiParserParserINTERFACE) localctx.(*DataTypeContext).inter = _m } @@ -3396,7 +3392,7 @@ func (p *ApiParserParser) DataType() (localctx IDataTypeContext) { { p.SetState(216) - var _m = p.Match(ApiParserParserT__6) + _m := p.Match(ApiParserParserT__6) localctx.(*DataTypeContext).time = _m } @@ -3444,7 +3440,7 @@ type PointerTypeContext struct { } func NewEmptyPointerTypeContext() *PointerTypeContext { - var p = new(PointerTypeContext) + p := new(PointerTypeContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_pointerType return p @@ -3453,7 +3449,7 @@ func NewEmptyPointerTypeContext() *PointerTypeContext { func (*PointerTypeContext) IsPointerTypeContext() {} func NewPointerTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PointerTypeContext { - var p = new(PointerTypeContext) + p := new(PointerTypeContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -3515,7 +3511,7 @@ func (p *ApiParserParser) PointerType() (localctx IPointerTypeContext) { { p.SetState(221) - var _m = p.Match(ApiParserParserT__5) + _m := p.Match(ApiParserParserT__5) localctx.(*PointerTypeContext).star = _m } @@ -3580,7 +3576,7 @@ type MapTypeContext struct { } func NewEmptyMapTypeContext() *MapTypeContext { - var p = new(MapTypeContext) + p := new(MapTypeContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_mapType return p @@ -3589,7 +3585,7 @@ func NewEmptyMapTypeContext() *MapTypeContext { func (*MapTypeContext) IsMapTypeContext() {} func NewMapTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MapTypeContext { - var p = new(MapTypeContext) + p := new(MapTypeContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -3630,7 +3626,7 @@ func (s *MapTypeContext) ID(i int) antlr.TerminalNode { } func (s *MapTypeContext) DataType() IDataTypeContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) if t == nil { return nil @@ -3682,14 +3678,14 @@ func (p *ApiParserParser) MapType() (localctx IMapTypeContext) { { p.SetState(226) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*MapTypeContext).mapToken = _m } { p.SetState(227) - var _m = p.Match(ApiParserParserT__7) + _m := p.Match(ApiParserParserT__7) localctx.(*MapTypeContext).lbrack = _m } @@ -3697,21 +3693,21 @@ func (p *ApiParserParser) MapType() (localctx IMapTypeContext) { { p.SetState(229) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*MapTypeContext).key = _m } { p.SetState(230) - var _m = p.Match(ApiParserParserT__8) + _m := p.Match(ApiParserParserT__8) localctx.(*MapTypeContext).rbrack = _m } { p.SetState(231) - var _x = p.DataType() + _x := p.DataType() localctx.(*MapTypeContext).value = _x } @@ -3750,7 +3746,7 @@ type ArrayTypeContext struct { } func NewEmptyArrayTypeContext() *ArrayTypeContext { - var p = new(ArrayTypeContext) + p := new(ArrayTypeContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_arrayType return p @@ -3759,7 +3755,7 @@ func NewEmptyArrayTypeContext() *ArrayTypeContext { func (*ArrayTypeContext) IsArrayTypeContext() {} func NewArrayTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ArrayTypeContext { - var p = new(ArrayTypeContext) + p := new(ArrayTypeContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -3780,7 +3776,7 @@ func (s *ArrayTypeContext) SetLbrack(v antlr.Token) { s.lbrack = v } func (s *ArrayTypeContext) SetRbrack(v antlr.Token) { s.rbrack = v } func (s *ArrayTypeContext) DataType() IDataTypeContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) if t == nil { return nil @@ -3831,14 +3827,14 @@ func (p *ApiParserParser) ArrayType() (localctx IArrayTypeContext) { { p.SetState(233) - var _m = p.Match(ApiParserParserT__7) + _m := p.Match(ApiParserParserT__7) localctx.(*ArrayTypeContext).lbrack = _m } { p.SetState(234) - var _m = p.Match(ApiParserParserT__8) + _m := p.Match(ApiParserParserT__8) localctx.(*ArrayTypeContext).rbrack = _m } @@ -3867,7 +3863,7 @@ type ServiceSpecContext struct { } func NewEmptyServiceSpecContext() *ServiceSpecContext { - var p = new(ServiceSpecContext) + p := new(ServiceSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_serviceSpec return p @@ -3876,7 +3872,7 @@ func NewEmptyServiceSpecContext() *ServiceSpecContext { func (*ServiceSpecContext) IsServiceSpecContext() {} func NewServiceSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceSpecContext { - var p = new(ServiceSpecContext) + p := new(ServiceSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -3889,7 +3885,7 @@ func NewServiceSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, func (s *ServiceSpecContext) GetParser() antlr.Parser { return s.parser } func (s *ServiceSpecContext) ServiceApi() IServiceApiContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceApiContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceApiContext)(nil)).Elem(), 0) if t == nil { return nil @@ -3899,7 +3895,7 @@ func (s *ServiceSpecContext) ServiceApi() IServiceApiContext { } func (s *ServiceSpecContext) AtServer() IAtServerContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0) if t == nil { return nil @@ -3957,7 +3953,6 @@ func (p *ApiParserParser) ServiceSpec() (localctx IServiceSpecContext) { p.SetState(237) p.AtServer() } - } { p.SetState(240) @@ -3998,7 +3993,7 @@ type AtServerContext struct { } func NewEmptyAtServerContext() *AtServerContext { - var p = new(AtServerContext) + p := new(AtServerContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_atServer return p @@ -4007,7 +4002,7 @@ func NewEmptyAtServerContext() *AtServerContext { func (*AtServerContext) IsAtServerContext() {} func NewAtServerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtServerContext { - var p = new(AtServerContext) + p := new(AtServerContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -4032,8 +4027,8 @@ func (s *AtServerContext) ATSERVER() antlr.TerminalNode { } func (s *AtServerContext) AllKvLit() []IKvLitContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem()) - var tst = make([]IKvLitContext, len(ts)) + ts := s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem()) + tst := make([]IKvLitContext, len(ts)) for i, t := range ts { if t != nil { @@ -4045,7 +4040,7 @@ func (s *AtServerContext) AllKvLit() []IKvLitContext { } func (s *AtServerContext) KvLit(i int) IKvLitContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i) + t := s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i) if t == nil { return nil @@ -4101,7 +4096,7 @@ func (p *ApiParserParser) AtServer() (localctx IAtServerContext) { { p.SetState(243) - var _m = p.Match(ApiParserParserT__1) + _m := p.Match(ApiParserParserT__1) localctx.(*AtServerContext).lp = _m } @@ -4122,7 +4117,7 @@ func (p *ApiParserParser) AtServer() (localctx IAtServerContext) { { p.SetState(249) - var _m = p.Match(ApiParserParserT__2) + _m := p.Match(ApiParserParserT__2) localctx.(*AtServerContext).rp = _m } @@ -4168,7 +4163,7 @@ type ServiceApiContext struct { } func NewEmptyServiceApiContext() *ServiceApiContext { - var p = new(ServiceApiContext) + p := new(ServiceApiContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_serviceApi return p @@ -4177,7 +4172,7 @@ func NewEmptyServiceApiContext() *ServiceApiContext { func (*ServiceApiContext) IsServiceApiContext() {} func NewServiceApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceApiContext { - var p = new(ServiceApiContext) + p := new(ServiceApiContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -4202,7 +4197,7 @@ 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 { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceNameContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceNameContext)(nil)).Elem(), 0) if t == nil { return nil @@ -4216,8 +4211,8 @@ func (s *ServiceApiContext) ID() antlr.TerminalNode { } func (s *ServiceApiContext) AllServiceRoute() []IServiceRouteContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem()) - var tst = make([]IServiceRouteContext, len(ts)) + ts := s.GetTypedRuleContexts(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem()) + tst := make([]IServiceRouteContext, len(ts)) for i, t := range ts { if t != nil { @@ -4229,7 +4224,7 @@ func (s *ServiceApiContext) AllServiceRoute() []IServiceRouteContext { } func (s *ServiceApiContext) ServiceRoute(i int) IServiceRouteContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem(), i) + t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem(), i) if t == nil { return nil @@ -4282,7 +4277,7 @@ func (p *ApiParserParser) ServiceApi() (localctx IServiceApiContext) { { p.SetState(252) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*ServiceApiContext).serviceToken = _m } @@ -4293,7 +4288,7 @@ func (p *ApiParserParser) ServiceApi() (localctx IServiceApiContext) { { p.SetState(254) - var _m = p.Match(ApiParserParserT__3) + _m := p.Match(ApiParserParserT__3) localctx.(*ServiceApiContext).lbrace = _m } @@ -4314,7 +4309,7 @@ func (p *ApiParserParser) ServiceApi() (localctx IServiceApiContext) { { p.SetState(261) - var _m = p.Match(ApiParserParserT__4) + _m := p.Match(ApiParserParserT__4) localctx.(*ServiceApiContext).rbrace = _m } @@ -4339,7 +4334,7 @@ type ServiceRouteContext struct { } func NewEmptyServiceRouteContext() *ServiceRouteContext { - var p = new(ServiceRouteContext) + p := new(ServiceRouteContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_serviceRoute return p @@ -4348,7 +4343,7 @@ func NewEmptyServiceRouteContext() *ServiceRouteContext { func (*ServiceRouteContext) IsServiceRouteContext() {} func NewServiceRouteContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceRouteContext { - var p = new(ServiceRouteContext) + p := new(ServiceRouteContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -4361,7 +4356,7 @@ func NewServiceRouteContext(parser antlr.Parser, parent antlr.ParserRuleContext, func (s *ServiceRouteContext) GetParser() antlr.Parser { return s.parser } func (s *ServiceRouteContext) Route() IRouteContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IRouteContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IRouteContext)(nil)).Elem(), 0) if t == nil { return nil @@ -4371,7 +4366,7 @@ func (s *ServiceRouteContext) Route() IRouteContext { } func (s *ServiceRouteContext) AtServer() IAtServerContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0) if t == nil { return nil @@ -4381,7 +4376,7 @@ func (s *ServiceRouteContext) AtServer() IAtServerContext { } func (s *ServiceRouteContext) AtHandler() IAtHandlerContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtHandlerContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IAtHandlerContext)(nil)).Elem(), 0) if t == nil { return nil @@ -4391,7 +4386,7 @@ func (s *ServiceRouteContext) AtHandler() IAtHandlerContext { } func (s *ServiceRouteContext) AtDoc() IAtDocContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtDocContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IAtDocContext)(nil)).Elem(), 0) if t == nil { return nil @@ -4449,7 +4444,6 @@ func (p *ApiParserParser) ServiceRoute() (localctx IServiceRouteContext) { p.SetState(263) p.AtDoc() } - } p.SetState(268) p.GetErrorHandler().Sync(p) @@ -4509,7 +4503,7 @@ type AtDocContext struct { } func NewEmptyAtDocContext() *AtDocContext { - var p = new(AtDocContext) + p := new(AtDocContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_atDoc return p @@ -4518,7 +4512,7 @@ func NewEmptyAtDocContext() *AtDocContext { func (*AtDocContext) IsAtDocContext() {} func NewAtDocContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtDocContext { - var p = new(AtDocContext) + p := new(AtDocContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -4547,8 +4541,8 @@ func (s *AtDocContext) STRING() antlr.TerminalNode { } func (s *AtDocContext) AllKvLit() []IKvLitContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem()) - var tst = make([]IKvLitContext, len(ts)) + ts := s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem()) + tst := make([]IKvLitContext, len(ts)) for i, t := range ts { if t != nil { @@ -4560,7 +4554,7 @@ func (s *AtDocContext) AllKvLit() []IKvLitContext { } func (s *AtDocContext) KvLit(i int) IKvLitContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i) + t := s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i) if t == nil { return nil @@ -4621,11 +4615,10 @@ func (p *ApiParserParser) AtDoc() (localctx IAtDocContext) { { p.SetState(273) - var _m = p.Match(ApiParserParserT__1) + _m := p.Match(ApiParserParserT__1) localctx.(*AtDocContext).lp = _m } - } p.SetState(282) p.GetErrorHandler().Sync(p) @@ -4664,11 +4657,10 @@ func (p *ApiParserParser) AtDoc() (localctx IAtDocContext) { { p.SetState(284) - var _m = p.Match(ApiParserParserT__2) + _m := p.Match(ApiParserParserT__2) localctx.(*AtDocContext).rp = _m } - } return localctx @@ -4691,7 +4683,7 @@ type AtHandlerContext struct { } func NewEmptyAtHandlerContext() *AtHandlerContext { - var p = new(AtHandlerContext) + p := new(AtHandlerContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_atHandler return p @@ -4700,7 +4692,7 @@ func NewEmptyAtHandlerContext() *AtHandlerContext { func (*AtHandlerContext) IsAtHandlerContext() {} func NewAtHandlerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtHandlerContext { - var p = new(AtHandlerContext) + p := new(AtHandlerContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -4816,7 +4808,7 @@ type RouteContext struct { } func NewEmptyRouteContext() *RouteContext { - var p = new(RouteContext) + p := new(RouteContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_route return p @@ -4825,7 +4817,7 @@ func NewEmptyRouteContext() *RouteContext { func (*RouteContext) IsRouteContext() {} func NewRouteContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RouteContext { - var p = new(RouteContext) + p := new(RouteContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -4854,7 +4846,7 @@ func (s *RouteContext) SetRequest(v IBodyContext) { s.request = v } func (s *RouteContext) SetResponse(v IReplybodyContext) { s.response = v } func (s *RouteContext) Path() IPathContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IPathContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IPathContext)(nil)).Elem(), 0) if t == nil { return nil @@ -4872,7 +4864,7 @@ func (s *RouteContext) ID(i int) antlr.TerminalNode { } func (s *RouteContext) Body() IBodyContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IBodyContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IBodyContext)(nil)).Elem(), 0) if t == nil { return nil @@ -4882,7 +4874,7 @@ func (s *RouteContext) Body() IBodyContext { } func (s *RouteContext) Replybody() IReplybodyContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IReplybodyContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IReplybodyContext)(nil)).Elem(), 0) if t == nil { return nil @@ -4935,7 +4927,7 @@ func (p *ApiParserParser) Route() (localctx IRouteContext) { { p.SetState(291) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*RouteContext).httpMethod = _m } @@ -4950,11 +4942,10 @@ func (p *ApiParserParser) Route() (localctx IRouteContext) { { p.SetState(293) - var _x = p.Body() + _x := p.Body() localctx.(*RouteContext).request = _x } - } p.SetState(297) p.GetErrorHandler().Sync(p) @@ -4964,11 +4955,10 @@ func (p *ApiParserParser) Route() (localctx IRouteContext) { { p.SetState(296) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*RouteContext).returnToken = _m } - } p.SetState(300) p.GetErrorHandler().Sync(p) @@ -4978,11 +4968,10 @@ func (p *ApiParserParser) Route() (localctx IRouteContext) { { p.SetState(299) - var _x = p.Replybody() + _x := p.Replybody() localctx.(*RouteContext).response = _x } - } return localctx @@ -5019,7 +5008,7 @@ type BodyContext struct { } func NewEmptyBodyContext() *BodyContext { - var p = new(BodyContext) + p := new(BodyContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_body return p @@ -5028,7 +5017,7 @@ func NewEmptyBodyContext() *BodyContext { func (*BodyContext) IsBodyContext() {} func NewBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *BodyContext { - var p = new(BodyContext) + p := new(BodyContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -5095,7 +5084,7 @@ func (p *ApiParserParser) Body() (localctx IBodyContext) { { p.SetState(302) - var _m = p.Match(ApiParserParserT__1) + _m := p.Match(ApiParserParserT__1) localctx.(*BodyContext).lp = _m } @@ -5108,12 +5097,11 @@ func (p *ApiParserParser) Body() (localctx IBodyContext) { p.SetState(303) p.Match(ApiParserParserID) } - } { p.SetState(306) - var _m = p.Match(ApiParserParserT__2) + _m := p.Match(ApiParserParserT__2) localctx.(*BodyContext).rp = _m } @@ -5152,7 +5140,7 @@ type ReplybodyContext struct { } func NewEmptyReplybodyContext() *ReplybodyContext { - var p = new(ReplybodyContext) + p := new(ReplybodyContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_replybody return p @@ -5161,7 +5149,7 @@ func NewEmptyReplybodyContext() *ReplybodyContext { func (*ReplybodyContext) IsReplybodyContext() {} func NewReplybodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ReplybodyContext { - var p = new(ReplybodyContext) + p := new(ReplybodyContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -5182,7 +5170,7 @@ func (s *ReplybodyContext) SetLp(v antlr.Token) { s.lp = v } func (s *ReplybodyContext) SetRp(v antlr.Token) { s.rp = v } func (s *ReplybodyContext) DataType() IDataTypeContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) + t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0) if t == nil { return nil @@ -5234,7 +5222,7 @@ func (p *ApiParserParser) Replybody() (localctx IReplybodyContext) { { p.SetState(308) - var _m = p.Match(ApiParserParserT__1) + _m := p.Match(ApiParserParserT__1) localctx.(*ReplybodyContext).lp = _m } @@ -5247,12 +5235,11 @@ func (p *ApiParserParser) Replybody() (localctx IReplybodyContext) { p.SetState(309) p.DataType() } - } { p.SetState(312) - var _m = p.Match(ApiParserParserT__2) + _m := p.Match(ApiParserParserT__2) localctx.(*ReplybodyContext).rp = _m } @@ -5291,7 +5278,7 @@ type KvLitContext struct { } func NewEmptyKvLitContext() *KvLitContext { - var p = new(KvLitContext) + p := new(KvLitContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_kvLit return p @@ -5300,7 +5287,7 @@ func NewEmptyKvLitContext() *KvLitContext { func (*KvLitContext) IsKvLitContext() {} func NewKvLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *KvLitContext { - var p = new(KvLitContext) + p := new(KvLitContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -5370,7 +5357,7 @@ func (p *ApiParserParser) KvLit() (localctx IKvLitContext) { { p.SetState(314) - var _m = p.Match(ApiParserParserID) + _m := p.Match(ApiParserParserID) localctx.(*KvLitContext).key = _m } @@ -5378,7 +5365,7 @@ func (p *ApiParserParser) KvLit() (localctx IKvLitContext) { { p.SetState(316) - var _m = p.Match(ApiParserParserLINE_VALUE) + _m := p.Match(ApiParserParserLINE_VALUE) localctx.(*KvLitContext).value = _m } @@ -5403,7 +5390,7 @@ type ServiceNameContext struct { } func NewEmptyServiceNameContext() *ServiceNameContext { - var p = new(ServiceNameContext) + p := new(ServiceNameContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_serviceName return p @@ -5412,7 +5399,7 @@ func NewEmptyServiceNameContext() *ServiceNameContext { func (*ServiceNameContext) IsServiceNameContext() {} func NewServiceNameContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceNameContext { - var p = new(ServiceNameContext) + p := new(ServiceNameContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) @@ -5490,7 +5477,6 @@ func (p *ApiParserParser) ServiceName() (localctx IServiceNameContext) { p.SetState(319) p.Match(ApiParserParserT__9) } - } p.SetState(324) @@ -5518,7 +5504,7 @@ type PathContext struct { } func NewEmptyPathContext() *PathContext { - var p = new(PathContext) + p := new(PathContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_path return p @@ -5527,7 +5513,7 @@ func NewEmptyPathContext() *PathContext { func (*PathContext) IsPathContext() {} func NewPathContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PathContext { - var p = new(PathContext) + p := new(PathContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) diff --git a/tools/goctl/api/parser/g4/gen/api/baseparser.go b/tools/goctl/api/parser/g4/gen/api/baseparser.go index 6738fadc..672fb037 100644 --- a/tools/goctl/api/parser/g4/gen/api/baseparser.go +++ b/tools/goctl/api/parser/g4/gen/api/baseparser.go @@ -16,28 +16,30 @@ const ( tagRegex = `(?m)\x60[a-z]+:".+"\x60` ) -var holder = struct{}{} -var kind = map[string]struct{}{ - "bool": holder, - "int": holder, - "int8": holder, - "int16": holder, - "int32": holder, - "int64": holder, - "uint": holder, - "uint8": holder, - "uint16": holder, - "uint32": holder, - "uint64": holder, - "uintptr": holder, - "float32": holder, - "float64": holder, - "complex64": holder, - "complex128": holder, - "string": holder, - "byte": holder, - "rune": holder, -} +var ( + holder = struct{}{} + kind = map[string]struct{}{ + "bool": holder, + "int": holder, + "int8": holder, + "int16": holder, + "int32": holder, + "int64": holder, + "uint": holder, + "uint8": holder, + "uint16": holder, + "uint32": holder, + "uint64": holder, + "uintptr": holder, + "float32": holder, + "float64": holder, + "complex64": holder, + "complex128": holder, + "string": holder, + "byte": holder, + "rune": holder, + } +) func match(p *ApiParserParser, text string) { v := getCurrentTokenText(p) diff --git a/tools/goctl/api/parser/g4/test/info_test.go b/tools/goctl/api/parser/g4/test/info_test.go index 52f3a771..7794cf0b 100644 --- a/tools/goctl/api/parser/g4/test/info_test.go +++ b/tools/goctl/api/parser/g4/test/info_test.go @@ -145,7 +145,6 @@ line"`), }, }, })) - }) t.Run("mismatched", func(t *testing.T) { diff --git a/tools/goctl/api/parser/g4/test/service_test.go b/tools/goctl/api/parser/g4/test/service_test.go index f69c8d10..1d64a111 100644 --- a/tools/goctl/api/parser/g4/test/service_test.go +++ b/tools/goctl/api/parser/g4/test/service_test.go @@ -120,7 +120,8 @@ func TestRoute(t *testing.T) { PointerExpr: ast.NewTextExpr("*Bar"), Star: ast.NewTextExpr("*"), Name: ast.NewTextExpr("Bar"), - }}, + }, + }, }, })) @@ -224,7 +225,6 @@ func TestAtHandler(t *testing.T) { _, err = parser.Accept(fn, `@handler "foo"`) assert.Error(t, err) }) - } func TestAtDoc(t *testing.T) { diff --git a/tools/goctl/api/parser/parser.go b/tools/goctl/api/parser/parser.go index 7310ed3d..83e6054c 100644 --- a/tools/goctl/api/parser/parser.go +++ b/tools/goctl/api/parser/parser.go @@ -64,7 +64,7 @@ func (p parser) convert2Spec() error { } func (p parser) fillInfo() { - var properties = make(map[string]string, 0) + properties := make(map[string]string, 0) if p.ast.Info != nil { p.spec.Info = spec.Info{} for _, kv := range p.ast.Info.Kvs { @@ -147,8 +147,8 @@ func (p parser) findDefinedType(name string) (*spec.Type, error) { } func (p parser) fieldToMember(field *ast.TypeField) spec.Member { - var name = "" - var tag = "" + name := "" + tag := "" if !field.IsAnonymous { name = field.Name.Text() if field.Tag == nil { @@ -239,7 +239,7 @@ func (p parser) fillService() error { route.ResponseType = p.astTypeToSpec(astRoute.Route.Reply.Name) } if astRoute.AtDoc != nil { - var properties = make(map[string]string, 0) + properties := make(map[string]string, 0) for _, kv := range astRoute.AtDoc.Kv { properties[kv.Key.Text()] = kv.Value.Text() } @@ -271,7 +271,7 @@ func (p parser) fillService() error { func (p parser) fillRouteAtServer(astRoute *ast.ServiceRoute, route *spec.Route) error { if astRoute.AtServer != nil { - var properties = make(map[string]string, 0) + properties := make(map[string]string, 0) for _, kv := range astRoute.AtServer.Kv { properties[kv.Key.Text()] = kv.Value.Text() } @@ -295,7 +295,7 @@ func (p parser) fillRouteAtServer(astRoute *ast.ServiceRoute, route *spec.Route) func (p parser) fillAtServer(item *ast.Service, group *spec.Group) { if item.AtServer != nil { - var properties = make(map[string]string, 0) + properties := make(map[string]string, 0) for _, kv := range item.AtServer.Kv { properties[kv.Key.Text()] = kv.Value.Text() } diff --git a/tools/goctl/api/util/util.go b/tools/goctl/api/util/util.go index 13cbcdcb..2a1a18a7 100644 --- a/tools/goctl/api/util/util.go +++ b/tools/goctl/api/util/util.go @@ -76,7 +76,7 @@ func WriteIndent(writer io.Writer, indent int) { // RemoveComment filters comment content func RemoveComment(line string) string { - var commentIdx = strings.Index(line, "//") + commentIdx := strings.Index(line, "//") if commentIdx >= 0 { return strings.TrimSpace(line[:commentIdx]) } diff --git a/tools/goctl/model/mongo/generate/generate_test.go b/tools/goctl/model/mongo/generate/generate_test.go index 4e651083..5298644b 100644 --- a/tools/goctl/model/mongo/generate/generate_test.go +++ b/tools/goctl/model/mongo/generate/generate_test.go @@ -20,7 +20,7 @@ func TestDo(t *testing.T) { tempDir := t.TempDir() typesfile := filepath.Join(tempDir, "types.go") - err = ioutil.WriteFile(typesfile, []byte(testTypes), 0666) + err = ioutil.WriteFile(typesfile, []byte(testTypes), 0o666) assert.Nil(t, err) err = Do(&Context{ diff --git a/tools/goctl/model/sql/builderx/builder_test.go b/tools/goctl/model/sql/builderx/builder_test.go index 28141f6f..8199963b 100644 --- a/tools/goctl/model/sql/builderx/builder_test.go +++ b/tools/goctl/model/sql/builderx/builder_test.go @@ -68,7 +68,7 @@ func TestBuilderSql(t *testing.T) { } func TestBuildSqlDefaultValue(t *testing.T) { - var eq = builder.Eq{} + eq := builder.Eq{} eq["age"] = 0 eq["user_name"] = "" diff --git a/tools/goctl/model/sql/gen/gen.go b/tools/goctl/model/sql/gen/gen.go index a92e107b..a0860184 100644 --- a/tools/goctl/model/sql/gen/gen.go +++ b/tools/goctl/model/sql/gen/gen.go @@ -230,7 +230,7 @@ func (g *defaultGenerator) genModel(in parser.Table, withCache bool) (string, er return "", err } - var findCode = make([]string, 0) + findCode := make([]string, 0) findOneCode, findOneCodeMethod, err := genFindOne(table, withCache) if err != nil { return "", err diff --git a/tools/goctl/model/sql/gen/gen_test.go b/tools/goctl/model/sql/gen/gen_test.go index 4a888c6e..024f5c10 100644 --- a/tools/goctl/model/sql/gen/gen_test.go +++ b/tools/goctl/model/sql/gen/gen_test.go @@ -15,9 +15,7 @@ import ( "github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx" ) -var ( - source = "CREATE TABLE `test_user` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `mobile` varchar(255) COLLATE utf8mb4_bin NOT NULL,\n `class` bigint NOT NULL,\n `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,\n `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,\n `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE KEY `mobile_unique` (`mobile`),\n UNIQUE KEY `class_name_unique` (`class`,`name`),\n KEY `create_index` (`create_time`),\n KEY `name_index` (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;" -) +var source = "CREATE TABLE `test_user` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `mobile` varchar(255) COLLATE utf8mb4_bin NOT NULL,\n `class` bigint NOT NULL,\n `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,\n `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,\n `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE KEY `mobile_unique` (`mobile`),\n UNIQUE KEY `class_name_unique` (`class`,`name`),\n KEY `create_index` (`create_time`),\n KEY `name_index` (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;" func TestCacheModel(t *testing.T) { logx.Disable() diff --git a/tools/goctl/model/sql/gen/keys_test.go b/tools/goctl/model/sql/gen/keys_test.go index 58aaa160..8fd9e507 100644 --- a/tools/goctl/model/sql/gen/keys_test.go +++ b/tools/goctl/model/sql/gen/keys_test.go @@ -134,7 +134,6 @@ func TestGenCacheKeys(t *testing.T) { return true }()) }) - } func cacheKeyEqual(k1 Key, k2 Key) bool { @@ -161,5 +160,4 @@ func cacheKeyEqual(k1 Key, k2 Key) bool { k1.DataKeyRight == k2.DataKeyRight && k1.DataKeyExpression == k2.DataKeyExpression && k1.KeyExpression == k2.KeyExpression - } diff --git a/tools/goctl/model/sql/parser/parser.go b/tools/goctl/model/sql/parser/parser.go index 15d3d9a4..3c8823d2 100644 --- a/tools/goctl/model/sql/parser/parser.go +++ b/tools/goctl/model/sql/parser/parser.go @@ -165,7 +165,7 @@ func convertColumns(columns []*sqlparser.ColumnDefinition, primaryColumn string) comment = string(column.Type.Comment.Val) } - var isDefaultNull = true + isDefaultNull := true if column.Type.NotNull { isDefaultNull = false } else { diff --git a/tools/goctl/plugin/plugin.go b/tools/goctl/plugin/plugin.go index a87fcb0b..9e47b082 100644 --- a/tools/goctl/plugin/plugin.go +++ b/tools/goctl/plugin/plugin.go @@ -37,7 +37,7 @@ func PluginCommand(c *cli.Context) error { panic(err) } - var plugin = c.String("plugin") + plugin := c.String("plugin") if len(plugin) == 0 { return errors.New("missing plugin") } @@ -113,7 +113,7 @@ func getCommand(arg string) (string, bool, error) { return abs, false, nil } - var defaultErr = errors.New("invalid plugin value " + arg) + defaultErr := errors.New("invalid plugin value " + arg) if strings.HasPrefix(arg, "http") { items := strings.Split(arg, "/") if len(items) == 0 { diff --git a/tools/goctl/rpc/generator/gencall.go b/tools/goctl/rpc/generator/gencall.go index 4c6f7426..2f1a0e5c 100644 --- a/tools/goctl/rpc/generator/gencall.go +++ b/tools/goctl/rpc/generator/gencall.go @@ -89,7 +89,7 @@ func (g *DefaultGenerator) GenCall(ctx DirContext, proto parser.Proto, cfg *conf return err } - var alias = collection.NewSet() + alias := collection.NewSet() for _, item := range proto.Message { alias.AddStr(fmt.Sprintf("%s = %s", parser.CamelCase(item.Name), fmt.Sprintf("%s.%s", proto.PbPackage, parser.CamelCase(item.Name)))) } diff --git a/tools/goctl/rpc/generator/genlogic.go b/tools/goctl/rpc/generator/genlogic.go index c303f1ea..62eb9111 100644 --- a/tools/goctl/rpc/generator/genlogic.go +++ b/tools/goctl/rpc/generator/genlogic.go @@ -83,7 +83,7 @@ func (g *DefaultGenerator) GenLogic(ctx DirContext, proto parser.Proto, cfg *con } func (g *DefaultGenerator) genLogicFunction(goPackage string, rpc *parser.RPC) (string, error) { - var functions = make([]string, 0) + functions := make([]string, 0) text, err := util.LoadTemplate(category, logicFuncTemplateFileFile, logicFunctionTemplate) if err != nil { return "", err diff --git a/tools/goctl/rpc/parser/parser.go b/tools/goctl/rpc/parser/parser.go index 718cc37e..a6ff0610 100644 --- a/tools/goctl/rpc/parser/parser.go +++ b/tools/goctl/rpc/parser/parser.go @@ -164,6 +164,7 @@ func CamelCase(s string) string { } return string(t) } + func isASCIILower(c byte) bool { return 'a' <= c && c <= 'z' } diff --git a/tools/goctl/util/console/console.go b/tools/goctl/util/console/console.go index c20fde6a..9ed43371 100644 --- a/tools/goctl/util/console/console.go +++ b/tools/goctl/util/console/console.go @@ -21,11 +21,9 @@ type ( MarkDone() Must(err error) } - colorConsole struct { - } + colorConsole struct{} // for idea log - ideaConsole struct { - } + ideaConsole struct{} ) // NewConsole returns an instance of Console diff --git a/tools/goctl/util/path.go b/tools/goctl/util/path.go index a1e07181..4371c62e 100644 --- a/tools/goctl/util/path.go +++ b/tools/goctl/util/path.go @@ -61,8 +61,8 @@ func FindGoModPath(dir string) (string, bool) { absDir = strings.ReplaceAll(absDir, `\`, `/`) var rootPath string - var tempPath = absDir - var hasGoMod = false + tempPath := absDir + hasGoMod := false for { if FileExists(filepath.Join(tempPath, goModeIdentifier)) { rootPath = strings.TrimPrefix(absDir[len(tempPath):], "/") diff --git a/tools/goctl/util/stringx/string.go b/tools/goctl/util/stringx/string.go index bbfc8203..1e3e6161 100644 --- a/tools/goctl/util/stringx/string.go +++ b/tools/goctl/util/stringx/string.go @@ -42,7 +42,7 @@ func (s String) ReplaceAll(old, new string) string { return strings.ReplaceAll(s.source, old, new) } -//Source returns the source string value +// Source returns the source string value func (s String) Source() string { return s.source } diff --git a/tools/goctl/util/templatex.go b/tools/goctl/util/templatex.go index 19942605..9a9fa734 100644 --- a/tools/goctl/util/templatex.go +++ b/tools/goctl/util/templatex.go @@ -7,7 +7,7 @@ import ( "text/template" ) -const regularPerm = 0666 +const regularPerm = 0o666 // DefaultTemplate is a tool to provides the text/template operations type DefaultTemplate struct { diff --git a/zrpc/internal/balancer/p2c/p2c.go b/zrpc/internal/balancer/p2c/p2c.go index abaee516..dca22d6c 100644 --- a/zrpc/internal/balancer/p2c/p2c.go +++ b/zrpc/internal/balancer/p2c/p2c.go @@ -36,8 +36,7 @@ func init() { balancer.Register(newBuilder()) } -type p2cPickerBuilder struct { -} +type p2cPickerBuilder struct{} func newBuilder() balancer.Builder { return base.NewBalancerBuilder(Name, new(p2cPickerBuilder)) diff --git a/zrpc/internal/balancer/p2c/p2c_test.go b/zrpc/internal/balancer/p2c/p2c_test.go index 7743c534..8df500b6 100644 --- a/zrpc/internal/balancer/p2c/p2c_test.go +++ b/zrpc/internal/balancer/p2c/p2c_test.go @@ -103,8 +103,7 @@ func TestP2cPicker_Pick(t *testing.T) { } } -type mockClientConn struct { -} +type mockClientConn struct{} func (m mockClientConn) UpdateAddresses(addresses []resolver.Address) { } diff --git a/zrpc/internal/mock/deposit.pb.go b/zrpc/internal/mock/deposit.pb.go index 22534ac6..60a43c5a 100644 --- a/zrpc/internal/mock/deposit.pb.go +++ b/zrpc/internal/mock/deposit.pb.go @@ -14,9 +14,11 @@ It has these top-level messages: */ package mock -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + proto "github.com/golang/protobuf/proto" + fmt "fmt" + math "math" +) import ( context "golang.org/x/net/context" @@ -24,9 +26,11 @@ import ( ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -72,8 +76,10 @@ func init() { } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. diff --git a/zrpc/internal/mock/depositserver.go b/zrpc/internal/mock/depositserver.go index 16ef01a0..658a1b77 100644 --- a/zrpc/internal/mock/depositserver.go +++ b/zrpc/internal/mock/depositserver.go @@ -8,8 +8,7 @@ import ( ) // DepositServer is used for mocking. -type DepositServer struct { -} +type DepositServer struct{} // Deposit handles the deposit requests. func (*DepositServer) Deposit(ctx context.Context, req *DepositRequest) (*DepositResponse, error) { diff --git a/zrpc/internal/serverinterceptors/sheddinginterceptor_test.go b/zrpc/internal/serverinterceptors/sheddinginterceptor_test.go index 55ac22c1..a7ceb4bf 100644 --- a/zrpc/internal/serverinterceptors/sheddinginterceptor_test.go +++ b/zrpc/internal/serverinterceptors/sheddinginterceptor_test.go @@ -67,8 +67,7 @@ func (m mockedShedder) Allow() (load.Promise, error) { return nil, load.ErrServiceOverloaded } -type mockedPromise struct { -} +type mockedPromise struct{} func (m mockedPromise) Pass() { }