Source File
pgservicefile.go
Belonging Package
github.com/jackc/pgservicefile
func ( *Servicefile) ( string) (*Service, error) {
, := .servicesByName[]
if ! {
return nil, errors.New("not found")
}
return , nil
}
func ( string) (*Servicefile, error) {
, := os.Open()
if != nil {
return nil,
}
defer .Close()
return ParseServicefile()
}
func ( io.Reader) (*Servicefile, error) {
:= &Servicefile{}
var *Service
:= bufio.NewScanner()
:= 0
for .Scan() {
+= 1
:= .Text()
= strings.TrimSpace()
} else if strings.HasPrefix(, "[") && strings.HasSuffix(, "]") {
= &Service{Name: [1 : len()-1], Settings: make(map[string]string)}
.Services = append(.Services, )
} else {
:= strings.SplitN(, "=", 2)
if len() != 2 {
return nil, fmt.Errorf("unable to parse line %d", )
}
:= strings.TrimSpace([0])
:= strings.TrimSpace([1])
.Settings[] =
}
}
.servicesByName = make(map[string]*Service, len(.Services))
for , := range .Services {
.servicesByName[.Name] =
}
return , .Err()
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |