Section12 - 94
This commit is contained in:
32
Section12/90.go
Normal file
32
Section12/90.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
s1 := "Hi there Go!"
|
||||
fmt.Println(s1)
|
||||
|
||||
fmt.Println("He sais: \"Hello!\"")
|
||||
fmt.Println(`He sais: "Hello again!"`)
|
||||
|
||||
s2 := `I like \n Go!` //raw string
|
||||
fmt.Println(s2)
|
||||
|
||||
fmt.Println("Price: 100\nBrand: Nike")
|
||||
fmt.Println(`
|
||||
Price: 100
|
||||
Brand: Nike
|
||||
`)
|
||||
fmt.Println(`C:\Users\Sebastian`)
|
||||
fmt.Println("C:\\Users\\Sebastian")
|
||||
|
||||
var s3 = "I love " + "Go " + "Programming"
|
||||
fmt.Println(s3 + "!")
|
||||
|
||||
fmt.Println("Element at index 0:", s3[0])
|
||||
|
||||
// s3[5] = 'x'
|
||||
fmt.Printf("%s\n", s3)
|
||||
fmt.Printf("%q\n", s3)
|
||||
|
||||
}
|
||||
29
Section12/93.go
Normal file
29
Section12/93.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var1, var2 := 'a', 'b'
|
||||
|
||||
fmt.Printf("Type: %T, Value: %d\n", var1, var2)
|
||||
|
||||
str := "țară"
|
||||
fmt.Println(len(str))
|
||||
|
||||
fmt.Println("Byte (non rune) at position 1:", str[1])
|
||||
|
||||
for i := 0; i < len(str); i++ {
|
||||
fmt.Printf("%c", str[i])
|
||||
}
|
||||
fmt.Println("\n" + strings.Repeat("#", 20))
|
||||
for i := 0; i < len(str); {
|
||||
r, size := utf8.DecodeRuneInString(str[i:])
|
||||
fmt.Printf("%c", r)
|
||||
i += size
|
||||
}
|
||||
fmt.Println("\n" + strings.Repeat("#", 20))
|
||||
}
|
||||
18
Section12/94.go
Normal file
18
Section12/94.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s1 := "Golang"
|
||||
fmt.Println(len(s1))
|
||||
|
||||
name := "Codruța"
|
||||
fmt.Println(len(name))
|
||||
|
||||
n := utf8.RuneCountInString(name)
|
||||
fmt.Println(n)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user