84 that.join()
85 // Add Timer for Refresh and so on.
86 that.fetch()
87 return88}
89
90func (that *Peer) Exit() {
57 }
58 delete(peer.Router.Neighbor, neighbor.HashString())
59 log.Println(neighbor, "exit blockchain network.")
60 break61 default:
62 break
63 }
49 //}
50 log.Println(peerInfo, "ask for blockchain network.")
51 }
52 break53 case UdpMethodExit:
54 neighbor := UnpackPeerInfo(p.Message)
55 if nil == neighbor {
50 return
51 }
52 go neighbor.UdpSendToPeer(packByte)
53 break 54 case UdpMethodReceive:
55 log.Println("UdpMethodReceive")
56 neighbor := UnpackPeerInfoList(p.Message)
161 length = len(that.Router.Neighbor)
162 }
163 }
164 return165}
166
167func (that *Peer) exit() {
Omit redundant control flow in your Go code.
Following cases should be considered to omit redundant control flow:
switch
statement in Go does not have automatic fallthrough, unlike languages like C. It is unnecessary to have a break statement as the final statement in a case block.func foo() {
fmt.Println("foo")
return
}
switch 1 {
case 1:
fmt.Println(“case one“)
break
case 2:
fmt.Println(“case two“)
}
func foo() {
fmt.Println("foo")
}
switch 1 {
case 1:
fmt.Println(“case one“)
case 2:
fmt.Println(“case two“)
}