(opts Options)
| 21 | } |
| 22 | |
| 23 | func BuildStringFromOptions(opts Options) (string, error) { |
| 24 | query := url.Values{} |
| 25 | if opts.Ssl != "" { |
| 26 | query.Add("sslmode", opts.Ssl) |
| 27 | } |
| 28 | dbUrl := url.URL{ |
| 29 | Scheme: "postgres", |
| 30 | User: url.UserPassword(opts.User, opts.Pass), |
| 31 | Host: fmt.Sprintf("%s:%v", opts.Host, opts.Port), |
| 32 | Path: fmt.Sprintf("/%s", opts.DbName), |
| 33 | RawQuery: query.Encode(), |
| 34 | } |
| 35 | return dbUrl.String(), nil |
| 36 | } |
| 37 | |
| 38 | func EncodeParam(s string) string { |
| 39 | return url.QueryEscape(s) |