Add Util.go
This commit is contained in:
parent
983ad95620
commit
4759731fb7
27
util.go
Normal file
27
util.go
Normal file
@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CheckErr(err error) bool {
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
fmt.Println("error: ", err.Error())
|
||||
panic(err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func FileExist(Path string) bool {
|
||||
if _, err := os.Stat(Path); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
} else {
|
||||
CheckErr(err)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user