正则表达式是一个非常有用的工具,用于描述匹配文本的搜索模式。正则表达式只不过是定义搜索模式的一些字符序列。正则表达式用于解析、过滤、验证和从大文本中提取有意义的信息,例如从其他程序生成的日志和输出。

 

用于提取方括号之间的文本的正则表达式

package main

import (
	"fmt"
	"regexp"
	"strings"
)

func main() {
	str1 := "this is a [sample] [[string]] with [SOME] special words"

	re := regexp.MustCompile(`\[([^\[\]]*)\]`)
	fmt.Printf("Pattern: %v\n", re.String())      // print pattern
	fmt.Println("Matched:", re.MatchString(str1)) // true

	fmt.Println("\nText between square brackets:")
	submatchall := re.FindAllString(str1, -1)
	for _, element := range submatchall {
		element = strings.Trim(element, "[")
		element = strings.Trim(element, "]")
		fmt.Println(element)
	}
}

输出

Pattern: \[([^\[\]]*)\]
Matched: true
Text between square brackets:
sample
string
SOME

 

用于从字符串中提取所有非字母数字字符

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := "We @@@Love@@@@ #Go!$! ****Programming****Language^^^"

	re := regexp.MustCompile(`[^a-zA-Z0-9]+`)

	fmt.Printf("Pattern: %v\n", re.String()) // print pattern
	fmt.Println(re.MatchString(str1))        // true

	submatchall := re.FindAllString(str1, -1)
	for _, element := range submatchall {
		fmt.Println(element)
	}
}

输出

Pattern: [^a-zA-Z0-9]+
true
 @@@
@@@@ #
!$! ****
****
^^^

 

用于从字符串中提取日期YYYY-MM-DD的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := "If I am 20 years 10 months and 14 days old as of August 17,2016 then my DOB would be 1995-10-03"

	re := regexp.MustCompile(`\d{4}-\d{2}-\d{2}`)

	fmt.Printf("Pattern: %v\n", re.String()) // print pattern

	fmt.Println(re.MatchString(str1)) // true

	submatchall := re.FindAllString(str1, -1)
	for _, element := range submatchall {
		fmt.Println(element)
	}
}

输出

Pattern: \d{4}-\d{2}-\d{2}
true
1995-10-03

 

用于从字符串中提取DNS主机名或IP地址的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := `Proxy Port Last Check Proxy Speed Proxy Country Anonymity 118.99.81.204
	118.99.81.204 8080 34 sec Indonesia - Tangerang Transparent 2.184.31.2 8080 58 sec 
	Iran Transparent 93.126.11.189 8080 1 min Iran - Esfahan Transparent 202.118.236.130 
	7777 1 min China - Harbin Transparent 62.201.207.9 8080 1 min Iraq Transparent`

	re := regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`)

	fmt.Printf("Pattern: %v\n", re.String()) // print pattern
	fmt.Println(re.MatchString(str1)) // true

	submatchall := re.FindAllString(str1, -1)
	for _, element := range submatchall {
		fmt.Println(element)
	}
}

输出

Pattern: (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}
true
118.99.81.204
118.99.81.204
2.184.31.2
93.126.11.189
202.118.236.130
62.201.207.9

 

用于从URL中提取域名的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := `http://www.suon.co.uk/product/1/7/3/`

	re := regexp.MustCompile(`^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/\n]+)`)
	fmt.Printf("Pattern: %v\n", re.String()) // print pattern
	fmt.Println(re.MatchString(str1)) // true

	submatchall := re.FindAllString(str1,-1)
	for _, element := range submatchall {
		fmt.Println(element)
	}
}

输出

Pattern: ^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/\n]+)
true
http://www.suon.co.uk

 

用于验证电子邮件地址的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := "ç$€§/az@gmail.com"
	str2 := "abcd@gmail_yahoo.com"
	str3 := "abcd@gmail-yahoo.com"
	str4 := "abcd@gmailyahoo"
	str5 := "abcd@gmail.yahoo"

	re := regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")

	fmt.Printf("Pattern: %v\n", re.String()) // print pattern	
	fmt.Printf("\nEmail: %v :%v\n", str1, re.MatchString(str1))
	fmt.Printf("Email: %v :%v\n", str2, re.MatchString(str2))
	fmt.Printf("Email: %v :%v\n", str3, re.MatchString(str3))
	fmt.Printf("Email: %v :%v\n", str4, re.MatchString(str4))
	fmt.Printf("Email: %v :%v\n", str5, re.MatchString(str5))
}

输出

Pattern: ^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$

Email: ç$?§/az@gmail.com :false
Email: abcd@gmail_yahoo.com :false
Email: abcd@gmail-yahoo.com :true
Email: abcd@gmailyahoo :true
Email: abcd@gmail.yahoo :true

 

用于验证电话号码的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := "1(234)5678901x1234"
	str2 := "(+351) 282 43 50 50"
	str3 := "90191919908"
	str4 := "555-8909"
	str5 := "001 6867684"
	str6 := "001 6867684x1"
	str7 := "1 (234) 567-8901"
	str8 := "1-234-567-8901 ext1234"

	re := regexp.MustCompile(`^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$`)

	fmt.Printf("Pattern: %v\n", re.String()) // print pattern
	fmt.Printf("\nPhone: %v\t:%v\n", str1, re.MatchString(str1))
	fmt.Printf("Phone: %v\t:%v\n", str2, re.MatchString(str2))
	fmt.Printf("Phone: %v\t\t:%v\n", str3, re.MatchString(str3))
	fmt.Printf("Phone: %v\t\t\t:%v\n", str4, re.MatchString(str4))
	fmt.Printf("Phone: %v\t\t:%v\n", str5, re.MatchString(str5))
	fmt.Printf("Phone: %v\t\t:%v\n", str6, re.MatchString(str6))
	fmt.Printf("Phone: %v\t\t:%v\n", str7, re.MatchString(str7))
	fmt.Printf("Phone: %v\t:%v\n", str8, re.MatchString(str8))
}

输出

Pattern: ^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x
)[\-\.\ \\\/]?(\d+))?$

Phone: 1(234)5678901x1234       :true
Phone: (+351) 282 43 50 50      :true
Phone: 90191919908              :true
Phone: 555-8909                 :true
Phone: 001 6867684              :true
Phone: 001 6867684x1            :true
Phone: 1 (234) 567-8901         :true
Phone: 1-234-567-8901 ext1234   :true

 

用于验证正确的日期格式的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := "31/07/2010"
	str2 := "1/13/2010"
	str3 := "29/2/2007"
	str4 := "31/08/2010"
	str5 := "29/02/200a"
	str6 := "29/02/200a"
	str7 := "55/02/200a"
	str8 := "2_/02/2009"

	re := regexp.MustCompile("(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\\d\\d)")

	fmt.Printf("Pattern: %v\n", re.String()) // print pattern
	fmt.Printf("\nDate: %v :%v\n", str1, re.MatchString(str1))
	fmt.Printf("Date: %v :%v\n", str2, re.MatchString(str2))
	fmt.Printf("Date: %v :%v\n", str3, re.MatchString(str3))
	fmt.Printf("Date: %v :%v\n", str4, re.MatchString(str4))
	fmt.Printf("Date: %v :%v\n", str5, re.MatchString(str5))
	fmt.Printf("Date: %v :%v\n", str6, re.MatchString(str6))
	fmt.Printf("Date: %v :%v\n", str7, re.MatchString(str7))
	fmt.Printf("Date: %v :%v\n", str8, re.MatchString(str8))
}

输出

Pattern: (0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\d\d)
Date: 31/07/2010 :true
Date: 1/13/2010 :false
Date: 29/2/2007 :true
Date: 31/08/2010 :true
Date: 29/02/200a :false
Date: 29/02/200a :false
Date: 55/02/200a :false
Date: 2_/02/2009 :false

 

用于验证常用信用卡号的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := "4111111111111111"
	str2 := "346823285239073"
	str3 := "370750517718351"
	str4 := "4556229836495866"
	str5 := "5019717010103742"
	str6 := "76009244561"
	str7 := "4111-1111-1111-1111"
	str8 := "5610591081018250"
	str9 := "30569309025904"
	str10 := "6011111111111117"

	re := regexp.MustCompile(`^(?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$`)

	fmt.Printf("Pattern: %v\n", re.String()) // print pattern
	fmt.Printf("\nCC : %v :%v\n", str1, re.MatchString(str1))
	fmt.Printf("CC : %v :%v\n", str2, re.MatchString(str2))
	fmt.Printf("CC : %v :%v\n", str3, re.MatchString(str3))
	fmt.Printf("CC : %v :%v\n", str4, re.MatchString(str4))
	fmt.Printf("CC : %v :%v\n", str5, re.MatchString(str5))
	fmt.Printf("CC : %v :%v\n", str6, re.MatchString(str6))
	fmt.Printf("CC : %v :%v\n", str7, re.MatchString(str7))
	fmt.Printf("CC : %v :%v\n", str8, re.MatchString(str8))
	fmt.Printf("CC : %v :%v\n", str9, re.MatchString(str9))
	fmt.Printf("CC : %v :%v\n", str10, re.MatchString(str10))
}

输出

Pattern: ^(?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|18
00|35\d{3})\d{11})$
CC : 4111111111111111 :true
CC : 346823285239073 :true
CC : 370750517718351 :true
CC : 4556229836495866 :true
CC : 5019717010103742 :false
CC : 76009244561 :false
CC : 4111-1111-1111-1111 :false
CC : 5610591081018250 :true
CC : 30569309025904 :true
CC : 6011111111111117 :true

 

使用正则表达式将任何非字母数字字符序列替换为短划线

package main

import (
	"fmt"
	"log"
	"regexp"
)

func main() {
	reg, err := regexp.Compile("[^A-Za-z0-9]+")
	if err != nil {
		log.Fatal(err)
	}
	newStr := reg.ReplaceAllString("#Golang#Python$Php&Kotlin@@", "-")
	fmt.Println(newStr)
}

输出

-Golang-Python-Php-Kotlin-

 

使用替换第一次出现的匹配的字符串正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	strEx := "Php-Golang-Php-Python-Php-Kotlin"
	reStr := regexp.MustCompile("^(.*?)Php(.*)$")
	repStr := "${1}Java$2"
	output := reStr.ReplaceAllString(strEx, repStr)
	fmt.Println(output)
}

输出

Java-Golang-Php-Python-Php-Kotlin

 

以空格拆分字符串的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := "Split   String on \nwhite    \tspaces."

	re := regexp.MustCompile(`\S+`)

	fmt.Printf("Pattern: %v\n", re.String()) // Print Pattern

	fmt.Printf("String contains any match: %v\n", re.MatchString(str1)) // True

	submatchall := re.FindAllString(str1, -1)
	for _, element := range submatchall {
		fmt.Println(element)
	}
}

输出

Pattern: \S+
String contains any match: true
Split
String
on
white
spaces.

 

从字符串中提取数字的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := "Hello X42 I'm a Y-32.35 string Z30"

	re := regexp.MustCompile(`[-]?\d[\d,]*[\.]?[\d{2}]*`)

	fmt.Printf("Pattern: %v\n", re.String()) // Print Pattern

	fmt.Printf("String contains any match: %v\n", re.MatchString(str1)) // True

	submatchall := re.FindAllString(str1, -1)
	for _, element := range submatchall {
		fmt.Println(element)
	}
}

输出

Pattern: [-]?\d[\d,]*[\.]?[\d{2}]*
String contains any match: true
42
-32.35
30

 

从给定路径中提取文件名的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	re := regexp.MustCompile(`^(.*/)?(?:$|(.+?)(?:(\.[^.]*$)|$))`)

	str1 := `http://www.golangprograms.com/regular-expressions.html`
	match1 := re.FindStringSubmatch(str1)
	fmt.Println(match1[2])

	str2 := `/home/me/dir3/dir3a/dir3ac/filepat.png`
	match2 := re.FindStringSubmatch(str2)
	fmt.Println(match2[2])
}

输出

regular-expressions
filepat

 

使用正则表达式将字符串以大写字母拆分

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := "Hello X42 I'm a Y-32.35 string Z30"

	re := regexp.MustCompile(`[A-Z][^A-Z]*`)

	fmt.Printf("Pattern: %v\n", re.String()) // Print Pattern

	submatchall := re.FindAllString(str1, -1)
	for _, element := range submatchall {
		fmt.Println(element)
	}
}

输出

Pattern: [A-Z][^A-Z]*
Hello
X42
I'm a
Y-32.35 string
Z30

 

用于获取括号之间的字符串的正则表达式

package main

import (
	"fmt"
	"regexp"
	"strings"
)

func main() {
	str1 := "This is a (sample) ((string)) with (SOME) special words"

	re := regexp.MustCompile(`\((.*?)\)`)
	fmt.Printf("Pattern: %v\n", re.String()) // print pattern

	fmt.Println("\nText between parentheses:")
	submatchall := re.FindAllString(str1, -1)
	for _, element := range submatchall {
		element = strings.Trim(element, "(")
		element = strings.Trim(element, ")")
		fmt.Println(element)
	}
}

输出

Pattern: \((.*?)\)
Text between parentheses:
sample
string
SOME

 

将字符串中的符号替换为空格

package main 

import ( 
	"fmt" 
	"log" 
	"regexp" 
)

func main() { 
	str1 := "how much for the maple syrup? $20.99? That's ridiculous!!!" 
	re, err := regexp.Compile(`[^\w]`) 
	if err != nil { 
		log.Fatal(err) 
	} 
	str1 = re.ReplaceAllString(str1, " ") 
	fmt.Println(str1) 
}

输出

how much for the maple syrup   20 99  That s ridiculous

 

使用正则表达式替换字符串中的表情符号字符

package main 
import (
	"fmt" 
	"regexp" 
) 

func main() { 
	var emojiRx = regexp.MustCompile(`[\x{1F600}-\x{1F6FF}|[\x{2600}-\x{26FF}]`) 
	var str = emojiRx.ReplaceAllString("Thats a nice joke 😆😆😆 😛", `[e]`) 
	fmt.Println(str) 
}

输出

Thats a nice joke [e][e][e] [e]

 

获取textarea标记之间的文本的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := `<html><body>
			<form name="query" action="http://www.example.net/action.php" method="post">
				<textarea type="text" name="nameiknow">The text I want</textarea>
				<div id="button">
					<input type="submit" value="Submit" />
				</div>
			</form>
			</body></html>`

	re := regexp.MustCompile(`<textarea.*?>(.*)</textarea>`)

	submatchall := re.FindAllStringSubmatch(str1, -1)
	for _, element := range submatchall {
		fmt.Println(element[1])
	}
}

输出

The text I want

 

用于匹配HH:MM时间格式的正则表达式

package main

import (
	"fmt"
	"regexp"
)

func main() {
	str1 := "8:2"
	str2 := "9:9"
	str3 := "12:29"
	str4 := "02:5"
	str5 := "23:59"
	str6 := "55:59"
	str7 := "0:01"

	re := regexp.MustCompile(`^([0-9]|0[0-9]|1[0-9]|2[0-3]):([0-9]|[0-5][0-9])$`)

	fmt.Printf("Pattern: %v\n", re.String()) // print pattern
	fmt.Printf("Time: %v\t:%v\n", str1, re.MatchString(str1))
	fmt.Printf("Time: %v\t:%v\n", str2, re.MatchString(str2))
	fmt.Printf("Time: %v\t:%v\n", str3, re.MatchString(str3))
	fmt.Printf("Time: %v\t:%v\n", str4, re.MatchString(str4))
	fmt.Printf("Time: %v\t:%v\n", str5, re.MatchString(str5))
	fmt.Printf("Time: %v\t:%v\n", str6, re.MatchString(str6))
	fmt.Printf("Time: %v\t:%v\n", str7, re.MatchString(str7))
}

输出

Pattern: ^([0-9]|0[0-9]|1[0-9]|2[0-3]):([0-9]|[0-5][0-9])$
Time: 8:2       :true
Time: 9:9       :true
Time: 12:29     :true
Time: 02:5      :true
Time: 23:59     :true
Time: 55:59     :false
Time: 0:01      :true

© 本文著作权归作者所有。转载请联系授权,禁止商用。

🔗 系列文章

1. Go语言教程之边写边学:Go语言介绍

2. Go语言教程之边写边学:变量

3. Go语言教程之边写边学:常量

4. Go语言教程之边写边:数据类型定义

5. Go语言教程之边写边学:类型转换-如何在Go中将字符串转换为整数类型?

6. Go语言教程之边写边学:类型转换-如何在Go中将字符串转换为浮点类型?

7. Go语言教程之边写边学:类型转换-如何在Go中将字符串转换为布尔数据类型转换?

8. Go语言教程之边写边学:类型转换-如何在Go中将布尔类型转换为字符串?

9. Go语言教程之边写边学:类型转换-如何在 Go 中将浮点转换为字符串类型?

10. Go语言教程之边写边学:类型转换-integer到string转换的不同方式

11. Go语言教程之边写边学:类型转换-将Int数据类型转换为 Int16 Int32 Int64

12. Go语言教程之边写边学:类型转换-将float32转换为float64,将float64转换为float32

13. Go语言教程之边写边学:类型转换-将integer转换为float

14. Go语言教程之边写边学:运算符

15. Go语言教程之边写边学:If...Else...Else If条件语句

16. Go语言教程之边写边学:Switch…Case条件语句

17. Go语言教程之边写边学:For循环

18. Go语言教程之边写边学:函数

19. Go语言教程之边写边学:可变参数函数

20. Go语言教程之边写边学:延迟调用函数

21. Go语言教程之边写边学:panic和recover

22. Go语言教程之边写边学:数组array

23. Go语言教程之边写边学:切片slice

24. Go语言教程之边写边学:映射map

25. Go语言教程之边写边学:结构 struct

26. Go语言教程之边写边学:接口 interface

27. Go语言教程之边写边学:协程 Goroutine

28. Go语言教程之边写边学:通道 channel

29. Go语言教程之边写边学:并发 Concurrency

30. Go语言教程之边写边学:日志 logging

31. Go语言教程之边写边学:操作文件和文件夹,压缩和解压缩

32. Go语言教程之边写边学:读写不同的文件类型

33. Go语言教程之边写边学:正则表达式 Regex

34. Go语言教程之边写边学:golang中处理DNS记录

35. Go语言教程之边写边学:密码学 Cryptography

36. Go语言教程之边写边学:golang的一些陷阱

37. Go语言教程之边写边学:导入导出:如何从其他包或者子包中导入结构体

38. Go语言教程之边写边学:导入导出:用指针访问并修改其他包的变量

39. Go语言教程之边写边学:导入导出:如何导入包并声明包的别名

40. Go语言教程之边写边学:导入导出:如何实现来自不同包的接口?

41. Go语言教程之边写边学:导入导出:如何从另一个包调用函数?

42. Go语言教程之边写边学:导入导出:解引用来自另一个包的指针

43. Go语言教程之边写边学:常用的软件库:结构体和字段验证

44. Go语言教程之边写边学:常用的软件库:Golang中的动态JSON

45. Go语言教程之边写边学:常用的软件库:Golang统计包

46. Go语言教程之边写边学:常用的软件库:slice和map过滤器

47. Go语言教程之边写边学:常用的软件库:HTML解析器

48. Go语言教程之边写边学:常用的软件库:常用正则表达式包CommonRegex

49. Go语言教程之边写边学:常用的软件库:简单图像处理包

50. Go语言教程之边写边学:常用的软件库:图表包

51. Go语言教程之边写边学:常用的软件库:动态XML解析器

52. Go语言教程之边写边学:常用的软件库:时间工具包

53. Go语言教程之边写边学:web应用:如何创建照片库

54. Go语言教程之边写边学:web应用:获取Twitter趋势某个位置附近的热门主题标签

55. Go语言教程之边写边学:web应用:生成二维码的Web应用程序

56. Go语言教程之边写边学:web应用:读取和写入JSON数据的Web应用程序

57. Go语言教程之边写边学:Goroutines和Channels练习:启动多个Goroutine,每个goroutine都向一个频道添加值

58. Go语言教程之边写边学:Goroutines和Channels练习:从通道发送和接收值

59. Go语言教程之边写边学:Goroutines和Channels练习:将斐波那契数列读写到通道

60. Go语言教程之边写边学:Goroutines和Channels练习:Goroutines通道执行顺序

61. Go语言教程之边写边学:Goroutines和Channels练习:查找奇数和偶数

62. Go语言教程之边写边学:Goroutines和Channels练习:哲学家就餐问题

63. Go语言教程之边写边学:Goroutines和Channels练习:检查点同步问题

64. Go语言教程之边写边学:Goroutines和Channels练习:生产者消费者问题

65. Go语言教程之边写边学:Goroutines和Channels练习:睡眠理发师问题

66. Go语言教程之边写边学:Goroutines和Channels练习:吸烟者问题

67. Go语言教程之边写边学:Golang中的反射:Reflect 包的copy函数

68. Go语言教程之边写边学:Golang中的反射:Reflect包的DeepEqual函数

69. Go语言教程之边写边学:Golang中的反射:Reflect包的swapper函数

70. Go语言教程之边写边学:Golang中的反射:Reflect包的TypeOf函数

71. Go语言教程之边写边学:Golang中的反射:Reflect包的ValueOf函数

72. Go语言教程之边写边学:Golang中的反射:Reflect包的Field相关函数

73. Go语言教程之边写边学:Golang中的反射:Reflect包的Make相关函数

74. Go语言教程之边写边学:golang中创建结构体切片

75. Go语言教程之边写边学:golang中创建结构体字典

76. Go语言教程之边写边学:golang中捕获panic

77. Go语言教程之边写边学:检查结构体中是否存在某个字段

78. Go语言教程之边写边学:初始化包含结构体切片的结构体

79. Go语言教程之边写边学:使用空接口动态添加结构体成员

80. Go语言教程之边写边学:将结构字段转换为映射字符串

81. Go语言教程之边写边学:Golang中的字符串

82. Go语言教程之边写边学:Golang中的字符串:字符串操作

83. Go语言教程之边写边学:Golang中的字符串:字符串字符编码

84. Go语言教程之边写边学:Golang Web服务器示例

85. Go语言教程之边写边学:Go中的HTTP服务器

86. Go语言教程之边写边学:Go中的HTTP客户端

87. Go语言教程之边写边学:使用HTTP客户端在HTTP请求中设置标头

88. Go语言教程之边写边学:使用HTTP客户端从HTTP响应中读取标头

89. Go语言教程之边写边学:处理HTTP重定向

90. Go语言教程之边写边学:如何处理HTTP 错误

91. Go语言教程之边写边学:如何在HTTP响应中设置标头

92. Go语言教程之边写边学:如何读取HTTP响应中的标头

93. Go语言教程之边写边学:如何在HTTP请求中设置cookie

94. Go语言教程之边写边学:如何读取HTTP请求中的cookie

95. Go语言教程之边写边学:如何处理HTTP身份验证

96. Go语言教程之边写边学:如何在HTTP客户端处理HTTP超时

97. Go语言教程之边写边学:如何优雅地处理HTTP服务器关闭

98. Go语言教程之边写边学:如何处理HTTP客户端-服务器安全

99. Go语言教程之边写边学:如何处理HTTP服务器负载均衡

100. Go语言教程之边写边学:如何处理HTTP服务器缓存

101. Go语言教程之边写边学:如何处理HTTP客户端缓存

102. Go语言教程之边写边学:如何处理HTTP服务器健康检查

103. Go语言教程之边写边学:如何处理HTTP客户端请求压缩

104. Go语言教程之边写边学:如何处理HTTP服务器日志记录

105. Go语言教程之边写边学:如何创建HTTP/2服务器

106. Go语言教程之边写边学:如何向Prometheus发出服务器预警

107. Go语言教程之边写边学:标准库:Context包

108. Go语言教程之边写边学:基础练习:打印金字塔型星号

109. Go语言教程之边写边学:基础练习:检查一个数字是否是回文

110. Go语言教程之边写边学:基础练习:打印乘法表

111. Go语言教程之边写边学:基础练习:打印帕斯卡三角形

112. Go语言教程之边写边学:基础练习:如何创建多个goroutine,如何使用三个逻辑处理器

113. Go语言教程之边写边学:基础练习:如何提高 Golang 应用程序的性能?

114. Go语言教程之边写边学:基础练习:类型嵌入和方法覆盖的接口示例

115. Go语言教程之边写边学:基础练习:如何使用WaitGroup将main函数的执行延迟到所有goroutines完成后

116. Go语言教程之边写边学:基础练习:逐行读取文件到字符串

117. Go语言教程之边写边学:基础练习:并发最佳实践

118. Go语言教程之边写边学:基础练习:2023年要遵循的最佳实践

119. Go语言教程之边写边学:基础练习:如何获取带有本地时区的当前日期和时间

120. Go语言教程之边写边学:基础练习:获取今天是星期几,今天是今年的第几天,本周是今年的第几周?

121. Go语言教程之边写边学:基础练习:获取 EST、UTC 和 MST 中的当前日期和时间

122. Go语言教程之边写边学:基础练习:获取两个日期之间的小时、天、分钟和秒差 [未来和过去]

123. Go语言教程之边写边学:基础练习:将年、月、日、小时、分钟、秒、毫秒、微秒和纳秒添加到当前日期时间

124. Go语言教程之边写边学:基础练习:将年、月、日、小时、分钟、秒、毫秒、微秒和纳秒从当前日期时间减去

125. Go语言教程之边写边学:基础练习:以各种格式获取当前日期和时间

126. Go语言教程之边写边学:基础练习:从当前日期和时间获取年、月、日、小时、分钟和秒

127. Go语言教程之边写边学:基础练习:将特定的UTC日期时间转换为 PST、HST、MST 和 SGT

128. Go语言教程之边写边学:基础练习:使用carbon日期时间包

129. Go语言教程之边写边学:基础练习:切片排序、反转、搜索功能

130. Go语言教程之边写边学:基础练习:常用字符串函数(1)

131. Go语言教程之边写边学:基础练习:常用字符串函数(2)

132. Go语言教程之边写边学:基础练习:常用字符串函数(3)

133. Go语言教程之边写边学:基础练习:常用字符串函数(4)

134. Go语言教程之边写边学:基础练习:方法和对象

135. Go语言教程之边写边学:基础练习:接口的设计理念

136. Go语言教程之边写边学:数据结构与算法:线性搜索

137. Go语言教程之边写边学:数据结构与算法:二分搜索

138. Go语言教程之边写边学:数据结构与算法:插值搜索

139. Go语言教程之边写边学:数据结构与算法:冒泡排序

140. Go语言教程之边写边学:数据结构与算法:快速排序

141. Go语言教程之边写边学:数据结构与算法:选择排序

142. Go语言教程之边写边学:数据结构与算法:希尔排序

143. Go语言教程之边写边学:数据结构与算法:插入排序

144. Go语言教程之边写边学:数据结构与算法:梳排序

145. Go语言教程之边写边学:数据结构与算法:归并排序

146. Go语言教程之边写边学:数据结构与算法:基数排序

147. Go语言教程之边写边学:数据结构与算法:烧饼排序

148. Go语言教程之边写边学:数据结构与算法:二叉树

149. Go语言教程之边写边学:数据结构与算法:Rabin-Karp

150. Go语言教程之边写边学:数据结构与算法:链表 Linked List

151. Go语言教程之边写边学:数据结构与算法:LIFO堆栈和FIFO队列

152. Go语言教程之边写边学:数据结构与算法:BFPRT中位数的中位数

153. Go语言教程之边写边学:数据结构与算法:LCS最长公共子序列

154. Go语言教程之边写边学:数据结构与算法:Levenshtein Distance编辑距离

155. Go语言教程之边写边学:数据结构与算法:KMP算法 字符串匹配算法

156. Go语言教程之边写边学:数据结构与算法:Floyd–Warshall多源最短路径

157. Go语言教程之边写边学:数据结构与算法:汉诺塔Tower of Hanoi

158. Go语言教程之边写边学:数据结构与算法:哈夫曼编码(Huffman Coding)

159. Go语言教程之边写边学:数据结构与算法:绘制长方体

160. Go语言教程之边写边学:数据结构与算法:生成随机迷宫

161. Go语言教程之边写边学:数据结构与算法:生成数字折线矩阵

162. Go语言教程之边写边学:数据结构与算法:生成数字螺旋矩阵

163. Go语言教程之边写边学:数据结构与算法:生成自平衡二叉查找树 AVL tree

164. Go语言教程之边写边学:数据结构与算法:打印给定字符串的所有排列

165. Go语言教程之边写边学:数据结构与算法:LZW 数据无损压缩和解压缩

166. Go语言教程之边写边学:了解go中并发工作原理:了解goroutine

167. Go语言教程之边写边学:了解go中并发工作原理:将channel用作通信机制

168. Go语言教程之边写边学:了解go中并发工作原理:了解有缓冲channel

169. Go语言教程之边写边学:了解go中并发工作原理:挑战:利用并发方法更快地计算斐波纳契数

170. Go语言教程之边写边学:编写并测试程序 :概述网上银行项目

171. Go语言教程之边写边学:编写并测试程序 :开始编写测试

172. Go语言教程之边写边学:编写并测试程序 :编写银行核心程序包

173. Go语言教程之边写边学:编写并测试程序 :编写银行 API

174. Go语言教程之边写边学:编写并测试程序 :完成银行项目功能

175. Go语言教程之边写边学:了解如何在 Go 中处理错误

176. Go语言教程之边写边学:标准库:strings(1)

177. Go语言教程之边写边学:标准库:strings(2)

178. Go语言教程之边写边学:标准库:strings(3)

179. Go语言教程之边写边学:标准库:strings(4)

180. Go语言教程之边写边学:标准库:strings(5)

181. Go语言教程之边写边学:标准库:strings(6)