[Go] Go语言判断指定的文件是否存在 →→→→→进入此内容的聊天室

来自 , 2021-01-17, 写在 Go, 查看 122 次.
URL http://www.code666.cn/view/02b5b45c
  1. package main
  2.    
  3. import (
  4.     "fmt"
  5.     "os"
  6. )
  7.    
  8. func main() {
  9.     f, err := os.Open("dotcoo.com.txt")
  10.     if err != nil && os.IsNotExist(err) {
  11.         fmt.Printf("file not exist!\n")
  12.         return
  13.     }
  14.     fmt.Printf("file exist!\n")
  15.     defer f.Close()
  16. }
  17. //go/4367

回复 "Go语言判断指定的文件是否存在"

这儿你可以回复上面这条便签

captcha