MCPcopy Index your code
hub / github.com/jetify-com/devbox / setStringField

Method setStringField

internal/devconfig/configfile/field.go:41–56  ·  view source on GitHub ↗
(key, val string)

Source from the content-addressed store, hash-verified

39}
40
41func (c *configAST) setStringField(key, val string) {
42 rootObject := c.root.Value.(*hujson.Object)
43 i := c.memberIndex(rootObject, key)
44 if i == -1 {
45 rootObject.Members = append(rootObject.Members, hujson.ObjectMember{
46 Name: hujson.Value{Value: hujson.String(key)},
47 Value: hujson.Value{Value: hujson.String(val)},
48 })
49 } else if val != "" {
50 rootObject.Members[i].Value = hujson.Value{Value: hujson.String(val)}
51 } else {
52 rootObject.Members = append(rootObject.Members[:i], rootObject.Members[i+1:]...)
53 }
54
55 c.root.Format()
56}

Callers 1

SetStringFieldMethod · 0.80

Calls 3

memberIndexMethod · 0.95
StringMethod · 0.45
FormatMethod · 0.45

Tested by

no test coverage detected