2015-05-28 18:57:52 +02:00
|
|
|
package globals
|
|
|
|
|
|
2015-05-29 21:10:00 +02:00
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"strconv"
|
|
|
|
|
"os"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2015-05-28 18:57:52 +02:00
|
|
|
const (
|
2015-05-30 11:02:31 +02:00
|
|
|
ConfigurationDirectoryName = ".chub"
|
2015-05-28 18:57:52 +02:00
|
|
|
ConfigurationFilePermissions = 600
|
|
|
|
|
ConfigurationFileName = "config"
|
2015-05-29 21:10:00 +02:00
|
|
|
UrlOfTheService = "http://localhost:3000/api/"
|
|
|
|
|
MimeTypeOfService = "application/json"
|
2015-05-30 11:02:31 +02:00
|
|
|
WebSite = "http://confighub.saburly.com"
|
2015-05-28 18:57:52 +02:00
|
|
|
)
|
2015-05-29 21:10:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|