Skip to content

Commit 27985a0

Browse files
authored
Merge pull request #332 from xuthus5/chore/format
chore: format code style
2 parents 9660dd0 + 4596b73 commit 27985a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+190
-173
lines changed

agcache/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package agcache
1919

20-
//CacheInterface 自定义缓存组件接口
20+
// CacheInterface 自定义缓存组件接口
2121
type CacheInterface interface {
2222
Set(key string, value interface{}, expireSeconds int) (err error)
2323

@@ -32,7 +32,7 @@ type CacheInterface interface {
3232
Clear()
3333
}
3434

35-
//CacheFactory 缓存组件工厂接口
35+
// CacheFactory 缓存组件工厂接口
3636
type CacheFactory interface {
3737
//Create 创建缓存组件
3838
Create() CacheInterface

agcache/memory/memory.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,26 @@ import (
2525
"github.com/apolloconfig/agollo/v4/agcache"
2626
)
2727

28-
//DefaultCache 默认缓存
28+
// DefaultCache 默认缓存
2929
type DefaultCache struct {
3030
defaultCache sync.Map
3131
count int64
3232
}
3333

34-
//Set 获取缓存
34+
// Set 获取缓存
3535
func (d *DefaultCache) Set(key string, value interface{}, expireSeconds int) (err error) {
3636
d.defaultCache.Store(key, value)
3737
atomic.AddInt64(&d.count, int64(1))
3838
return nil
3939
}
4040

41-
//EntryCount 获取实体数量
41+
// EntryCount 获取实体数量
4242
func (d *DefaultCache) EntryCount() (entryCount int64) {
4343
c := atomic.LoadInt64(&d.count)
4444
return c
4545
}
4646

47-
//Get 获取缓存
47+
// Get 获取缓存
4848
func (d *DefaultCache) Get(key string) (value interface{}, err error) {
4949
v, ok := d.defaultCache.Load(key)
5050
if !ok {
@@ -53,29 +53,29 @@ func (d *DefaultCache) Get(key string) (value interface{}, err error) {
5353
return v, nil
5454
}
5555

56-
//Range 遍历缓存
56+
// Range 遍历缓存
5757
func (d *DefaultCache) Range(f func(key, value interface{}) bool) {
5858
d.defaultCache.Range(f)
5959
}
6060

61-
//Del 删除缓存
61+
// Del 删除缓存
6262
func (d *DefaultCache) Del(key string) (affected bool) {
6363
d.defaultCache.Delete(key)
6464
atomic.AddInt64(&d.count, int64(-1))
6565
return true
6666
}
6767

68-
//Clear 清除所有缓存
68+
// Clear 清除所有缓存
6969
func (d *DefaultCache) Clear() {
7070
d.defaultCache = sync.Map{}
7171
atomic.StoreInt64(&d.count, int64(0))
7272
}
7373

74-
//DefaultCacheFactory 构造默认缓存组件工厂类
74+
// DefaultCacheFactory 构造默认缓存组件工厂类
7575
type DefaultCacheFactory struct {
7676
}
7777

78-
//Create 创建默认缓存组件
78+
// Create 创建默认缓存组件
7979
func (d *DefaultCacheFactory) Create() agcache.CacheInterface {
8080
return &DefaultCache{}
8181
}

agcache/memory/memory_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ package memory
2020
import (
2121
"testing"
2222

23-
"github.com/apolloconfig/agollo/v4/agcache"
2423
. "github.com/tevid/gohamcrest"
24+
25+
"github.com/apolloconfig/agollo/v4/agcache"
2526
)
2627

2728
var testDefaultCache agcache.CacheInterface

client_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@ import (
2727
"time"
2828

2929
"github.com/agiledragon/gomonkey/v2"
30+
. "github.com/tevid/gohamcrest"
3031

3132
"github.com/apolloconfig/agollo/v4/agcache/memory"
3233
"github.com/apolloconfig/agollo/v4/component/remote"
3334
"github.com/apolloconfig/agollo/v4/env/config"
34-
"github.com/apolloconfig/agollo/v4/env/server"
35-
3635
_ "github.com/apolloconfig/agollo/v4/env/file/json"
36+
"github.com/apolloconfig/agollo/v4/env/server"
3737
"github.com/apolloconfig/agollo/v4/extension"
3838
"github.com/apolloconfig/agollo/v4/storage"
39-
. "github.com/tevid/gohamcrest"
4039
)
4140

4241
const testDefaultNamespace = "application"

cluster/load_balance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/apolloconfig/agollo/v4/env/config"
2222
)
2323

24-
//LoadBalance 负载均衡器
24+
// LoadBalance 负载均衡器
2525
type LoadBalance interface {
2626
//Load 负载均衡,获取对应服务信息
2727
Load(servers map[string]*config.ServerInfo) *config.ServerInfo

cluster/roundrobin/round_robin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import (
2121
"github.com/apolloconfig/agollo/v4/env/config"
2222
)
2323

24-
//RoundRobin 轮询调度
24+
// RoundRobin 轮询调度
2525
type RoundRobin struct {
2626
}
2727

28-
//Load 负载均衡
28+
// Load 负载均衡
2929
func (r *RoundRobin) Load(servers map[string]*config.ServerInfo) *config.ServerInfo {
3030
var returnServer *config.ServerInfo
3131
for _, server := range servers {

cluster/roundrobin/round_robin_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ package roundrobin
2020
import (
2121
"testing"
2222

23+
. "github.com/tevid/gohamcrest"
24+
2325
"github.com/apolloconfig/agollo/v4/component/serverlist"
26+
"github.com/apolloconfig/agollo/v4/env"
2427
"github.com/apolloconfig/agollo/v4/env/config"
2528
"github.com/apolloconfig/agollo/v4/env/server"
2629
"github.com/apolloconfig/agollo/v4/protocol/http"
27-
28-
"github.com/apolloconfig/agollo/v4/env"
29-
. "github.com/tevid/gohamcrest"
3030
)
3131

3232
const servicesConfigResponseStr = `[{

component/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
package component
1919

20-
//AbsComponent 定时组件
20+
// AbsComponent 定时组件
2121
type AbsComponent interface {
2222
Start()
2323
}
2424

25-
//StartRefreshConfig 开始定时服务
25+
// StartRefreshConfig 开始定时服务
2626
func StartRefreshConfig(component AbsComponent) {
2727
component.Start()
2828
}

component/common_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,19 @@
1818
package component
1919

2020
import (
21+
json2 "encoding/json"
2122
"testing"
2223

23-
"github.com/apolloconfig/agollo/v4/component/log"
24-
"github.com/apolloconfig/agollo/v4/env/server"
25-
"github.com/apolloconfig/agollo/v4/protocol/http"
24+
. "github.com/tevid/gohamcrest"
2625

2726
"github.com/apolloconfig/agollo/v4/cluster/roundrobin"
27+
"github.com/apolloconfig/agollo/v4/component/log"
2828
"github.com/apolloconfig/agollo/v4/env"
2929
"github.com/apolloconfig/agollo/v4/env/config"
3030
"github.com/apolloconfig/agollo/v4/env/config/json"
31+
"github.com/apolloconfig/agollo/v4/env/server"
3132
"github.com/apolloconfig/agollo/v4/extension"
32-
. "github.com/tevid/gohamcrest"
33-
34-
json2 "encoding/json"
33+
"github.com/apolloconfig/agollo/v4/protocol/http"
3534
)
3635

3736
func init() {
@@ -121,7 +120,7 @@ func TestSelectOnlyOneHost(t *testing.T) {
121120
type testComponent struct {
122121
}
123122

124-
//Start 启动同步服务器列表
123+
// Start 启动同步服务器列表
125124
func (s *testComponent) Start() {
126125
}
127126

@@ -137,7 +136,7 @@ func trySyncServerIPList(appConfigFunc func() config.AppConfig) {
137136
SyncServerIPListSuccessCallBack([]byte(servicesConfigResponseStr), http.CallBack{AppConfigFunc: appConfigFunc})
138137
}
139138

140-
//SyncServerIPListSuccessCallBack 同步服务器列表成功后的回调
139+
// SyncServerIPListSuccessCallBack 同步服务器列表成功后的回调
141140
func SyncServerIPListSuccessCallBack(responseBody []byte, callback http.CallBack) (o interface{}, err error) {
142141
log.Debug("get all server info:", string(responseBody))
143142

component/log/log.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717

1818
package log
1919

20-
//Logger logger 对象
20+
// Logger logger 对象
2121
var Logger LoggerInterface
2222

2323
func init() {
2424
Logger = &DefaultLogger{}
2525
}
2626

27-
//InitLogger 初始化logger对象
27+
// InitLogger 初始化logger对象
2828
func InitLogger(ILogger LoggerInterface) {
2929
Logger = ILogger
3030
}
3131

32-
//LoggerInterface 日志接口
32+
// LoggerInterface 日志接口
3333
type LoggerInterface interface {
3434
Debugf(format string, params ...interface{})
3535

@@ -48,82 +48,82 @@ type LoggerInterface interface {
4848
Error(v ...interface{})
4949
}
5050

51-
//Debugf debug 格式化
51+
// Debugf debug 格式化
5252
func Debugf(format string, params ...interface{}) {
5353
Logger.Debugf(format, params...)
5454
}
5555

56-
//Infof 打印info
56+
// Infof 打印info
5757
func Infof(format string, params ...interface{}) {
5858
Logger.Infof(format, params...)
5959
}
6060

61-
//Warnf warn格式化
61+
// Warnf warn格式化
6262
func Warnf(format string, params ...interface{}) {
6363
Logger.Warnf(format, params...)
6464
}
6565

66-
//Errorf error格式化
66+
// Errorf error格式化
6767
func Errorf(format string, params ...interface{}) {
6868
Logger.Errorf(format, params...)
6969
}
7070

71-
//Debug 打印debug
71+
// Debug 打印debug
7272
func Debug(v ...interface{}) {
7373
Logger.Debug(v...)
7474
}
7575

76-
//Info 打印Info
76+
// Info 打印Info
7777
func Info(v ...interface{}) {
7878
Logger.Info(v...)
7979
}
8080

81-
//Warn 打印Warn
81+
// Warn 打印Warn
8282
func Warn(v ...interface{}) {
8383
Logger.Warn(v...)
8484
}
8585

86-
//Error 打印Error
86+
// Error 打印Error
8787
func Error(v ...interface{}) {
8888
Logger.Error(v...)
8989
}
9090

91-
//DefaultLogger 默认日志实现
91+
// DefaultLogger 默认日志实现
9292
type DefaultLogger struct {
9393
}
9494

95-
//Debugf debug 格式化
95+
// Debugf debug 格式化
9696
func (d *DefaultLogger) Debugf(format string, params ...interface{}) {
9797

9898
}
9999

100-
//Infof 打印info
100+
// Infof 打印info
101101
func (d *DefaultLogger) Infof(format string, params ...interface{}) {
102102

103103
}
104104

105-
//Warnf warn格式化
105+
// Warnf warn格式化
106106
func (d *DefaultLogger) Warnf(format string, params ...interface{}) {
107107
}
108108

109-
//Errorf error格式化
109+
// Errorf error格式化
110110
func (d *DefaultLogger) Errorf(format string, params ...interface{}) {
111111
}
112112

113-
//Debug 打印debug
113+
// Debug 打印debug
114114
func (d *DefaultLogger) Debug(v ...interface{}) {
115115

116116
}
117117

118-
//Info 打印Info
118+
// Info 打印Info
119119
func (d *DefaultLogger) Info(v ...interface{}) {
120120

121121
}
122122

123-
//Warn 打印Warn
123+
// Warn 打印Warn
124124
func (d *DefaultLogger) Warn(v ...interface{}) {
125125
}
126126

127-
//Error 打印Error
127+
// Error 打印Error
128128
func (d *DefaultLogger) Error(v ...interface{}) {
129129
}

component/notify/change_event_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ import (
2424
"testing"
2525
"time"
2626

27+
. "github.com/tevid/gohamcrest"
28+
2729
"github.com/apolloconfig/agollo/v4/agcache/memory"
30+
_ "github.com/apolloconfig/agollo/v4/agcache/memory"
2831
"github.com/apolloconfig/agollo/v4/cluster/roundrobin"
2932
"github.com/apolloconfig/agollo/v4/component/remote"
3033
"github.com/apolloconfig/agollo/v4/env/config"
34+
_ "github.com/apolloconfig/agollo/v4/env/file/json"
3135
jsonFile "github.com/apolloconfig/agollo/v4/env/file/json"
3236
"github.com/apolloconfig/agollo/v4/extension"
33-
34-
_ "github.com/apolloconfig/agollo/v4/agcache/memory"
35-
_ "github.com/apolloconfig/agollo/v4/env/file/json"
3637
"github.com/apolloconfig/agollo/v4/storage"
37-
. "github.com/tevid/gohamcrest"
3838
)
3939

4040
func init() {

component/notify/componet_notify.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ import (
2121
"time"
2222

2323
"github.com/apolloconfig/agollo/v4/component/remote"
24-
"github.com/apolloconfig/agollo/v4/storage"
25-
2624
"github.com/apolloconfig/agollo/v4/env/config"
25+
"github.com/apolloconfig/agollo/v4/storage"
2726
)
2827

2928
const (
3029
longPollInterval = 2 * time.Second //2s
3130
)
3231

33-
//ConfigComponent 配置组件
32+
// ConfigComponent 配置组件
3433
type ConfigComponent struct {
3534
appConfigFunc func() config.AppConfig
3635
cache *storage.Cache
@@ -47,7 +46,7 @@ func (c *ConfigComponent) SetCache(cache *storage.Cache) {
4746
c.cache = cache
4847
}
4948

50-
//Start 启动配置组件定时器
49+
// Start 启动配置组件定时器
5150
func (c *ConfigComponent) Start() {
5251
if c.stopCh == nil {
5352
c.stopCh = make(chan interface{})

0 commit comments

Comments
 (0)