package util import ( "fmt" "net/http" ) // WriteResponse writes msg to response func WriteResponse(w http.ResponseWriter, statusCode int, statusText string, msg string) { w.WriteHeader(statusCode) fmt.Fprintf(w, `{"status":"%s","message":"%s"}`, statusText, msg) } func Contains(s []string, v string) bool { for _, a := range s { if a == v { return true } } return false } // ToStrings return slice of string func ToStrings(data interface{}) []string { var values []string if vv, ok := data.([]interface{}); ok { for _, in := range vv { values = append(values, fmt.Sprint(in)) } } return values } // ToString return string func ToString(data interface{}) string { return fmt.Sprint(data) }