Skip to content

Commit 275bd1f

Browse files
committed
Avoid channel pointer usages.
1 parent 3ae0280 commit 275bd1f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

handler.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package fpgo
44
type HandlerDef struct {
55
isClosed bool
66

7-
ch *chan func()
7+
ch chan func()
88
}
99

1010
var defaultHandler *HandlerDef
@@ -17,11 +17,11 @@ func (handlerSelf *HandlerDef) GetDefault() *HandlerDef {
1717
// New New Handler instance
1818
func (handlerSelf *HandlerDef) New() *HandlerDef {
1919
ch := make(chan func())
20-
return handlerSelf.NewByCh(&ch)
20+
return handlerSelf.NewByCh(ch)
2121
}
2222

2323
// NewByCh New Handler by its Channel
24-
func (handlerSelf *HandlerDef) NewByCh(ioCh *chan func()) *HandlerDef {
24+
func (handlerSelf *HandlerDef) NewByCh(ioCh chan func()) *HandlerDef {
2525
new := HandlerDef{ch: ioCh}
2626
go new.run()
2727

@@ -34,14 +34,14 @@ func (handlerSelf *HandlerDef) Post(fn func()) {
3434
return
3535
}
3636

37-
*(handlerSelf.ch) <- fn
37+
handlerSelf.ch <- fn
3838
}
3939

4040
// Close Close the Handler
4141
func (handlerSelf *HandlerDef) Close() {
4242
handlerSelf.isClosed = true
4343

44-
close(*handlerSelf.ch)
44+
close(handlerSelf.ch)
4545
}
4646

4747
// IsClosed Check is Closed
@@ -50,7 +50,7 @@ func (handlerSelf *HandlerDef) IsClosed() bool {
5050
}
5151

5252
func (handlerSelf *HandlerDef) run() {
53-
for fn := range *handlerSelf.ch {
53+
for fn := range handlerSelf.ch {
5454
fn()
5555
}
5656
}

0 commit comments

Comments
 (0)