package main

import (

"fmt"

"strings"

)

func reverse(str string) string {

var result string

length := len(str)

for i := 0; i < length; i++ {

result += fmt.Sprintf("%c", str[length-i-1])

}

return result

}

func main() {

str1 := "hello"

str2 := " world"

//str3 := str1 + str2

str3 := fmt.Sprintf("%s%s", str1, str2)

//字符串长度

n := len(str3)

fmt.Println(str3)

fmt.Printf("len(str3)=%d\n", n)

//切片

substr := str3[0:5]

fmt.Println(substr)

substr = str3[6:]

fmt.Println(substr)

//转为大写

substr = strings.ToUpper(str3)

fmt.Println(substr)

//字符串反转

resv := reverse(str3)

fmt.Println(resv)

}