在php裡有個函式可以檢查檔案是否存在
那在Golang又該如何判斷呢?
在Golang裡可以使用os.Stat
並判斷error
if _, err := os.Stat("/path/to/your/file"); os.IsNotExist(err) {
// path/to/your/file does not exist
}
在php裡有個函式可以檢查檔案是否存在
那在Golang又該如何判斷呢?
在Golang裡可以使用os.Stat
並判斷error
if _, err := os.Stat("/path/to/your/file"); os.IsNotExist(err) {
// path/to/your/file does not exist
}