| 14 | var postgresHost string |
| 15 | |
| 16 | func StartPostgreSQLServer(c context.Context) (string, error) { |
| 17 | if err := Installed(); err != nil { |
| 18 | return "", err |
| 19 | } |
| 20 | if postgresHost != "" { |
| 21 | return postgresHost, nil |
| 22 | } |
| 23 | value, err, _ := flight.Do("postgresql", func() (interface{}, error) { |
| 24 | host, err := startPostgreSQLServer(c) |
| 25 | if err != nil { |
| 26 | return "", err |
| 27 | } |
| 28 | postgresHost = host |
| 29 | return host, err |
| 30 | }) |
| 31 | if err != nil { |
| 32 | return "", err |
| 33 | } |
| 34 | data, ok := value.(string) |
| 35 | if !ok { |
| 36 | return "", fmt.Errorf("returned value was not a string") |
| 37 | } |
| 38 | return data, nil |
| 39 | } |
| 40 | |
| 41 | func startPostgreSQLServer(c context.Context) (string, error) { |
| 42 | { |