MCPcopy Create free account
hub / github.com/Pluralith/pluralith-cli / InitComFile

Function InitComFile

app/pkg/comdb/InitComFile.go:11–34  ·  view source on GitHub ↗
(file string, object interface{})

Source from the content-addressed store, hash-verified

9)
10
11func InitComFile(file string, object interface{}) error {
12 functionName := "InitComFile"
13
14 if strings.Contains(file, "ComDB") {
15 object = ComDB{
16 Events: make([]ComDBEvent, 0),
17 }
18 } else {
19 object = dblock.LockInstance
20 }
21
22 // Turn emtpy DB template into string
23 objectString, marshalErr := json.MarshalIndent(object, "", " ")
24 if marshalErr != nil {
25 return fmt.Errorf("could not format json string -> %v: %w", functionName, marshalErr)
26 }
27
28 // Write to DB template to bus file
29 if writeErr := os.WriteFile(file, objectString, 0700); writeErr != nil {
30 return fmt.Errorf("%v: %w", functionName, writeErr)
31 }
32
33 return nil
34}

Callers 1

ReadComFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected