Add function transformation data on JSON

This commit is contained in:
Archie Fox
2025-03-06 23:58:58 +03:00
parent b5941ea148
commit 26e125577d
7 changed files with 94 additions and 25 deletions

30
go-demo-4/files/files.go Normal file
View File

@@ -0,0 +1,30 @@
package files
import (
"fmt"
"os"
)
func FileWrite(content []byte, name string) {
file, err := os.Create(name)
if err != nil {
fmt.Println(err)
}
defer file.Close()
_, err = file.Write(content)
if err != nil {
file.Close()
fmt.Println(err)
return
}
fmt.Println("Файл успешно записан")
}
func FileRead() {
data, err := os.ReadFile("test.txt")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(data))
}