Go语言判断指定文件是否存在的方法
作者:不吃皮蛋 时间:2024-05-21 10:21:38
本文实例讲述了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语言程序设计有所帮助。
标签:Go语言,判断,文件
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
通过实例解析js简易模块加载器
2024-04-16 08:55:57
![](https://img.aspxhome.com/file/2023/6/136736_0s.png)
Tensorflow tf.nn.depthwise_conv2d如何实现深度卷积的
2021-10-23 19:00:50
MySQL慢sql优化思路详细讲解
2024-01-18 03:51:43
![](https://img.aspxhome.com/file/2023/5/66145_0s.png)
Python及Django框架生成二维码的方法分析
2023-10-11 22:25:48
AES加密算法的原理详解与实现分析
2022-11-18 14:39:43
![](https://img.aspxhome.com/file/2023/5/132495_0s.png)
python 通过logging写入日志到文件和控制台的实例
2021-04-26 00:04:38
python3实现暴力穷举博客园密码
2022-10-24 22:38:21
Python轻量级ORM框架Peewee访问sqlite数据库的方法详解
2024-01-23 06:47:45
Python catplot函数自定义颜色的方法
2021-01-29 16:25:01
![](https://img.aspxhome.com/file/2023/1/95491_0s.png)
numpy np.newaxis 的实用分享
2023-01-21 06:06:25
OpenCV 读取图像imread的使用详解
2022-02-07 02:00:22
![](https://img.aspxhome.com/file/2023/0/135380_0s.png)
Python实现语音合成功能详解
2023-11-28 16:09:17
![](https://img.aspxhome.com/file/2023/9/87999_0s.jpg)
Python下载网络文本数据到本地内存的四种实现方法示例
2022-10-09 15:48:25
Python中list列表的一些进阶使用方法介绍
2023-12-24 10:31:47
Python检测数据类型的方法总结
2022-08-29 22:07:58
![](https://img.aspxhome.com/file/2023/1/65461_0s.png)
Python sklearn中的.fit与.predict的用法说明
2023-01-03 23:54:25
![](https://img.aspxhome.com/file/2023/7/92267_0s.jpg)
python中的Pytorch建模流程汇总
2022-04-26 19:02:14
JS基于面向对象实现的选项卡效果示例
2024-04-19 10:42:56
IDEA使用properties配置文件进行mysql数据库连接的教程图解
2024-01-22 13:45:08
![](https://img.aspxhome.com/file/2023/5/118205_0s.png)
C#中使用SQLite数据库的方法介绍
2024-01-26 00:31:49