Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix function comments based on best practices from Effective Go #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions daemon/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func CheckRouteOverlaps(toCheck *net.IPNet) error {
return nil
}

// Detects overlap between one IPNet and another
// NetworkOverlaps: Detects overlap between one IPNet and another
func NetworkOverlaps(netX *net.IPNet, netY *net.IPNet) bool {
if firstIP, _ := NetworkRange(netX); netY.Contains(firstIP) {
return true
Expand All @@ -42,7 +42,7 @@ func NetworkOverlaps(netX *net.IPNet, netY *net.IPNet) bool {
return false
}

// Calculates the first and last IP addresses in an IPNet
// NetworkRange: Calculates the first and last IP addresses in an IPNet
func NetworkRange(network *net.IPNet) (net.IP, net.IP) {
var (
netIP = network.IP.To4()
Expand All @@ -56,7 +56,7 @@ func NetworkRange(network *net.IPNet) (net.IP, net.IP) {
return firstIP, lastIP
}

// Given a netmask, calculates the number of available hosts
// NetworkSize: Given a netmask, calculates the number of available hosts
func NetworkSize(mask net.IPMask) int32 {
m := net.IPv4Mask(0, 0, 0, 0)
for i := 0; i < net.IPv4len; i++ {
Expand All @@ -65,7 +65,7 @@ func NetworkSize(mask net.IPMask) int32 {
return int32(binary.BigEndian.Uint32(m)) + 1
}

// Return the IPv4 address of a network interface
// GetIfaceAddr returns the IPv4 address of a network interface
func GetIfaceAddr(name string) (*net.IPNet, error) {
iface, err := netlink.LinkByName(name)
if err != nil {
Expand Down