OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris | 5 // +build darwin dragonfly freebsd linux netbsd openbsd solaris |
6 | 6 |
7 // Read system port mappings from /etc/services | 7 // Read system port mappings from /etc/services |
8 | 8 |
9 package net | 9 package net |
10 | 10 |
11 import "sync" | 11 import "sync" |
12 | 12 |
13 // services contains minimal mappings between services names and port | 13 // services contains minimal mappings between services names and port |
14 // numbers for platforms that don't have a complete list of port numbers | 14 // numbers for platforms that don't have a complete list of port numbers |
15 // (some Solaris distros). | 15 // (some Solaris distros). |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 network = "udp" | 64 network = "udp" |
65 } | 65 } |
66 | 66 |
67 if m, ok := services[network]; ok { | 67 if m, ok := services[network]; ok { |
68 if port, ok = m[service]; ok { | 68 if port, ok = m[service]; ok { |
69 return | 69 return |
70 } | 70 } |
71 } | 71 } |
72 return 0, &AddrError{"unknown port", network + "/" + service} | 72 return 0, &AddrError{"unknown port", network + "/" + service} |
73 } | 73 } |
OLD | NEW |