feat(Go-StudyExample): 新增 网络及端口测试、传值和传址的比较、切片测试、Map测试、通道测试、测试init调用、测试error、defer关键字、recover测试、测试携程的异常捕获、矩阵旋转

This commit is contained in:
huangzj
2020-07-13 17:02:04 +08:00
parent f5894a2680
commit 9ad10e8cd9
12 changed files with 514 additions and 13 deletions
+42
View File
@@ -0,0 +1,42 @@
/*
* @Author : huangzj
* @Time : 2020/7/13 13:43
* @Description:传值和传址
*/
package originGoLanguage
import "fmt"
func TestQuote() {
x, y := "i am x", "i am y"
fmt.Println("回参的值2")
x2, y2 := byValue(x, y)
fmt.Println(x2)
fmt.Println(y2)
fmt.Println("传值的方式(原始值)")
fmt.Println(x)
fmt.Println(y)
fmt.Println("回参的值")
x1, y1 := byAddress(&x, &y)
fmt.Println(x1)
fmt.Println(y1)
fmt.Println("传引用的方式(原始值)")
fmt.Println(x)
fmt.Println(y)
}
func byAddress(i *string, i2 *string) (string, string) {
*i2, *i = *i, *i2
return *i, *i2
}
func byValue(s string, s2 string) (string, string) {
s, s2 = s2, s
return s, s2
}