gitee.com/hongliu9527/go-tools@v0.0.8/file/file.go (about)

     1  /*
     2   * @Author: hongliu
     3   * @Date: 2023-01-09 17:30:48
     4   * @LastEditors: hongliu
     5   * @LastEditTime: 2023-01-09 17:35:07
     6   * @FilePath: \go-tools\file\file.go
     7   * @Description: 文件相关工具函数
     8   *
     9   * Copyright (c) 2023 by 洪流, All Rights Reserved.
    10   */
    11  
    12  package file
    13  
    14  import "os"
    15  
    16  // Exists 判断文件/文件夹是否存在
    17  func Exists(path string) bool {
    18  	_, err := os.Stat(path) // os.Stat获取文件信息
    19  	if err != nil {
    20  		return os.IsExist(err)
    21  	}
    22  
    23  	return true
    24  }