Преглед на файлове

Add mechanism for extensions to set variable defaults

This enables pprof extensions to update the default for a variable
before the command line is processed.
Raul Silvera преди 9 години
родител
ревизия
d3ab00933a
променени са 1 файла, в които са добавени 8 реда и са изтрити 0 реда
  1. 8
    0
      internal/driver/commands.go

+ 8
- 0
internal/driver/commands.go Целия файл

@@ -68,6 +68,14 @@ func AddCommand(cmd string, format int, post PostProcessor, desc, usage string)
68 68
 	pprofCommands[cmd] = &command{format, post, false, desc, usage}
69 69
 }
70 70
 
71
+// SetDefault sets the default value for a pprof variable. This enables
72
+// extensions to set their own default values for variables.
73
+func SetVariableDefault(variable, value string) {
74
+	if v := pprofVariables[variable]; v != nil {
75
+		v.value = value
76
+	}
77
+}
78
+
71 79
 // PostProcessor is a function that applies post-processing to the report output
72 80
 type PostProcessor func(input []byte, output io.Writer, ui plugin.UI) error
73 81