Skip to content

Commit

Permalink
bnet.IP.String() should be called by value (#386)
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Wilhelm <[email protected]>
  • Loading branch information
Maximilian Wilhelm authored Sep 15, 2022
1 parent df4fc63 commit 32000ff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ func (ip *IP) Compare(other *IP) int8 {
}

// String returns string representation of an IP address
func (ip *IP) String() string {
func (ip IP) String() string {
if !ip.isLegacy {
return ip.stringIPv6()
}

return ip.stringIPv4()
}

func (ip *IP) stringIPv6() string {
func (ip IP) stringIPv6() string {
return fmt.Sprintf("%X:%X:%X:%X:%X:%X:%X:%X",
ip.higher&0xFFFF000000000000>>48,
ip.higher&0x0000FFFF00000000>>32,
Expand All @@ -194,7 +194,7 @@ func (ip *IP) stringIPv6() string {
ip.lower&0x000000000000FFFF)
}

func (ip *IP) stringIPv4() string {
func (ip IP) stringIPv4() string {
b := ip.Bytes()

return fmt.Sprintf("%d.%d.%d.%d", b[0], b[1], b[2], b[3])
Expand Down

0 comments on commit 32000ff

Please sign in to comment.