This commit is contained in:
a.pivkin 2025-10-29 20:47:02 +03:00
parent 85b6d83f7b
commit 5c56f1ff0b
3 changed files with 39 additions and 13 deletions

View File

@ -1,27 +1,37 @@
package main
import (
// "fmt"
"fmt"
"strings"
)
func ToCamelCase(s string) string {
// your code
dash := "-"
// und := "_"
if strings.Contains(s,dash) {
fmt.Println("Contains dashes!")
index := strings.Index(s,dash)
fmt.Println(index)
fmt.Println(strings.ReplaceAll(s,string(s[index:index]),strings.ToUpper(string(s[index+1]))))
var fin string
fin = s
symbs := []string{"-","_"}
for _, ind := range symbs {
if strings.Contains(s,ind) {
index := strings.Index(s,ind)
initStr := s
substr := initStr[index:index+2]
toRepl := strings.ToUpper(string(initStr[index+1]))
fin = strings.Replace(s,substr,toRepl,1)
fin = ToCamelCase(fin)
} else {
continue
}
}
return ""
return fin
}
func main() {
ToCamelCase("the-stealth-warrior")
// ToCamelCase("The_Stealth_Warrior")
// ToCamelCase("The_Stealth-Warrior")
fmt.Println(ToCamelCase("the-stealth-warrior"))
fmt.Println(ToCamelCase("The_Stealth_Warrior"))
fmt.Println(ToCamelCase("The_Stealth-Warrior"))
}

3
headFirst/time/go.mod Normal file
View File

@ -0,0 +1,3 @@
module main.go
go 1.25.3

13
headFirst/time/main.go Normal file
View File

@ -0,0 +1,13 @@
package main
import (
"flag"
"fmt"
"time"
)
func main() {
timex := flag.Duration("t",4*time.Second,"kek")
flag.Parse()
fmt.Println(timex)
}