当前位置: 移动技术网 > IT编程>脚本编程>Go语言 > Go语言判断指定文件是否存在的方法

Go语言判断指定文件是否存在的方法

2017年12月08日  | 移动技术网IT编程  | 我要评论

本文实例讲述了go语言判断指定文件是否存在的方法。分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:
package main
  
import (
    "fmt"
    "os"
)
  
func main() {
    f, err := os.open("dotcoo.com.txt")
    if err != nil && os.isnotexist(err) {
        fmt.printf("file not exist!\n")
        return
    }
    fmt.printf("file exist!\n")
    defer f.close()
}

希望本文所述对大家的go语言程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网