Beispiel #1
0
func ProcessError(w http.ResponseWriter, r *http.Request, e error) {
	if e != nil {
		parseJSON(w, r, map[string]interface{}{"Error:": e.Error()})
		log.Error(e)
		//fmt.Printf("STACK: %s", string(debug.Stack()))
	}
}
Beispiel #2
0
/*
Genarate New psedulo Guid id as unique identifier.
*/
func Guid() (uuid string, err error) {
	b := make([]byte, 16)
	_, err = rand.Read(b)
	if err != nil {
		log.Error(err, nil, "Error while GUID creation")
		return
	}
	uuid = fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
	return
}
Beispiel #3
0
func Test_Util(t *testing.T) {
	CIDR = "1.2.0.0/8"
	if er := ValidateIp("1.2.4.198"); er != nil {
		log.Error(er)
		t.Fail()
	} else {
		fmt.Printf("This Is valid.")
	}

}