diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
commit | 64d2a7c8945ba05af859901f5e248f1befdd8621 (patch) | |
tree | 013fcb7e9e3296ecdda876012252c36bd6bcb063 /src/pkg/net/lookup_unix.go | |
parent | b901efe83e212f0c34c769c079e41373da12d723 (diff) | |
download | golang-64d2a7c8945ba05af859901f5e248f1befdd8621.tar.gz |
Imported Upstream version 1.2upstream/1.2
Diffstat (limited to 'src/pkg/net/lookup_unix.go')
-rw-r--r-- | src/pkg/net/lookup_unix.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/pkg/net/lookup_unix.go b/src/pkg/net/lookup_unix.go index fa98eed5f..59e9f6321 100644 --- a/src/pkg/net/lookup_unix.go +++ b/src/pkg/net/lookup_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin freebsd linux netbsd openbsd +// +build darwin dragonfly freebsd linux netbsd openbsd package net @@ -11,15 +11,11 @@ import ( "sync" ) -var ( - protocols map[string]int - onceReadProtocols sync.Once -) +var onceReadProtocols sync.Once // readProtocols loads contents of /etc/protocols into protocols map // for quick access. func readProtocols() { - protocols = make(map[string]int) if file, err := open("/etc/protocols"); err == nil { for line, ok := file.readLine(); ok; line, ok = file.readLine() { // tcp 6 TCP # transmission control protocol @@ -31,9 +27,13 @@ func readProtocols() { continue } if proto, _, ok := dtoi(f[1], 0); ok { - protocols[f[0]] = proto + if _, ok := protocols[f[0]]; !ok { + protocols[f[0]] = proto + } for _, alias := range f[2:] { - protocols[alias] = proto + if _, ok := protocols[alias]; !ok { + protocols[alias] = proto + } } } } |