MCPcopy Create free account
hub / github.com/cblgh/plain / createIfNotExist

Function createIfNotExist

main.go:1179–1195  ·  view source on GitHub ↗
(name, content string)

Source from the content-addressed store, hash-verified

1177var EXAMPLE_CONTACTS string
1178
1179func createIfNotExist(name, content string) (bool, error) {
1180 _, err := os.Stat(name)
1181 if err != nil {
1182 // if the file doesn't exist, create it
1183 if errors.Is(err, fs.ErrNotExist) {
1184 err = os.WriteFile(name, []byte(content), 0777)
1185 if err != nil {
1186 return false, err
1187 }
1188 // created file successfully
1189 return true, nil
1190 } else {
1191 return false, err
1192 }
1193 }
1194 return false, nil
1195}
1196
1197func copyFile(src, dst string) {
1198 reader, err := os.Open(src)

Callers 2

readTemplateFunction · 0.85
populateFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected