package net
import (
)
var onceReadServices sync.Once
func () {
, := open("/etc/services")
if != nil {
return
}
defer .close()
for , := .readLine(); ; , = .readLine() {
if := bytealg.IndexByteString(, '#'); >= 0 {
= [:]
}
:= getFields()
if len() < 2 {
continue
}
:= [1]
, , := dtoi()
if ! || <= 0 || >= len() || [] != '/' {
continue
}
:= [+1:]
, := services[]
if ! {
= make(map[string]int)
services[] =
}
for := 0; < len(); ++ {
if != 1 {
[[]] =
}
}
}
}
func (, string) ( int, error) {
onceReadServices.Do(readServices)
return lookupPortMap(, )
}