yjp 3 kuukautta sitten
vanhempi
commit
5125889f23
1 muutettua tiedostoa jossa 9 lisäystä ja 13 poistoa
  1. 9 13
      template/template_func.go

+ 9 - 13
template/template_func.go

@@ -63,19 +63,15 @@ func UpperShort(s string) string {
 }
 
 func Id(s string) string {
-	if s == "ID" {
-		return "id"
-	}
-
-	if strings.Contains(s, "ID") {
+	if strings.HasSuffix(s, "ID") {
 		return strings.ReplaceAll(s, "ID", "Id")
 	}
 
-	if strings.Contains(s, "id") {
+	if strings.HasSuffix(s, "id") {
 		return strings.ReplaceAll(s, "id", "Id")
 	}
 
-	if strings.Contains(s, "iD") {
+	if strings.HasSuffix(s, "iD") {
 		return strings.ReplaceAll(s, "iD", "Id")
 	}
 
@@ -83,15 +79,15 @@ func Id(s string) string {
 }
 
 func ID(s string) string {
-	if strings.Contains(s, "Id") {
+	if strings.HasSuffix(s, "Id") {
 		return strings.ReplaceAll(s, "Id", "ID")
 	}
 
-	if strings.Contains(s, "id") {
+	if strings.HasSuffix(s, "id") {
 		return strings.ReplaceAll(s, "id", "ID")
 	}
 
-	if strings.Contains(s, "iD") {
+	if strings.HasSuffix(s, "iD") {
 		return strings.ReplaceAll(s, "iD", "ID")
 	}
 
@@ -99,15 +95,15 @@ func ID(s string) string {
 }
 
 func id(s string) string {
-	if strings.Contains(s, "Id") {
+	if strings.HasSuffix(s, "Id") {
 		return strings.ReplaceAll(s, "Id", "id")
 	}
 
-	if strings.Contains(s, "ID") {
+	if strings.HasSuffix(s, "ID") {
 		return strings.ReplaceAll(s, "ID", "id")
 	}
 
-	if strings.Contains(s, "iD") {
+	if strings.HasSuffix(s, "iD") {
 		return strings.ReplaceAll(s, "iD", "id")
 	}