aboutsummaryrefslogtreecommitdiff
path: root/src/net/interface_test.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2025-01-09 13:04:51 -0800
committerGopher Robot <gobot@golang.org>2025-02-03 12:11:12 -0800
commit4160ebf28f69a738203571bba6abab6ec0913080 (patch)
tree022009902a0d81a3011803886aaff60d3deb5f3a /src/net/interface_test.go
parentdcebb675b3fa0fd8d3056323a9f7f857ce4a2105 (diff)
downloadgo-4160ebf28f69a738203571bba6abab6ec0913080.tar.xz
net: permit Interface with no Name
On darwin the utun interface sometimes has no name. Fixes #71064 Change-Id: Iec51641880515f8bd3f97bd892c26f68fd588fa3 Reviewed-on: https://go-review.googlesource.com/c/go/+/641855 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/net/interface_test.go')
-rw-r--r--src/net/interface_test.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/net/interface_test.go b/src/net/interface_test.go
index a97d675e7e..72befca0d8 100644
--- a/src/net/interface_test.go
+++ b/src/net/interface_test.go
@@ -68,12 +68,14 @@ func TestInterfaces(t *testing.T) {
t.Errorf("got %v; want %v", ifxi, ifi)
}
}
- ifxn, err := InterfaceByName(ifi.Name)
- if err != nil {
- t.Fatal(err)
- }
- if !reflect.DeepEqual(ifxn, &ifi) {
- t.Errorf("got %v; want %v", ifxn, ifi)
+ if ifi.Name != "" {
+ ifxn, err := InterfaceByName(ifi.Name)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !reflect.DeepEqual(ifxn, &ifi) {
+ t.Errorf("got %v; want %v", ifxn, ifi)
+ }
}
t.Logf("%s: flags=%v index=%d mtu=%d hwaddr=%v", ifi.Name, ifi.Flags, ifi.Index, ifi.MTU, ifi.HardwareAddr)
}