Skip to content

Commit 8fbb91e

Browse files
committed
client, pkg, server, test: replaced 'interface{}' with 'any'
1 parent 01fed8d commit 8fbb91e

File tree

19 files changed

+57
-57
lines changed

19 files changed

+57
-57
lines changed

client/event/event.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
var ErrPayloadType = errors.New("error payload type")
1010

11-
type Handler func(payload interface{}) error
11+
type Handler func(payload any) error
1212

1313
type StartProxyPayload struct {
1414
NewProxyMsg *msg.NewProxy

client/proxy/proxy_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (pm *Manager) HandleWorkConn(name string, workConn net.Conn, m *msg.StartWo
9696
}
9797
}
9898

99-
func (pm *Manager) HandleEvent(payload interface{}) error {
99+
func (pm *Manager) HandleEvent(payload any) error {
100100
var m msg.Message
101101
switch e := payload.(type) {
102102
case *event.StartProxyPayload:

pkg/config/legacy/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ type ClientCommonConf struct {
170170
}
171171

172172
// Supported sources including: string(file path), []byte, Reader interface.
173-
func UnmarshalClientConfFromIni(source interface{}) (ClientCommonConf, error) {
173+
func UnmarshalClientConfFromIni(source any) (ClientCommonConf, error) {
174174
f, err := ini.LoadSources(ini.LoadOptions{
175175
Insensitive: false,
176176
InsensitiveSections: false,
@@ -203,7 +203,7 @@ func UnmarshalClientConfFromIni(source interface{}) (ClientCommonConf, error) {
203203
// otherwise just start proxies in startProxy map
204204
func LoadAllProxyConfsFromIni(
205205
prefix string,
206-
source interface{},
206+
source any,
207207
start []string,
208208
) (map[string]ProxyConf, map[string]VisitorConf, error) {
209209
f, err := ini.LoadSources(ini.LoadOptions{

pkg/config/legacy/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func GetDefaultServerConf() ServerCommonConf {
217217
}
218218
}
219219

220-
func UnmarshalServerConfFromIni(source interface{}) (ServerCommonConf, error) {
220+
func UnmarshalServerConfFromIni(source any) (ServerCommonConf, error) {
221221
f, err := ini.LoadSources(ini.LoadOptions{
222222
Insensitive: false,
223223
InsensitiveSections: false,

pkg/config/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func LoadConfigure(b []byte, c any, strict bool) error {
118118
defer v1.DisallowUnknownFieldsMu.Unlock()
119119
v1.DisallowUnknownFields = strict
120120

121-
var tomlObj interface{}
121+
var tomlObj any
122122
// Try to unmarshal as TOML first; swallow errors from that (assume it's not valid TOML).
123123
if err := toml.Unmarshal(b, &tomlObj); err == nil {
124124
b, err = json.Marshal(&tomlObj)

pkg/msg/ctl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ func ReadMsgInto(c io.Reader, msg Message) (err error) {
3939
return msgCtl.ReadMsgInto(c, msg)
4040
}
4141

42-
func WriteMsg(c io.Writer, msg interface{}) (err error) {
42+
func WriteMsg(c io.Writer, msg any) (err error) {
4343
return msgCtl.WriteMsg(c, msg)
4444
}

pkg/msg/msg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const (
4040
TypeNatHoleReport = '6'
4141
)
4242

43-
var msgTypeMap = map[byte]interface{}{
43+
var msgTypeMap = map[byte]any{
4444
TypeLogin: Login{},
4545
TypeLoginResp: LoginResp{},
4646
TypeNewProxy: NewProxy{},

pkg/plugin/server/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (p *httpPlugin) IsSupport(op string) bool {
7272
return false
7373
}
7474

75-
func (p *httpPlugin) Handle(ctx context.Context, op string, content interface{}) (*Response, interface{}, error) {
75+
func (p *httpPlugin) Handle(ctx context.Context, op string, content any) (*Response, any, error) {
7676
r := &Request{
7777
Version: APIVersion,
7878
Op: op,

pkg/plugin/server/manager.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (m *Manager) Login(content *LoginContent) (*LoginContent, error) {
7575
Reject: false,
7676
Unchange: true,
7777
}
78-
retContent interface{}
78+
retContent any
7979
err error
8080
)
8181
reqid, _ := util.RandID()
@@ -109,7 +109,7 @@ func (m *Manager) NewProxy(content *NewProxyContent) (*NewProxyContent, error) {
109109
Reject: false,
110110
Unchange: true,
111111
}
112-
retContent interface{}
112+
retContent any
113113
err error
114114
)
115115
reqid, _ := util.RandID()
@@ -168,7 +168,7 @@ func (m *Manager) Ping(content *PingContent) (*PingContent, error) {
168168
Reject: false,
169169
Unchange: true,
170170
}
171-
retContent interface{}
171+
retContent any
172172
err error
173173
)
174174
reqid, _ := util.RandID()
@@ -202,7 +202,7 @@ func (m *Manager) NewWorkConn(content *NewWorkConnContent) (*NewWorkConnContent,
202202
Reject: false,
203203
Unchange: true,
204204
}
205-
retContent interface{}
205+
retContent any
206206
err error
207207
)
208208
reqid, _ := util.RandID()
@@ -236,7 +236,7 @@ func (m *Manager) NewUserConn(content *NewUserConnContent) (*NewUserConnContent,
236236
Reject: false,
237237
Unchange: true,
238238
}
239-
retContent interface{}
239+
retContent any
240240
err error
241241
)
242242
reqid, _ := util.RandID()

pkg/plugin/server/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ const (
3232
type Plugin interface {
3333
Name() string
3434
IsSupport(op string) bool
35-
Handle(ctx context.Context, op string, content interface{}) (res *Response, retContent interface{}, err error)
35+
Handle(ctx context.Context, op string, content any) (res *Response, retContent any, err error)
3636
}

0 commit comments

Comments
 (0)