MCPcopy Create free account
hub / github.com/google/pprof / makeURL

Method makeURL

internal/driver/config.go:344–372  ·  view source on GitHub ↗

makeURL returns a URL based on initialURL that contains the config contents as parameters. The second result is true iff a parameter value was changed.

(initialURL url.URL)

Source from the content-addressed store, hash-verified

342// makeURL returns a URL based on initialURL that contains the config contents
343// as parameters. The second result is true iff a parameter value was changed.
344func (cfg *config) makeURL(initialURL url.URL) (url.URL, bool) {
345 q := initialURL.Query()
346 changed := false
347 for _, f := range configFields {
348 if f.urlparam == "" || !f.saved {
349 continue
350 }
351 v := cfg.get(f)
352 if v == f.defaultValue {
353 v = "" // URL for of default value is the empty string.
354 } else if f.field.Type.Kind() == reflect.Bool {
355 // Shorten bool values to "f" or "t"
356 v = v[:1]
357 }
358 if q.Get(f.urlparam) == v {
359 continue
360 }
361 changed = true
362 if v == "" {
363 q.Del(f.urlparam)
364 } else {
365 q.Set(f.urlparam, v)
366 }
367 }
368 if changed {
369 initialURL.RawQuery = q.Encode()
370 }
371 return initialURL, changed
372}

Callers 4

TestParseConfigFunction · 0.95
TestDefaultConfigFunction · 0.80
openBrowserFunction · 0.80
configMenuFunction · 0.80

Calls 1

getMethod · 0.95

Tested by 2

TestParseConfigFunction · 0.76
TestDefaultConfigFunction · 0.64