Skip to content

Commit

Permalink
Add a //go:build directive to support Go 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
jkralik committed Oct 18, 2023
1 parent 29d64d2 commit 032259b
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions udp/isRunninigInterface_1.18_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build go1.18 || go1.19

package udp_test

import "net"

func isRunningInterface(net.Interface) bool {
return true
}
9 changes: 9 additions & 0 deletions udp/isRunninigInterface_1.20_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !go1.18 && !go1.19

package udp_test

import "net"

func isRunningInterface(i net.Interface) bool {
return i.Flags&net.FlagRunning == net.FlagRunning
}
2 changes: 1 addition & 1 deletion udp/server_test.go
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ func TestServerDiscover(t *testing.T) {
log.Printf("ifs:%v", ifs)
var iface net.Interface
for _, i := range ifs {
if i.Flags&net.FlagMulticast == net.FlagMulticast && i.Flags&net.FlagUp == net.FlagUp && i.Flags&net.FlagRunning == net.FlagRunning {
if i.Flags&net.FlagMulticast == net.FlagMulticast && i.Flags&net.FlagUp == net.FlagUp && isRunningInterface(i) {
iface = i
log.Printf("first available multicast if:%v", iface)
break

0 comments on commit 032259b

Please sign in to comment.