1.文件名,关键字和标识符
  1. 每个golang程序的源文件都是以.go为后缀结尾
  2. golang有25个关键字
    break, default, func, interface, select
    case, defer, go, map, struct, chan
    else, goto, package, switch, const
    fallthrough, if, range, type, continue
    for, import, return, var
  3. 标识符使用字母数字下划线,且必须以字母或下划线开头的字符串序列
    另外golang中还预定义了35个标识符
    append, bool, byte, cap, close, complex, complex64, complex12
    copy, false, float32, float64, imag, int, int8, int16, int32, int64, iota
    len, make, new, nil, panic, print, println, real, recover, string, true
    unit, unit8
2.一个最小的golang程序结构
    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("hello golang!")
    }
package mainimport "fmt"func main() {// 函数体}
3.常量及其定义和使用
const identifer [type] = valueconst PI = 3.14[type]const PI float64 = 3.14const STL string = "strings"
4.变量及其声明
var variable_name [type]var condition string = "if a is not b"
5.类型零值
var b stringvar c int
6.简短形式声明并初始化变量
a := falsestr := "string"a, _, c = 1, 2, 3
7.init函数
func init() {//statement}
8.基本数据类型和运算符
==!=
    var vari = 10
    vari == 10
    vari == 5
    vari != 5
9.逻辑运算符
!, &&, ||
10.算术运算符
+,-,*,/,%
11.运算符优先级
    优先级            运算符
        7             ^, !
        6             *, /, %, <<, >>, &, &^
        5             +, -, |, ^
        4             ==, !=, <, <=, >=, >
        3             <-
        2             &&
        1             ||
12.字符串
  1. 概念:字符串是utf-8字符的一个序列
13.strings包
HasPrefix(s, prefix) boolHasSuffix(s, suffix) bool
    package main

    import (
        "ftm"
        "strings"
    )
    func main() {
        var str string = "https://www.golang.org"
        fmt.Println(strings.HasPrefix(str, "https:"))
        fmt.Println(strings.HasSuffix(str, ".org"))
    }
14.字符串包含
Contains(s, substr, string) bool
    package main

    import (
        "fmt"
        "strings"
    )

    func main() {
        var str string = "hello golang"
        fmt.Println(strings.Contains(str, "he"))
    }
15.索引
Index(s, substr string) intLastIndex(s, substr string) intchIndexRune(s, substr string) int
    package main
    
    import (
        "fmt"
        "strings"
    )

    func main() {
        var str string = "oh my god!"
        fmt.Println(strings.Index(str, "o"))
        fmt.Println(strings.LastIndex(str, "my"))
        fmt.Println(strings.IndexRune(str, "层次"))
    }
16.字符串替换和统计字符串出现的次数
Replace(str, old, new, n) stringCount(s, str string) int
17.字符串重复
Repeat(s string, count int) string
18.修剪字符串
TrimSpace(s)TrimLeft(s)TrimRight(s)
19.分割字符串
Split(s, sep)
20.拼接slice到字符串
Join(sl []string, sep string)

that's all