From 6b9cdaffcd3bf84f050de835d6a86bebdbdf4c5b Mon Sep 17 00:00:00 2001
From: Daniel Czerwonk <daniel@dan-nrw.de>
Date: Thu, 28 Jun 2018 20:17:15 +0200
Subject: [PATCH] removed ToUint32

---
 net/ip.go      |  7 +------
 net/ip_test.go | 28 ----------------------------
 2 files changed, 1 insertion(+), 34 deletions(-)

diff --git a/net/ip.go b/net/ip.go
index 46b7350d..a277a192 100644
--- a/net/ip.go
+++ b/net/ip.go
@@ -41,11 +41,6 @@ func IPv6FromBlocks(b1, b2, b3, b4, b5, b6, b7, b8 uint16) IP {
 		uint64(uint64(b5)<<48+uint64(b6)<<32+uint64(b7)<<16+uint64(b8)))
 }
 
-// ToUint32 returns the uint32 representation of an IP address
-func (ip *IP) ToUint32() uint32 {
-	return uint32(^uint64(0) >> 32 & ip.lower)
-}
-
 // Equal returns true if ip is equal to other
 func (ip IP) Equal(other IP) bool {
 	return ip == other
@@ -110,7 +105,7 @@ func (ip IP) Bytes() []byte {
 }
 
 func (ip IP) bytesIPv4() []byte {
-	u := ip.ToUint32()
+	u := uint32(^uint64(0) >> 32 & ip.lower)
 	return []byte{
 		byte(u & 0xFF000000 >> 24),
 		byte(u & 0x00FF0000 >> 16),
diff --git a/net/ip_test.go b/net/ip_test.go
index a1001932..7283cfa8 100644
--- a/net/ip_test.go
+++ b/net/ip_test.go
@@ -8,34 +8,6 @@ import (
 	"github.com/stretchr/testify/assert"
 )
 
-func TestToUint32(t *testing.T) {
-	tests := []struct {
-		name     string
-		val      uint64
-		expected uint32
-	}{
-		{
-			name:     "IP: 172.24.5.1",
-			val:      2887255297,
-			expected: 2887255297,
-		},
-		{
-			name:     "bigger than IPv4 address",
-			val:      2887255295 + 17179869184,
-			expected: 2887255295,
-		},
-	}
-
-	for _, test := range tests {
-		t.Run(test.name, func(t *testing.T) {
-			ip := IP{
-				lower: test.val,
-			}
-			assert.Equal(t, test.expected, ip.ToUint32())
-		})
-	}
-}
-
 func TestCompare(t *testing.T) {
 	tests := []struct {
 		name     string
-- 
GitLab