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

Method createMemberIfMissing

internal/devconfig/configfile/ast.go:430–442  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

428}
429
430func (c *configAST) createMemberIfMissing(key string) *hujson.ObjectMember {
431 i := c.memberIndex(c.root.Value.(*hujson.Object), key)
432 if i == -1 {
433 c.root.Value.(*hujson.Object).Members = append(c.root.Value.(*hujson.Object).Members, hujson.ObjectMember{
434 Name: hujson.Value{
435 Value: hujson.String(key),
436 BeforeExtra: []byte{'\n'},
437 },
438 })
439 i = len(c.root.Value.(*hujson.Object).Members) - 1
440 }
441 return &c.root.Value.(*hujson.Object).Members[i]
442}
443
444func mapToObjectMembers(env map[string]string) []hujson.ObjectMember {
445 members := make([]hujson.ObjectMember, 0, len(env))

Callers 1

setEnvMethod · 0.95

Calls 2

memberIndexMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected