MCPcopy
hub / github.com/betty200744/ultimate-go / BuildStringFromOptions

Function BuildStringFromOptions

build-in-package/net/url/url.go:23–36  ·  view source on GitHub ↗
(opts Options)

Source from the content-addressed store, hash-verified

21}
22
23func 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
38func EncodeParam(s string) string {
39 return url.QueryEscape(s)

Callers 1

Calls 3

AddMethod · 0.65
EncodeMethod · 0.65
StringMethod · 0.45

Tested by 1