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.1/5.go
2025-06-14 12:40:10 +03:00

21 lines
372 B
Go

package main
import (
"fmt"
"log"
"os"
)
func main() {
pathToFile := "pirates.txt"
fileInfo, err := os.Stat(pathToFile)
if err != nil {
if os.IsNotExist(err) {
log.Fatal("File does not exist.")
os.Exit(1) // выход из приложения со статусом 1
}
}
fmt.Println("File does exist!")
fmt.Println("File information:", fileInfo)
}