String explained
This commit is contained in:
parent
0418380fd2
commit
d1fbf4865b
2 changed files with 28 additions and 0 deletions
2
main.go
2
main.go
|
@ -50,6 +50,7 @@ import (
|
||||||
"golesson/maps"
|
"golesson/maps"
|
||||||
"golesson/pointers"
|
"golesson/pointers"
|
||||||
"golesson/slices"
|
"golesson/slices"
|
||||||
|
"golesson/string_functions"
|
||||||
"golesson/structs"
|
"golesson/structs"
|
||||||
"golesson/variables"
|
"golesson/variables"
|
||||||
"time"
|
"time"
|
||||||
|
@ -125,4 +126,5 @@ func main() {
|
||||||
interfaces.Demo3()
|
interfaces.Demo3()
|
||||||
error_handling.Demo2()
|
error_handling.Demo2()
|
||||||
fmt.Println(error_handling.GuessIt2(102))
|
fmt.Println(error_handling.GuessIt2(102))
|
||||||
|
string_functions.Demo1()
|
||||||
}
|
}
|
||||||
|
|
26
string_functions/demo1.go
Normal file
26
string_functions/demo1.go
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package string_functions
|
||||||
|
|
||||||
|
//alias
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
s "strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// case sensitive
|
||||||
|
// ascii
|
||||||
|
func Demo1() {
|
||||||
|
name := "Engin"
|
||||||
|
fmt.Println(s.Count(name, "g"))
|
||||||
|
fmt.Println(s.Contains(name, "g"))
|
||||||
|
fmt.Println(s.Index(name, "g"))
|
||||||
|
result := s.Index(name, "E")
|
||||||
|
|
||||||
|
if result != -1{
|
||||||
|
fmt.Println("E letter exists")
|
||||||
|
}else{
|
||||||
|
fmt.Println("E letter does not exist")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(s.ToLower(name))
|
||||||
|
fmt.Println(s.ToUpper(name))
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue