Skip to content

Commit 558da94

Browse files
authored
Merge pull request #2355 from alexandear/dnshosts-improve-extract-zones
pkg/networks: refactor dnshosts.ExtractZones
2 parents 2d85cfd + 2803a3c commit 558da94

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pkg/networks/usernet/dnshosts/dnshosts.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"github.com/containers/gvisor-tap-vsock/pkg/types"
3333
)
3434

35-
func ExtractZones(hosts hostMap) (zones []types.Zone) {
35+
func ExtractZones(hosts hostMap) []types.Zone {
3636
list := make(map[string]types.Zone)
3737

3838
for host := range hosts {
@@ -57,10 +57,11 @@ func ExtractZones(hosts hostMap) (zones []types.Zone) {
5757
list[h.name()] = zone
5858
}
5959

60+
zones := make([]types.Zone, 0, len(list))
6061
for _, zone := range list {
6162
zones = append(zones, zone)
6263
}
63-
return
64+
return zones
6465
}
6566

6667
type hostMap map[string]string

pkg/networks/usernet/dnshosts/dnshosts_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func Test_zoneHost(t *testing.T) {
9494
}
9595
}
9696

97-
func Test_extractZones(t *testing.T) {
97+
func TestExtractZones(t *testing.T) {
9898
equalZones := func(za, zb []types.Zone) bool {
9999
find := func(list []types.Zone, name string) (types.Zone, bool) {
100100
for _, z := range list {

0 commit comments

Comments
 (0)