new task
This commit is contained in:
parent
85b6d83f7b
commit
5c56f1ff0b
|
|
@ -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
3
headFirst/time/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
module main.go
|
||||||
|
|
||||||
|
go 1.25.3
|
||||||
13
headFirst/time/main.go
Normal file
13
headFirst/time/main.go
Normal 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)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user