From 192836b4646498dcfb987bae7686f8ad3475ad1f Mon Sep 17 00:00:00 2001 From: Shaba Abhiram Date: Sun, 15 Apr 2018 22:46:50 -0700 Subject: [PATCH] Cleanup lint errors, change function name to send magic packets --- magic_packet.go | 10 +++++----- magic_packet_test.go | 8 ++++---- version_gen.go | 9 ++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/magic_packet.go b/magic_packet.go index e308aeb..b57b733 100644 --- a/magic_packet.go +++ b/magic_packet.go @@ -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})$`) ) //////////////////////////////////////////////////////////////////////////////// @@ -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) } @@ -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 @@ -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 } diff --git a/magic_packet_test.go b/magic_packet_test.go index c7d87ff..a58b247 100644 --- a/magic_packet_test.go +++ b/magic_packet_test.go @@ -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 { @@ -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 @@ -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) } diff --git a/version_gen.go b/version_gen.go index ec043e8..b0e99e5 100644 --- a/version_gen.go +++ b/version_gen.go @@ -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" )