Skip to content

Commit

Permalink
function literals = more compact/faster
Browse files Browse the repository at this point in the history
  • Loading branch information
imgurbot12 committed Jan 20, 2018
1 parent 307f34d commit db80d2e
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions pktdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ type PacketData struct {
}

//localIPs : a hashmap of local ip-addresses
var localIPs map[string]struct{}

/***Functions***/

//getLocalIPs : return list of local ip-addresses
func getLocalIPs() map[string]struct{} {
var localIPs = func() map[string]struct{} {
// create binary tree for lookup
ips := make(map[string]struct{})
// get ip-addresses from interfaces
Expand All @@ -35,12 +30,7 @@ func getLocalIPs() map[string]struct{} {
}
}
return ips
}

func init() {
// get all local ip addreses
localIPs = getLocalIPs()
}
}()

/***Methods***/

Expand Down

0 comments on commit db80d2e

Please sign in to comment.