ma@ma:/data/code/go/src/file_exist$ tree . └── file_exist.go 0 directories, 1 file ma@ma:/data/code/go/src/file_exist$ go run file_exist.go # 运行程序 ./test/1 is exist! ./test/2 is not exist! ./test/1.txt is not exist! ma@ma:/data/code/go/src/file_exist$ tree . ├── file_exist.go └── test └── 1 └── 2 3 directories, 1 file ma@ma:/data/code/go/src/file_exist$ touch test/1.txt # 创建1.txt ma@ma:/data/code/go/src/file_exist$ go run file_exist.go ./test/1 is exist! ./test/2 is not exist! ./test/1.txt is exist! # 1.txt存在
ma@ma:/data/code/go/src/file_exist$ tree . └── file_exist.go 0 directories, 1 file ma@ma:/data/code/go/src/file_exist$ go run file_exist.go # 运行程序 ./test/1 is exist! ./test/2 is not exist! ./test/1.txt is not exist! ma@ma:/data/code/go/src/file_exist$ tree . ├── file_exist.go └── test └── 1 └── 2 3 directories, 1 file ma@ma:/data/code/go/src/file_exist$ touch test/1.txt # 创建1.txt ma@ma:/data/code/go/src/file_exist$ go run file_exist.go ./test/1 is exist! ./test/2 is not exist! ./test/1.txt is exist! # 1.txt存在