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 package main
import ( import (
// "fmt"
"fmt" "fmt"
"strings" "strings"
) )
func ToCamelCase(s string) string { func ToCamelCase(s string) string {
// your code // your code
dash := "-" var fin string
// und := "_" fin = s
if strings.Contains(s,dash) { symbs := []string{"-","_"}
fmt.Println("Contains dashes!") for _, ind := range symbs {
index := strings.Index(s,dash) if strings.Contains(s,ind) {
fmt.Println(index)
fmt.Println(strings.ReplaceAll(s,string(s[index:index]),strings.ToUpper(string(s[index+1])))) 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() { func main() {
ToCamelCase("the-stealth-warrior") fmt.Println(ToCamelCase("the-stealth-warrior"))
// ToCamelCase("The_Stealth_Warrior") fmt.Println(ToCamelCase("The_Stealth_Warrior"))
// 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)
}