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

Function configMenu

internal/driver/settings.go:81–110  ·  view source on GitHub ↗

configMenu returns a list of items to add to a menu in the web UI.

(fname string, u url.URL)

Source from the content-addressed store, hash-verified

79
80// configMenu returns a list of items to add to a menu in the web UI.
81func configMenu(fname string, u url.URL) []configMenuEntry {
82 // Start with system configs.
83 configs := []namedConfig{{Name: "Default", config: defaultConfig()}}
84 if settings, err := readSettings(fname); err == nil {
85 // Add user configs.
86 configs = append(configs, settings.Configs...)
87 }
88
89 // Convert to menu entries.
90 result := make([]configMenuEntry, len(configs))
91 lastMatch := -1
92 for i, cfg := range configs {
93 dst, changed := cfg.makeURL(u)
94 if !changed {
95 lastMatch = i
96 }
97 // Use a relative URL to work in presence of stripping/redirects in webui.go.
98 rel := &url.URL{RawQuery: dst.RawQuery, ForceQuery: true}
99 result[i] = configMenuEntry{
100 Name: cfg.Name,
101 URL: rel.String(),
102 UserConfig: (i != 0),
103 }
104 }
105 // Mark the last matching config as current
106 if lastMatch >= 0 {
107 result[lastMatch].Current = true
108 }
109 return result
110}
111
112// editSettings edits settings by applying fn to them.
113func editSettings(fname string, fn func(s *settings) error) error {

Callers 2

TestConfigMenuFunction · 0.85
renderMethod · 0.85

Calls 4

defaultConfigFunction · 0.85
readSettingsFunction · 0.85
makeURLMethod · 0.80
StringMethod · 0.65

Tested by 1

TestConfigMenuFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…