39 lines
796 B
Go
39 lines
796 B
Go
package globals
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"os"
|
|
)
|
|
|
|
|
|
const (
|
|
ConfigurationFolderName = ".chub"
|
|
ConfigurationFilePermissions = 600
|
|
ConfigurationFileName = "config"
|
|
UrlOfTheService = "http://localhost:3000/api/"
|
|
MimeTypeOfService = "application/json"
|
|
)
|
|
|
|
|
|
func PanicWithStyle(message string, err error) {
|
|
if err != nil {
|
|
panic(fmt.Sprintf("%v:\n%v", message, err))
|
|
}
|
|
}
|
|
|
|
func RuneToAscii(r rune) string {
|
|
if r < 128 {
|
|
return string(r)
|
|
} else {
|
|
return "\\u" + strconv.FormatInt(int64(r), 16)
|
|
}
|
|
}
|
|
|
|
func FileExists(path string) (bool) {
|
|
_, err := os.Stat(path)
|
|
if err == nil { return true }
|
|
if os.IsNotExist(err) { return false }
|
|
PanicWithStyle("This should not be happening. Call 911 !" , err)
|
|
return false
|
|
} |