Add strings
This commit is contained in:
parent
693eca244b
commit
ab676f25a6
6
main.go
6
main.go
@ -21,7 +21,8 @@ package main
|
||||
// import "git.sangeeth.dev/gobyexample/sorting"
|
||||
// import "git.sangeeth.dev/gobyexample/panic"
|
||||
// import "git.sangeeth.dev/gobyexample/defers"
|
||||
import "git.sangeeth.dev/gobyexample/recovering"
|
||||
// import "git.sangeeth.dev/gobyexample/recovering"
|
||||
import "git.sangeeth.dev/gobyexample/stringfuncs"
|
||||
|
||||
func main() {
|
||||
// runes.Runes()
|
||||
@ -45,5 +46,6 @@ func main() {
|
||||
// sorting.Sorting()
|
||||
// panic.Panic()
|
||||
// defers.Defers()
|
||||
recovering.Recover()
|
||||
// recovering.Recover()
|
||||
stringfuncs.StringFuncs()
|
||||
}
|
||||
|
24
stringfuncs/stringfuncs.go
Normal file
24
stringfuncs/stringfuncs.go
Normal file
@ -0,0 +1,24 @@
|
||||
package stringfuncs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var f = fmt.Println
|
||||
|
||||
func StringFuncs() {
|
||||
f("Trim", strings.Trim("***ohaiiooo*****", "*"))
|
||||
f("Split", strings.Split("a-b-c-d-e", "-"))
|
||||
f("SplitAfter", strings.SplitAfter("a-b-c-d-e", "-"))
|
||||
f("ToUpper", strings.ToUpper("abc"))
|
||||
f("ToLower", strings.ToLower("ABC"))
|
||||
f("Replace (all)", strings.Replace("foo", "o", "0", -1))
|
||||
f("Replace (few)", strings.Replace("foo", "o", "0", 1))
|
||||
f("Contains", strings.Contains("foobar", "bar"))
|
||||
f("Count", strings.Count("fuwafuwa", "w"))
|
||||
f("HasPrefix", strings.HasPrefix("foobar", "foo"))
|
||||
f("HasSuffix", strings.HasSuffix("foobar", "bar"))
|
||||
f("Join", strings.Join([]string{"hello", "_", "world"}, ""))
|
||||
f("Index", strings.Index("foobar", "bar"))
|
||||
}
|
Loading…
Reference in New Issue
Block a user