Skip to content

Commit

Permalink
Merge pull request #82 from drakkan/staticcheck
Browse files Browse the repository at this point in the history
fix staticcheck warning: don't use Yoda conditions (ST1017)
  • Loading branch information
pires committed Sep 8, 2021
2 parents 10d5fbd + b809180 commit a55009f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions addr_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@ const (

// IsIPv4 returns true if the address family is IPv4 (AF_INET4), false otherwise.
func (ap AddressFamilyAndProtocol) IsIPv4() bool {
return 0x10 == ap&0xF0
return ap&0xF0 == 0x10
}

// IsIPv6 returns true if the address family is IPv6 (AF_INET6), false otherwise.
func (ap AddressFamilyAndProtocol) IsIPv6() bool {
return 0x20 == ap&0xF0
return ap&0xF0 == 0x20
}

// IsUnix returns true if the address family is UNIX (AF_UNIX), false otherwise.
func (ap AddressFamilyAndProtocol) IsUnix() bool {
return 0x30 == ap&0xF0
return ap&0xF0 == 0x30
}

// IsStream returns true if the transport protocol is TCP or STREAM (SOCK_STREAM), false otherwise.
func (ap AddressFamilyAndProtocol) IsStream() bool {
return 0x01 == ap&0x0F
return ap&0x0F == 0x01
}

// IsDatagram returns true if the transport protocol is UDP or DGRAM (SOCK_DGRAM), false otherwise.
func (ap AddressFamilyAndProtocol) IsDatagram() bool {
return 0x02 == ap&0x0F
return ap&0x0F == 0x02
}

// IsUnspec returns true if the transport protocol or address family is unspecified, false otherwise.
func (ap AddressFamilyAndProtocol) IsUnspec() bool {
return (0x00 == ap&0xF0) || (0x00 == ap&0x0F)
return (ap&0xF0 == 0x00) || (ap&0x0F == 0x00)
}

func (ap AddressFamilyAndProtocol) toByte() byte {
Expand Down

0 comments on commit a55009f

Please sign in to comment.