MCPcopy Create free account
hub / github.com/apache/answer / WriteFile

Function WriteFile

pkg/writer/writer.go:34–50  ·  view source on GitHub ↗

WriteFile write file to path

(filePath, content string)

Source from the content-addressed store, hash-verified

32
33// WriteFile write file to path
34func WriteFile(filePath, content string) error {
35 file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 0o666)
36 if err != nil {
37 return err
38 }
39 defer func() {
40 _ = file.Close()
41 }()
42 writer := bufio.NewWriter(file)
43 if _, err := writer.WriteString(content); err != nil {
44 return err
45 }
46 if err := writer.Flush(); err != nil {
47 return err
48 }
49 return nil
50}
51
52// MoveFile move file to new path
53func MoveFile(oldPath, newPath string) error {

Callers 5

InstallConfigFileFunction · 0.92
InstallI18nBundleFunction · 0.92
createMainGoFileFunction · 0.92
ReplaceI18nFilesLocalFunction · 0.92
ReplaceFileFunction · 0.85

Calls 2

FlushMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected