mirror of
https://github.com/foomo/gofoomo.git
synced 2025-10-16 12:25:44 +00:00
33 lines
479 B
Go
33 lines
479 B
Go
package utils
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"path"
|
|
"runtime"
|
|
)
|
|
|
|
// IsDir tells you is it a dir or not
|
|
func IsDir(filename string) (isDir bool, err error) {
|
|
i, err := os.Stat(filename)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
if !i.IsDir() {
|
|
return false, errors.New("not a dir")
|
|
}
|
|
return true, nil
|
|
}
|
|
|
|
// __DIR__
|
|
func GetCurrentDir() string {
|
|
_, filename, _, _ := runtime.Caller(1)
|
|
return path.Dir(filename)
|
|
}
|
|
|
|
func PanicOnErr(err error) {
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|