MCPcopy Create free account
hub / github.com/google/go-cloud / instanceFromURL

Function instanceFromURL

postgres/gcppostgres/gcppostgres.go:136–146  ·  view source on GitHub ↗
(u *url.URL)

Source from the content-addressed store, hash-verified

134}
135
136func instanceFromURL(u *url.URL) (instance, db string, _ error) {
137 path := u.Host + u.Path // everything after scheme but before query or fragment
138 parts := strings.SplitN(path, "/", 4)
139 if len(parts) < 4 {
140 return "", "", fmt.Errorf("%s is not in the form project/region/instance/dbname", path)
141 }
142 if slices.Contains(parts, "") {
143 return "", "", fmt.Errorf("%s is not in the form project/region/instance/dbname", path)
144 }
145 return parts[0] + ":" + parts[1] + ":" + parts[2], parts[3], nil
146}
147
148type pqDriver struct {
149 client *proxy.Client

Callers 2

OpenPostgresURLMethod · 0.70
TestInstanceFromURLFunction · 0.70

Calls

no outgoing calls

Tested by 1

TestInstanceFromURLFunction · 0.56