Reputation: 4581
Looking at the net/interface.go code it seems like the only way to get interface flags is as strings. Is this true?
if strings.Contains(i.Flags.String(), "broadcast") {
Feels gross.
Upvotes: 5
Views: 1629
Reputation:
net.Interface.Flags
is a bitmask. To see if an interface has a certain flag, use the bitwise AND operator (&
). For example:
if i.Flags&net.FlagBroadcast != 0 {
// interface has broadcast
}
Upvotes: 6