1
0
mirror of https://github.com/MADTeacher/go_basics.git synced 2025-11-23 21:34:47 +02:00
Files
go_basics/part_5/5.2/5.go

27 lines
445 B
Go
Raw Normal View History

package main
import (
"fmt"
"log"
"os"
"path/filepath"
)
const tempFileName = "myTempFile.dat"
func createdFile(path string) {
filepath := filepath.Join(path, tempFileName)
myFile, err := os.Create(filepath)
if err != nil {
log.Fatal(err)
}
defer myFile.Close()
fmt.Println("File created with path: ", filepath)
}
func main() {
path := filepath.Join("firstDir", "secondDir", "new")
os.MkdirAll(path, 0777)
createdFile(path)
}