Added filtered GET request

This commit is contained in:
Fran Jurmanović
2021-05-22 16:51:18 +02:00
parent f9ea943ed9
commit 8d4dc3ff57
6 changed files with 83 additions and 8 deletions

View File

@@ -2,6 +2,8 @@ package common
import (
"log"
"regexp"
"strings"
)
func CheckError(err error) {
@@ -9,3 +11,12 @@ func CheckError(err error) {
log.Fatalf("Error occured. %v", err)
}
}
var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
func ToSnakeCase(str string) string {
snake := matchFirstCap.ReplaceAllString(str, "${1}_${2}")
snake = matchAllCap.ReplaceAllString(snake, "${1}_${2}")
return strings.ToLower(snake)
}