Skip to content

Commit

Permalink
Cleanup lint errors, change function name to send magic packets
Browse files Browse the repository at this point in the history
  • Loading branch information
sabhiram committed Apr 16, 2018
1 parent 55f66b1 commit 192836b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
10 changes: 5 additions & 5 deletions magic_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

var (
delims = ":-"
re_MAC = regexp.MustCompile(`^([0-9a-fA-F]{2}[` + delims + `]){5}([0-9a-fA-F]{2})$`)
reMAC = regexp.MustCompile(`^([0-9a-fA-F]{2}[` + delims + `]){5}([0-9a-fA-F]{2})$`)
)

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -36,7 +36,7 @@ func New(mac string) (*MagicPacket, error) {

// We only support 6 byte MAC addresses since it is much harder to use the
// binary.Write(...) interface when the size of the MagicPacket is dynamic.
if !re_MAC.MatchString(mac) {
if !reMAC.MatchString(mac) {
return nil, fmt.Errorf("invalid mac-address %s", mac)
}

Expand Down Expand Up @@ -65,8 +65,8 @@ func New(mac string) (*MagicPacket, error) {

////////////////////////////////////////////////////////////////////////////////

// GetIpFromInterface returns a `*net.UDPAddr` from a network interface name.
func GetIpFromInterface(iface string) (*net.UDPAddr, error) {
// GetIPFromInterface returns a `*net.UDPAddr` from a network interface name.
func GetIPFromInterface(iface string) (*net.UDPAddr, error) {
ief, err := net.InterfaceByName(iface)
if err != nil {
return nil, err
Expand Down Expand Up @@ -120,7 +120,7 @@ func SendMagicPacket(macAddr, bcastAddr, iface string) error {
var localAddr *net.UDPAddr
if iface != "" {
var err error
localAddr, err = GetIpFromInterface(iface)
localAddr, err = GetIPFromInterface(iface)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions magic_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ func TestNewMagicPacketNegative(t *testing.T) {
}
}

func TestGetIpFromInterface(t *testing.T) {
func TestGetIPFromInterface(t *testing.T) {
interfaces, err := net.Interfaces()
assert.Nil(t, err)

// We can't actually enforce that we get a valid IP, but either the error
// or the pointer should be nil.
for _, i := range interfaces {
addr, err := GetIpFromInterface(i.Name)
addr, err := GetIPFromInterface(i.Name)
if err == nil {
assert.NotNil(t, addr)
} else {
Expand All @@ -63,7 +63,7 @@ func TestGetIpFromInterface(t *testing.T) {
}
}

func TestGetIpFromInterfaceNegative(t *testing.T) {
func TestGetIPFromInterfaceNegative(t *testing.T) {
// Test some fake interfaces.
var NegativeTestCases = []struct {
iface string
Expand All @@ -73,7 +73,7 @@ func TestGetIpFromInterfaceNegative(t *testing.T) {
}

for _, tc := range NegativeTestCases {
addr, err := GetIpFromInterface(tc.iface)
addr, err := GetIPFromInterface(tc.iface)
assert.Nil(t, addr)
assert.NotNil(t, err)
}
Expand Down
9 changes: 4 additions & 5 deletions version_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package wol

// WARNING: Auto generated version file. Do not edit this file by hand.
// WARNING: go get github.com/sabhiram/gover to manage this file.
// Version: 1.0.4

// Version: 1.1.0
const (
Major = 1
Minor = 0
Patch = 4
Minor = 1
Patch = 0

Version = "1.0.4"
Version = "1.1.0"
)

0 comments on commit 192836b

Please sign in to comment.