go语言背景介绍
go语言:Google开源,编译型语言,21世纪的C语言
解释型语言:python、php
编译型语言:go、c、c++
编译型语言执行性能高于解释型语言。
go语言快捷键
go build -o xxx 给编译的二进制文件重新命名go fmt main.go 自动格式化文件
区别于c和c++,不能进行偏移和运算,是安全指针。

字符串需要注意:
fmt.PrintIn("\t制表符\n换行符")

// 字符串长度s := "hello"fmt.PrintIn(len(s)) //5s2 := "hello沙河”fmt.PrintIn(len(s2)) //11// 拼接字符串fmt.PrintIn(s+s2) //hellohello沙河s3 := fmt.Sprintf("%s -%s", s, s2) // hello - hello沙河fmt.PrintIn(s3)// 字符串分割s4 := "how do you do"fmt.PrintIn(strings.Split(s4, "")) // [how do you do]// 查看分割后的类型fmt.Printf("%T\n", strings.Split(s4, " "))//判断是否包含fmt.PrintIn(strings.Contains(s4, "do")) // true// 判断前缀fmt.PrintIn(strings.HasPrefix(s4, "how")) // true// 判断后缀fmt.PrintIn(strings.HasSuffix(s4, "how")) // false// 判断子串的位置fmt.PrintIn(strings.Index(s4, "do")) // 4// 最后子串出现的位置fmt.PrintIn(strings.LastIndex(s4, "do")) // 11// joins5 := []string{"how", "do", "you", "do"} // 定义了一个字符串的切片fmt.PrintIn(s5) // [how do you do]fmt.PrintIn(strings.Join(s5, "+")) // how+do+you+do


