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

Method set

internal/driver/config.go:225–259  ·  view source on GitHub ↗

set sets the value of field f in cfg to value.

(f configField, value string)

Source from the content-addressed store, hash-verified

223
224// set sets the value of field f in cfg to value.
225func (cfg *config) set(f configField, value string) error {
226 switch ptr := cfg.fieldPtr(f).(type) {
227 case *string:
228 if len(f.choices) > 0 {
229 // Verify that value is one of the allowed choices.
230 if slices.Contains(f.choices, value) {
231 *ptr = value
232 return nil
233 }
234 return fmt.Errorf("invalid %q value %q", f.name, value)
235 }
236 *ptr = value
237 case *int:
238 v, err := strconv.Atoi(value)
239 if err != nil {
240 return err
241 }
242 *ptr = v
243 case *float64:
244 v, err := strconv.ParseFloat(value, 64)
245 if err != nil {
246 return err
247 }
248 *ptr = v
249 case *bool:
250 v, err := stringToBool(value)
251 if err != nil {
252 return err
253 }
254 *ptr = v
255 default:
256 panic(fmt.Sprintf("unsupported config field type %v", f.field.Type))
257 }
258 return nil
259}
260
261// isConfigurable returns true if name is either the name of a config field, or
262// a valid value for a multi-choice config field.

Callers 15

applyURLMethod · 0.95
configureFunction · 0.45
stackViewerFunction · 0.45
setHrefParamFunction · 0.45
switchPivotsFunction · 0.45
partitionPlacesFunction · 0.45
addElemFunction · 0.45
commitSaveFunction · 0.45
commitDeleteFunction · 0.45
handleKeyFunction · 0.45
selectFunction · 0.45
setNodeHighlightFunction · 0.45

Calls 2

fieldPtrMethod · 0.95
stringToBoolFunction · 0.85

Tested by

no test coverage detected