package main
import (
"fmt"
"os"
)
func main() {
f := "D:\\cron"
fmt.Println(os.Stat(f))
fmt.Println(os.Open(f))
f = "D:\\con"
fmt.Println(os.Stat(f))
fmt.Println(os.Open(f))
}
result:
<nil> CreateFile D:\cron: The system cannot find the file specified.
<nil> open D:\cron: The system cannot find the file specified.
<nil> CreateFile D:\con: The parameter is incorrect.
&{0xc000086a00} <nil>
我认为当文件不存在时,os.Open 应该返回 err != nil
但我想知道为什么“D:\con”返回 err == nil
陪伴而非守候
相关分类