mirror of
https://github.com/MADTeacher/go_basics.git
synced 2025-11-23 21:34:47 +02:00
21 lines
372 B
Go
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)
|
|
}
|