From daad8b5f9885c4d8f4bc2a64258985ca96e9565c Mon Sep 17 00:00:00 2001
From: jaywcjlove <398188662@qq.com>
Date: Wed, 6 Jul 2022 17:53:15 +0800
Subject: [PATCH 01/11] doc: build document.
---
.github/workflows/ci.yml | 51 +++++++++++++++++++++++++++++++---------
README.md | 11 ++++-----
package.json | 18 ++++----------
3 files changed, 49 insertions(+), 31 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d54b92d..e560bff 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,13 +8,14 @@ jobs:
website:
runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-node@v2
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
with:
- node-version: 14
+ node-version: 16
- - run: mkdir -p build build/example
- - run: cp -rp example build/example
+ - run: npm run build
+ - run: mkdir -p dist dist/example
+ - run: cp -rp example dist/example
# - run: npm i markdown-to-html-cli -g
# - run: markdown-to-html --output build/index.html
@@ -22,17 +23,45 @@ jobs:
uses: jaywcjlove/github-action-contributors@main
with:
filter-author: (renovate\[bot\]|renovate-bot|dependabot\[bot\])
- output: build/CONTRIBUTORS.svg
+ output: dist/CONTRIBUTORS.svg
avatarSize: 42
- - name: Converts Markdown to HTML
- uses: jaywcjlove/markdown-to-html-cli@main
+ - name: Create Tag
+ id: create_tag
+ uses: jaywcjlove/create-tag-action@v1.3.7
with:
- source: README.md
- output: build/index.html
+ package-path: ./package.json
+
+ - name: get tag version
+ id: tag_version
+ uses: jaywcjlove/changelog-generator@v1.5.7
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
+ user_name: 'github-actions[bot]'
+ user_email: 'github-actions[bot]@users.noreply.github.com'
+ commit_message: ${{steps.tag_version.outputs.tag}} ${{ github.event.head_commit.message }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- publish_dir: ./build
\ No newline at end of file
+ publish_dir: ./dist
+
+ - name: Generate Changelog
+ id: changelog
+ uses: jaywcjlove/changelog-generator@v1.5.7
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ filter-author: (jaywcjlove|小弟调调™|dependabot\[bot\]|Renovate Bot)
+ filter: (^[\s]+?[R|r]elease)|(^[R|r]elease)
+
+ - name: Create Release
+ uses: ncipollo/release-action@v1
+ if: steps.create_tag.outputs.successful
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ name: ${{ steps.create_tag.outputs.version }}
+ tag: ${{ steps.create_tag.outputs.version }}
+ body: |
+ Documentation ${{ steps.changelog.outputs.tag }}: https://raw.githack.com/jaywcjlove/golang-tutorial/${{ steps.changelog.outputs.gh-pages-short-hash }}/index.html
+ Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
+
+ ${{ steps.changelog.outputs.changelog }}
\ No newline at end of file
diff --git a/README.md b/README.md
index 02c8d59..870d27d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
+
Go语言快速入门
===
-
+
[](https://github.com/jaywcjlove/golang-tutorial/actions/workflows/ci.yml)
@@ -15,12 +16,11 @@ Go语言快速入门
- GOPATH 目录下新建 `bin` 目录,该目录用于存放项目中所生成的可执行文件。
- GOPATH 目录下新建 `pkg` 目录,该目录用于存放编译生成的库文件。
+
+
目录
---
-
-点击展开目录菜单
-
- [安装Go](#安装go)
- [运行Go](#运行go)
- [格式化输入输出](#格式化输入输出)
@@ -32,8 +32,7 @@ Go语言快速入门
- [结构体](#结构体)
- [资源导航](#资源导航)
-
-
+
## 安装Go
diff --git a/package.json b/package.json
index 0c2460f..75b1eae 100644
--- a/package.json
+++ b/package.json
@@ -1,23 +1,13 @@
{
"version": "1.0.0",
- "title": "Go语言快速入门",
+ "title": "Go 语言快速入门",
"scripts": {
"start": "idoc --watch",
"build": "idoc"
},
- "markdown-to-html": {
- "github-corners": "https://github.com/jaywcjlove/golang-tutorial",
- "document": {
- "title": "Go 语言快速入门",
- "meta": [
- {
- "description": "通过简单的例子,来快速入门Go语言基础编程、语法等各种语言特性,主要面向新手级别的学习者。"
- },
- {
- "keywords": "golang,tutorial,go,golang-tutorial"
- }
- ]
- }
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/jaywcjlove/golang-tutorial"
},
"devDependencies": {
"idoc": "^1.21.4"
From c475ee74627967c60f8ae67a6c2afb92aad737f5 Mon Sep 17 00:00:00 2001
From: jaywcjlove <398188662@qq.com>
Date: Wed, 6 Jul 2022 17:54:00 +0800
Subject: [PATCH 02/11] chore: update renovate.json
---
renovate.json | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/renovate.json b/renovate.json
index f45d8f1..5fe6b17 100644
--- a/renovate.json
+++ b/renovate.json
@@ -1,5 +1,11 @@
{
"extends": [
"config:base"
+ ],
+ "packageRules": [
+ {
+ "matchPackagePatterns": ["*"],
+ "rangeStrategy": "replace"
+ }
]
}
From 95e77bbd6ad64087c6f8faa956fd043c04434392 Mon Sep 17 00:00:00 2001
From: jaywcjlove <398188662@qq.com>
Date: Wed, 6 Jul 2022 17:59:48 +0800
Subject: [PATCH 03/11] chore: update workflows config.
---
.github/workflows/ci.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e560bff..d301d5c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -13,6 +13,7 @@ jobs:
with:
node-version: 16
+ - run: npm install
- run: npm run build
- run: mkdir -p dist dist/example
- run: cp -rp example dist/example
From f55a75e9f54c2dc785ff2ddac8ad84e5730a3ea3 Mon Sep 17 00:00:00 2001
From: jaywcjlove <398188662@qq.com>
Date: Wed, 6 Jul 2022 18:11:55 +0800
Subject: [PATCH 04/11] doc: Update README.md
---
README.md | 351 +++++++++++-------------------------------------------
1 file changed, 68 insertions(+), 283 deletions(-)
diff --git a/README.md b/README.md
index 870d27d..cff2c71 100644
--- a/README.md
+++ b/README.md
@@ -36,18 +36,14 @@ Go语言快速入门
## 安装Go
-
-CentOS7中通过yum安装
+### CentOS7 中通过 yum 安装
```bash
# CentOS7 可以只用使用yum安装
yum install golang
```
-
-
-
-CentOS7中通过源码安装
+### CentOS7 中通过源码安装
```bash
# 源码下载
@@ -58,10 +54,7 @@ tar zxvf go1.8.linux-amd64.tar.gz -C /usr/local
mkdir -p $HOME/gopath
```
-
-
-
-Mac中通过brew命令安装
+### Mac中通过brew命令安装
使用[home brew](http://brew.sh/)安装方便快捷安装Go,如果你想要在你的 Mac 系统上安装 Go,则必须使用 `Intel 64` 位处理器,Go 不支持 `PowerPC` 处理器。
@@ -73,10 +66,7 @@ brew install go # 安装 go
brew upgrade go # 更新 go
```
-
-
-
-Mac中通过源码安装
+### Mac中通过源码安装
通过源代码编译安装的过程与环境变量的配置与在 Linux 系统非常相似,因此不再赘述。
@@ -84,11 +74,7 @@ brew upgrade go # 更新 go
在 Mac 系统下使用到的 C 工具链是 Xcode 的一部分,因此你需要通过安装 Xcode 来完成这些工具的安装。你并不需要安装完整的 Xcode,而只需要安装它的命令行工具部分。
-
-
-
-
-环境变量配置
+### 环境变量配置
通过`go env`查看go的详细信息
@@ -141,11 +127,7 @@ export PATH=$PATH:$GOPATH/bin
source /etc/profile
```
-
-
-
-
-标准命令详解
+### 标准命令详解
```bash
→ go --help
@@ -237,11 +219,7 @@ cat $GOROOT/VERSION # 查看版本
$GOROOT/src/all.bash # 测试用例正确
```
-
-
-
-
-依赖管理工具
+### 依赖管理工具
目前 Go 语言常用的依赖管理工具,有三个 [godep](https://github.com/tools/godep)、[vendor](https://github.com/kardianos/govendor)和[db](https://github.com/constabulary/gb/),`vendor` 是go 1.5 官方引入管理包依赖的方式,1.6正式引入。所以这里推荐是用[vendor](https://github.com/kardianos/govendor)来管理你的依赖。
@@ -282,26 +260,16 @@ govendor install +local
govendor test +local
```
-
-
-
-
## 卸载go
-
-卸载Go
-
- 删除 Go 的安装文件目录,这通常是在 `Linux`,`macOS` 和 `FreeBSD` 下的 `/usr/local/` go 或者在 Windows 下的 `c:\Go` 下。
- 同时删除环境变量, `Linux` 和 `FreeBSD` 编辑 `/etc/profile` 或者 `$HOME/.profile`。
- 如果你是 `macOS` 你需要删除 `/etc/paths.d/go` 文件。
-
-
## 运行Go
-
-运行Go文档,在线预览文档
+### 运行Go文档,在线预览文档
```bash
# 如果你的 godoc 命令不存在,运行它安装
@@ -311,10 +279,7 @@ $ godoc -http=:6060
# 运行上面一条命令,可访问文档http://localhost:6060/
```
-
-
-
-通过go命令运行
+### 通过go命令运行
我们先写一段GO代码,很简单就是打印输出一个`hello world!`, 保存为[hello.go](./example/hello/hello.go)文件
@@ -332,10 +297,7 @@ func main() {
go run hello.go
```
-
-
-
-通过go命令编译运行
+### 通过go命令编译运行
GO程序的代码是可以直接编译成`exe文件` 或者 `二进制文件`直接运行,在[hello.go](./example/hello/hello.go)目录下运行下面命令,即可把go程序编译成二进制文件
@@ -345,21 +307,13 @@ go build hello.go
上面命令文件可以编译成一个`hello`可执行文件,然后直接在当前目录下 `./hello` 运行,可以输出`hello world!`。
-
-
-
-在浏览器中运行
+### 在浏览器中运行
Go Playground 允许在浏览器里面编辑运行 Go 语言代码。在浏览器中打开 https://play.golang.org/ (需要穿越才能打开) ,输入代码,点击 Run,看看会发生什么?还有个 Share 按钮,点击它会得到一个用于分享的网址,任何人都能代开这个链接,试一试 https://play.golang.org/p/UIOwu0DBQV
-
-
-
## 格式化输入输出
-
-
-输入输出语法方法
+### 输入输出语法方法
> `%[标记][宽度][.精度][arg索引]动词`
> `Print(arg列表)`、`Println(arg列表)`、`Printf(格式字符串, arg列表)`
@@ -376,10 +330,7 @@ func main() {
}
```
-
-
-
-标记
+### 标记
```
+ 总打印数值的正负号;对于%q(%+q)保证只输出ASCII编码的字符。
@@ -396,10 +347,7 @@ func main() {
- 其中 `0` 和 `-` 不能同时使用,优先使用 `-` 而忽略 `0`。
- 标记有时会被占位符忽略,所以不要指望它们。例如十进制没有备用格式,因此 `%#d` 与 `%d` 的行为相同。
-
-
-
-宽度和精度
+### 宽度和精度
`[宽度][.精度]`都可以写成以下三种形式:`数值`,`*`,`arg索引*`
@@ -413,17 +361,11 @@ func main() {
- 精度值:对于浮点型,用于控制小数位数,对于字符串或字节数组,用于控制字符数量(不是字节数量)。
- 对于浮点型而言,动词 g/G 的精度值比较特殊,在适当的情况下,g/G 会设置总有效数字,而不是小数位数。
-
-
-
-arg 索引
+### arg 索引
由中括号和 arg 序号组成(就像这个实例`"abc%+ #8.3[3]vdef"`中的[3]),用于指定当前要处理的 arg 的序号,序号从 1 开始:`'[' + arg序号 + ']'`
-
-
-
-动词/通用动词
+### 动词/通用动词
- `v`:默认格式,不同类型的默认格式如下:
> 布尔型:`t`
@@ -440,17 +382,11 @@ func main() {
注意事项:`动词`不能省略,不同的数据类型支持的动词不一样。
-
-
-
-布尔型
+### 布尔型
-`t` :输出 true 或 false 字符串。
-
-
-
-整型
+### 整型
- `b/o/d`:输出 2/8/10 进制格式
- `x/X `:输出 16 进制格式(小写/大写)
@@ -464,20 +400,14 @@ func main() {
对于 U:
- 如果使用 "#" 标记,则会在 Unicode 码点后面添加相应的 '字符'(前提是该字符必须可显示)
-
-
-
-浮点型和复数型
+### 浮点型和复数型
- `b`:科学计数法(以 2 为底)
- `e/E`:科学计数法(以 10 为底,小写 e/大写 E)
- `f/F`:普通小数格式(两者无区别)
- `g/G`:大指数(指数 >= 6)使用 %e/%E,其它情况使用 %f/%F
-
-
-
-字符串或字节切片
+### 字符串或字节切片
- `s` :普通字符串
- `q` :双引号引起来的 Go 语法字符串
@@ -492,10 +422,7 @@ func main() {
- 如果使用了 " " 标记,则在每个元素之间添加空格。
- 如果使用了 "#" 标记,则在十六进制格式之前添加 0x 前缀。
-
-
-
-指针类型
+### 指针类型
- `p` :带 0x 前缀的十六进制地址值。
- `#p`:不带 0x 前缀的十六进制地址值。
@@ -541,10 +468,7 @@ func main() {
}
```
-
-
-
-复合类型
+### 复合类型
复合类型将使用不同的格式输出,格式如下:
@@ -558,10 +482,7 @@ func main() {
复合类型本身没有动词,动词将应用到复合类型的元素上。
结构体可以使用 "+v" 同时输出字段名。
-
-
-
-格式化输入
+### 格式化输入
```go
// 格式化输入:从输入端读取字符串(以空白分隔的值的序列),
@@ -580,12 +501,9 @@ Scanf(格式字符串, arg列表)
// Scan 类函数会返回已处理的 arg 数量和遇到的错误信息。
```
-
-
## 编程基础
-
-内置关键字
+### 内置关键字
```go
break default func interface select
@@ -595,10 +513,7 @@ const fallthrough if range type
continue for import return var
```
-
-
-
-预定义标识符
+### 预定义标识符
```go
append bool byte cap close complex complex64 complex128 uint16
@@ -607,18 +522,12 @@ int32 int64 iota len make new nil panic uint64
print println real recover string true uint uint8 uintptr
```
-
-
-
-行分隔符
+### 行分隔符
- 在 Go 程序中,一行代表一个语句结束,不需要分隔符。
- 打算将多个语句写在同一行,它们则必须使用 `;` 人为区分,并不鼓励这种做法。
-
-
-
-注释方法
+### 注释方法
```go
// 单行注释
@@ -628,10 +537,7 @@ print println real recover string true uint uint8 uintptr
*/
```
-
-
-
-标识符
+### 标识符
- 标识符用来命名变量、类型等程序实体。
- 第一个字符必须是字母或下划线而不能是数字
@@ -651,10 +557,7 @@ case #(Go 语言的关键字)
a+b #(运算符是不允许的)
```
-
-
-
-包引用 import
+### 包引用 import
```go
import "fmt"
@@ -698,10 +601,7 @@ main.go中如何调用add.go、subtract.go或者是multiply.go文件中的函数
> 要调用`multiply.go`中的函数,必须要引入包"multi",`import "package-demo/cal/multi"`
> Go中如果函数名的首字母大写,表示该函数是公有的,可以被其他程序调用,如果首字母小写,该函数就是是私有的
-
-
-
-包别名
+### 包别名
```go
import(
@@ -715,11 +615,7 @@ import ff "fmt"
ff.Println('Hello World!')
```
-
-
-
-
-省略调用
+### 省略调用
```go
import(
@@ -731,23 +627,16 @@ func main() {
}
```
-
-
-
-
-可见性规则
+### 可见性规则
Go语言中约定使用 **大小写** 来决定常量、变量、类型、接口、结构或函数是否可以被外部包所调用
- 函数名字首字母 **小写** 即为 `private` 私有的
- 函数名字首字母 **大写** 即为 `public` 公有
-
-
## 基本类型
-
-布尔型
+### 布尔型
```go
var b bool
@@ -761,10 +650,7 @@ fmt.Printf("e is of type %t\n", e)
- 取值范围:true/false
- 只能使用true/false值,不能使用数字代替布尔值
-
-
-
-整形 int/uint
+### 整形 int/uint
```go
package main
@@ -789,10 +675,7 @@ func main() {
- int/uint
- 根据平台可能为32/64位
-
-
-
-8位整型 int8/uint8
+### 8位整型 int8/uint8
```go
u8 := []uint8{98, 99}
@@ -813,10 +696,7 @@ fmt.Printf("%08b %d \n", e, e)
- 长度:1字节
- 取值范围:-128~127/0~255
-
-
-
-字节型 byte
+### 字节型 byte
```go
// 这里不能写成 b := []byte{"Golang"},这里是利用类型转换。
@@ -903,37 +783,25 @@ func main() {
}
```
-
-
-
-16位整型 int16/uint16
+### 16位整型 int16/uint16
- int16/uint16
- 长度:2字节
- 取值范围:-32768~32767/0~65535
-
-
-
-32位整型 int32(别名rune)/uint32
+### 32位整型 int32(别名rune)/uint32
- int32(别名rune)/uint32
- 长度:4字节
- 取值范围:-2^32/2~2^32/2-1/0~2^32-1
-
-
-
-64位整型 int64/uint64
+### 64位整型 int64/uint64
- int64/uint64
- 长度:8字节
- 取值范围:-2^64/2~2^64/2-1/0~2^64-1
-
-
-
-浮点型 float32/float64
+### 浮点型 float32/float64
```go
package main
@@ -960,18 +828,12 @@ func main() {
- 长度:4/8字节
- 小数位:精确到 7/15 位小数
-
-
-
-复数 complex64/complex128
+### 复数 complex64/complex128
- complex64/complex128
- 长度:8/16
-
-
-
-指针整数型 uintptr
+### 指针整数型 uintptr
用于指针运算,GC 不把 uintptr 当指针,uintptr 无法持有对象。uintptr 类型的目标会被回收。
@@ -1040,10 +902,7 @@ func main() {
}
```
-
-
-
-数组类型 array
+### 数组类型 array
数组声明语法
@@ -1129,10 +988,7 @@ a = [3][4]int{
int val = a[2][3]
```
-
-
-
-结构类型 struct
+### 结构类型 struct
```go
package main
@@ -1204,10 +1060,7 @@ The string is: Chris
**使用 new**
-
-
-
-字符串类型 string
+### 字符串类型 string
```go
var str string //声明一个字符串
@@ -1224,10 +1077,7 @@ len函数是Go中内置函数,不引入strings包即可使用。len(string)返
- len(map) 字典中元素个数,如果入参为nil则返回0
- len(Channel) Channel buffer队列中元素个数
-
-
-
-接口类型 inteface
+### 接口类型 inteface
```go
package main
@@ -1277,10 +1127,7 @@ func main() {
实例:[inteface.go](./example/inteface/inteface.go)
-
-
-
-函数类型 func
+### 函数类型 func
```go
package main
@@ -1301,11 +1148,7 @@ func main() {
实例:[func.go](./example/func/func.go)
-
-
-
-引用类型 func
-
+### 引用类型 func
**切片**
@@ -1370,10 +1213,7 @@ func removeColor(colors map[string]string, key string) {
- chan
-
-
-
-类型别名
+### 类型别名
```go
type (
@@ -1385,12 +1225,9 @@ var b 文本
b = "别名类型,可以是中文!"
```
-
-
## 常量变量
-
-常量 const
+### 常量 const
```go
package main
@@ -1439,10 +1276,7 @@ func main() {
}
```
-
-
-
-变量 var
+### 变量 var
```go
var (
@@ -1473,10 +1307,7 @@ var a, _, c, d int = 1, 2, 3, 4
- 所有变量都可以使用类型推断
- 局部变量不可以使用`var()`简写的形式
-
-
-
-变量的类型转换
+### 变量的类型转换
```go
// 只能类型显式转换
@@ -1486,10 +1317,7 @@ b := int(a)
// 不兼容的类型不能转换类型
```
-
-
-
-多变量声明
+### 多变量声明
```go
var x, y int
@@ -1506,12 +1334,9 @@ var e, f = 123, "hello"
//g, h := 123, "hello"
```
-
-
## 语言运算符
-
-算术运算符
+### 算术运算符
```go
package main
@@ -1549,10 +1374,7 @@ func main() {
| ++ | 自增 | A++ 输出结果 11 |
| -- | 自减 | A-- 输出结果 9 |
-
-
-
-关系运算符
+### 关系运算符
```go
package main
@@ -1599,10 +1421,7 @@ func main() {
| >= | 检查左边值是否大于等于右边值,如果是返回 True 否则返回 False。 | (A >= B) 为 False |
| <= | 检查左边值是否小于等于右边值,如果是返回 True 否则返回 False。 | A <= B) 为 True |
-
-
-
-逻辑运算符
+### 逻辑运算符
```go
package main
@@ -1638,10 +1457,7 @@ func main() {
| \|\| | 逻辑 OR 运算符。 如果两边的操作数有一个 True,则条件 True,否则为 False。| (A || B) 为 True |
| ! | 逻辑 NOT 运算符。 如果条件为 True,则逻辑 NOT 条件 False,否则为 True。 | !(A && B) 为 True |
-
-
-
-位运算符
+### 位运算符
```go
package main
@@ -1679,10 +1495,7 @@ Go 语言支持的位运算符如下表所示。假定 A 为60,B 为13:
| << | 左移运算符"<<"是双目运算符。左移n位就是乘以2的n次方。 其功能把"<<"左边的运算数的各二进位全部左移若干位,由"<<"右边的数指定移动的位数,高位丢弃,低位补0。 | A << 2 结果为 240 ,二进制为 1111 0000 |
| >> | 右移运算符">>"是双目运算符。右移n位就是除以2的n次方。 其功能是把">>"左边的运算数的各二进位全部右移若干位,">>"右边的数指定移动的位数。| A >> 2 结果为 15 ,二进制为 0000 1111 |
-
-
-
-赋值运算符
+### 赋值运算符
```go
package main
@@ -1739,10 +1552,7 @@ func main() {
| ^= | 按位异或后赋值s | C ^= 2 等于 C = C ^ 2 |
| \|= | 按位或后赋值s | C \|= 2 等于 C = C \| 2 |
-
-
-
-其他运算符
+### 其他运算符
```go
package main
@@ -1770,10 +1580,7 @@ func main() {
| & | 返回变量存储地址 | &a; 将给出变量的实际地址。 |
| * | 指针变量。 | *a; 是一个指针变量 |
-
-
-
-运算符优先级
+### 运算符优先级
```go
package main
@@ -1808,12 +1615,9 @@ func main() {
| 2 | && |
| 1 | \|\| |
-
-
## 流程控制语句
-
-for 循环语句
+### for 循环语句
```go
package main
@@ -1843,10 +1647,7 @@ func main() {
1. 循环条件表达式:每轮迭代开始前被求值
1. 后置语句:每轮迭代后被执行
-
-
-
-if 语句
+### if 语句
```go
package main
@@ -1890,10 +1691,7 @@ func main() {
}
```
-
-
-
-if 和 else 语句
+### if 和 else 语句
```go
package main
@@ -1922,10 +1720,7 @@ func main() {
在 if 的便捷语句定义的变量同样可以在任何对应的 else 块中使用。
-
-
-
-switch 语句
+### switch 语句
```go
package main
@@ -1995,10 +1790,7 @@ func main() {
}
```
-
-
-
-defer 语句
+### defer 语句
```go
package main
@@ -2036,8 +1828,7 @@ func main() {
## 结构体
-
-结构体字段
+### 结构体字段
结构体字段使用点号来访问。
@@ -2055,10 +1846,7 @@ func main() {
}
```
-
-
-
-结构体指针
+### 结构体指针
结构体指针使用 & 来访问。
@@ -2078,10 +1866,7 @@ func main() {
```
-
-
-
-结构体文法
+### 结构体文法
> 结构体文法表示通过结构体字段的值作为列表来新分配一个结构体。
> 使用 Name: 语法可以仅列出部分字段。(字段名的顺序无关。)
From 52c3fcbf190cddeb5abb585cd08e8cc5b8bb8a15 Mon Sep 17 00:00:00 2001
From: jaywcjlove <398188662@qq.com>
Date: Wed, 6 Jul 2022 19:39:56 +0800
Subject: [PATCH 05/11] chore: update README.md
---
README.md | 226 +++++++++++++++++++--------------------
example/defer/defer.go | 54 +++++-----
example/module/README.md | 18 ++--
example/module/go.mod | 58 +++++-----
example/module/main.go | 30 +++---
5 files changed, 190 insertions(+), 196 deletions(-)
diff --git a/README.md b/README.md
index cff2c71..ae9f0d4 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,7 @@ Go语言快速入门
[](https://github.com/jaywcjlove/golang-tutorial/actions/workflows/ci.yml)
+
通过简单的例子,来快速入门Go语言基础编程、语法等各种语言特性,主要面向新手级别的学习者。下面所有例子均来源于网络,看文需谨慎后果自负。
@@ -22,6 +23,7 @@ Go语言快速入门
---
- [安装Go](#安装go)
+- [卸载Go](#卸载go)
- [运行Go](#运行go)
- [格式化输入输出](#格式化输入输出)
- [编程基础](#编程基础)
@@ -48,10 +50,12 @@ yum install golang
```bash
# 源码下载
# 官网源码 https://golang.org/dl/ 需要翻墙
-wget https://storage.googleapis.com/golang/go1.9.darwin-amd64.pkg
-tar zxvf go1.8.linux-amd64.tar.gz -C /usr/local
-# 新建GOPATH目录
-mkdir -p $HOME/gopath
+wget https://storage.googleapis.com/golang/go1.18.3.linux-amd64.tar.gz
+$ rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.3.linux-amd64.tar.gz
+```
+
+```bash
+export PATH=$PATH:/usr/local/go/bin
```
### Mac中通过brew命令安装
@@ -81,27 +85,44 @@ brew upgrade go # 更新 go
```bash
→ go env
-GOARCH="amd64"
+GO111MODULE=""
+GOARCH="arm64"
GOBIN=""
+GOCACHE="/Users/wangchujiang/Library/Caches/go-build"
+GOENV="/Users/wangchujiang/Library/Application Support/go/env"
GOEXE=""
-GOHOSTARCH="amd64"
+GOEXPERIMENT=""
+GOFLAGS=""
+GOHOSTARCH="arm64"
GOHOSTOS="darwin"
+GOINSECURE=""
+GOMODCACHE="/Users/wangchujiang/go/pkg/mod"
+GONOPROXY=""
+GONOSUMDB=""
GOOS="darwin"
-GOPATH="/Users/kenny/go"
-GORACE=""
-GOROOT="/usr/local/Cellar/go/1.9/libexec"
-GOTOOLDIR="/usr/local/Cellar/go/1.9/libexec/pkg/tool/darwin_amd64"
+GOPATH="/Users/wangchujiang/go"
+GOPRIVATE=""
+GOPROXY="https://proxy.golang.org,direct"
+GOROOT="/usr/local/go"
+GOSUMDB="sum.golang.org"
+GOTMPDIR=""
+GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
+GOVCS=""
+GOVERSION="go1.18.3"
GCCGO="gccgo"
+AR="ar"
CC="clang"
-GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/j7/3xly5sk567s65ny5dnr__3b80000gn/T/go-build377856897=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
+GOMOD="/dev/null"
+GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
+GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rn/jv6_kn5j2wv1whyj3pqvpxbw0000gn/T/go-build947462154=/tmp/go-build -gno-record-gcc-switches -fno-common"
```
如果需要修改默认的环境变量配置修改 `vim ~/.bash_profile` 或者 `vim ~/.zshrc`
@@ -131,85 +152,59 @@ source /etc/profile
```bash
→ go --help
-Go is a tool for managing Go source code.
-Go是用于管理Go源代码的工具。
-
-Usage用法:
- go command [arguments]
-
-The commands are:
-
- build 命令用于编译我们指定的源码文件或代码包以及它们的依赖包。
- -o 指定输出的文件名,可以带上路径,例如 go build -o a/b/c
- -i 安装相应的包,编译+go install
- -a 更新全部已经是最新的包的,但是对标准包不适用
- -n 把需要执行的编译命令打印出来,但是不执行,这样就可以很容易的知道底层是如何运行的
- -p n 指定可以并行可运行的编译数目,默认是CPU数目
- -race 开启编译的时候自动检测数据竞争的情况,目前只支持64位的机器
- -v 打印出来我们正在编译的包名
- -work 打印出来编译时候的临时文件夹名称,并且如果已经存在的话就不要删除
- -x 打印出来执行的命令,其实就是和-n的结果类似,只是这个会执行
- -ccflags 'arg list' 传递参数给5c, 6c, 8c 调用
- -compiler name 指定相应的编译器,gccgo还是gc
- -gccgoflags 'arg list' 传递参数给gccgo编译连接调用
- -gcflags 'arg list' 传递参数给5g, 6g, 8g 调用
- -installsuffix suffix 为了和默认的安装包区别开来,采用这个前缀来重新安装那些依赖的包,-race的时候默认已经是-installsuffix race,大家可以通过-n命令来验证
- -ldflags 'flag list' 传递参数给5l, 6l, 8l 调用
- -tags 'tag list' 设置在编译的时候可以适配的那些tag,详细的tag限制参考里面的http://golang.org/pkg/go/build/
- clean 删除掉执行其它命令时产生的一些文件和目录。
- -i 清除关联的安装的包和可运行文件,也就是通过go install安装的文件
- -n 把需要执行的清除命令打印出来,但是不执行,这样就可以很容易的知道底层是如何运行的
- -r 循环的清除在import中引入的包
- -x 打印出来执行的详细命令,其实就是-n打印的执行版本
- doc 命令可以打印附于Go语言程序实体上的文档。
- env 用于打印Go语言的环境信息。
- bug 启动错误报告。
- fix 把指定代码包的所有Go语言源码文件中的旧版本代码修正为新版本的代码。
- fmt 在包源上运行gofmt。
- -l 显示那些需要格式化的文件
- -w 把改写后的内容直接写入到文件中,而不是作为结果打印到标准输出。
- -r 添加形如“a[b:len(a)] -> a[b:]”的重写规则,方便我们做批量替换
- -s 简化文件中的代码
- -d 显示格式化前后的diff而不是写入文件,默认是false
- -e 打印所有的语法错误到标准输出。如果不使用此标记,则只会打印不同行的前10个错误。
- -cpuprofile 支持调试模式,写入相应的cpufile到指定的文件
- generate 通过处理源生成Go文件。
- get 下载或更新安装指定的代码包及其依赖包,并对它们进行编译和安装。
- -d 只下载不安装
- -f 只有在你包含了-u参数的时候才有效,不让-u去验证import中的每一个都已经获取了,这对于本地fork的包特别有用
- -fix 在获取源码之后先运行fix,然后再去做其他的事情
- -t 同时也下载需要为运行测试所需要的包
- -u 强制使用网络去更新包和它的依赖包
- -v 显示执行的命令
- install 用于编译并安装指定的代码包及它们的依赖包。
- list 列出指定的代码包的信息。
- run 命令可以编译并运行命令源码文件。
- test 对Go语言编写的程序进行测试。
- -bench regexp 执行相应的benchmarks,例如 -bench=.
- -cover 开启测试覆盖率
- -run regexp 只运行regexp匹配的函数,例如 -run=Array 那么就执行包含有Array开头的函数
- -v 显示测试的详细命令
- tool 运行指定的go工具
- go tool fix . 用来修复以前老版本的代码到新版本,例如go1之前老版本的代码转化到go1,例如API的变化
- go tool vet directory|files 用来分析当前目录的代码是否都是正确的代码,例如是不是调用fmt.Printf里面的参数不正确,例如函数里面提前return了然后出现了无用代码之类的。
- version 打印Go的版本信息
- vet 用于检查Go语言源码中静态错误的简单工具。
-
-Use "go help [command]" for more information about a command.
-
-Additional help topics:
-
- c calling between Go and C
- buildmode description of build modes
- filetype file types
- gopath GOPATH environment variable
- environment environment variables
- importpath import path syntax
- packages description of package lists
- testflag description of testing flags
- testfunc description of testing functions
-
-Use "go help [topic]" for more information about that topic.
+
+Go 是一个管理 Go 源代码的工具。
+
+用法:
+
+ go [arguments]
+
+命令是:
+
+ bug 开始一个错误报告。 start a bug report
+ build 编译包和依赖。 compile packages and dependencies
+ clean 删除目标文件和缓存文件。 remove object files and cached files
+ doc 显示包或符号的文档。 show documentation for package or symbol
+ env 打印Go环境信息。 print Go environment information
+ fix 更新软件包以使用新的 API。 update packages to use new APIs
+ fmt gofmt(重新格式化)包源。 gofmt (reformat) package sources
+ generate 通过处理源生成 Go 文件。 generate Go files by processing source
+ get 将依赖项添加到当前模块并安装它们。 add dependencies to current module and install them
+ install 编译和安装包和依赖项。 compile and install packages and dependencies
+ list 列出包或模块。 list packages or modules
+ mod 模块维护。 module maintenance
+ work 工作空间维护。 workspace maintenance
+ run 编译并运行 Go 程序。 compile and run Go program
+ test 测试包。 test packages
+ tool 运行指定的 go 工具。 run specified go tool
+ version 打印 Go 版本。 print Go version
+ vet 报告包中可能出现的错误。 report likely mistakes in packages
+
+使用“go help ”获取有关命令的更多信息。
+
+其他帮助主题:
+
+ buildconstraint 构建约束。 build constraints
+ buildmode 构建模式。 build modes
+ c Go 和 C 之间的调用。 calling between Go and C
+ cache 构建和测试缓存。 build and test caching
+ environment 环境变量。 environment variables
+ filetype 文件类型。 file types
+ go.mod go.mod 文件。 the go.mod file
+ gopath GOPATH 环境变量。 GOPATH environment variable
+ gopath-get 遗留的 GOPATH 去获取。 legacy GOPATH go get
+ goproxy 模块代理协议。 module proxy protocol
+ importpath 导入路径语法。 import path syntax
+ modules 模块、模块版本等。 modules, module versions, and more
+ module-get 模块感知 go get。 module-aware go get
+ module-auth 使用 go.sum 进行模块认证。 module authentication using go.sum
+ packages 包装清单和模式。 package lists and patterns
+ private 下载非公开代码的配置。 configuration for downloading non-public code
+ testflag 测试标志。 testing flags
+ testfunc 测试功能。 testing functions
+ vcs 使用 GOVCS 控制版本控制。 controlling version control with GOVCS
+
+Use "go help " for more information about that topic.
```
其它命令
@@ -264,8 +259,7 @@ govendor test +local
- 删除 Go 的安装文件目录,这通常是在 `Linux`,`macOS` 和 `FreeBSD` 下的 `/usr/local/` go 或者在 Windows 下的 `c:\Go` 下。
- 同时删除环境变量, `Linux` 和 `FreeBSD` 编辑 `/etc/profile` 或者 `$HOME/.profile`。
-- 如果你是 `macOS` 你需要删除 `/etc/paths.d/go` 文件。
-
+- 如果你是 `macOS` 你需要删除 `/etc/paths.d/go`,`/usr/local/go` 文件。
## 运行Go
@@ -456,15 +450,15 @@ fmt.Println(*p) // 通过指针 p 读取 i
package main
import "fmt"
func main() {
- i, j := 42, 2701
- p := &i // 指向我 i
- fmt.Println(*p) // 通过指针读 i
- *p = 21 // 通过指针设置 i
- fmt.Println(i) // 看到i的新值
-
- p = &j // 指向我 j
- *p = *p / 37 // 通过指针划分 j
- fmt.Println(j) // 看到j的新值
+ i, j := 42, 2701
+ p := &i // 指向我 i
+ fmt.Println(*p) // 通过指针读 i
+ *p = 21 // 通过指针设置 i
+ fmt.Println(i) // 看到i的新值
+
+ p = &j // 指向我 j
+ *p = *p / 37 // 通过指针划分 j
+ fmt.Println(j) // 看到j的新值
}
```
@@ -994,21 +988,21 @@ int val = a[2][3]
package main
import "fmt"
type Vertex struct {
- X int
- Y int
+ X int
+ Y int
}
func main() {
fmt.Println(Vertex{1, 2})
// 结构体字段使用点号来访问。
- v := Vertex{1, 2}
- v.X = 4
+ v := Vertex{1, 2}
+ v.X = 4
fmt.Println(v.X)
// 结构体字段可以通过结构体指针来访问。
- e := Vertex{1, 2}
- p := &e
- p.X = 1e9
+ e := Vertex{1, 2}
+ p := &e
+ p.X = 1e9
fmt.Println(e)
@@ -1454,8 +1448,8 @@ func main() {
| 运算符 | 描述 | 实例 |
| ---- | ---- | ---- |
| && | 逻辑 AND 运算符。 如果两边的操作数都是 True,则条件 True,否则为 False。 | (A && B) 为 False |
-| \|\| | 逻辑 OR 运算符。 如果两边的操作数有一个 True,则条件 True,否则为 False。| (A || B) 为 True |
-| ! | 逻辑 NOT 运算符。 如果条件为 True,则逻辑 NOT 条件 False,否则为 True。 | !(A && B) 为 True |
+| \|\| | 逻辑 OR 运算符。 如果两边的操作数有一个 True,则条件 True,否则为 False。| (A || B) 为 True |
+| ! | 逻辑 NOT 运算符。 如果条件为 True,则逻辑 NOT 条件 False,否则为 True。 | !(A && B) 为 True |
### 位运算符
@@ -1464,8 +1458,8 @@ package main
import "fmt"
func main() {
- var a uint = 60 /* 60 = 0011 1100 */
- var b uint = 13 /* 13 = 0000 1101 */
+ var a uint = 60 /* 60 = 0011 1100 */
+ var b uint = 13 /* 13 = 0000 1101 */
var c uint = 0
c = a & b /* 12 = 0000 1100 */
@@ -1489,9 +1483,9 @@ Go 语言支持的位运算符如下表所示。假定 A 为60,B 为13:
| 运算符 | 描述 | 实例 |
| ---- | ---- | ---- |
-| & | 按位与运算符"&"是双目运算符。 其功能是参与运算的两数各对应的二进位相与。 | (A & B) 结果为 12, 二进制为 0000 1100 |
-| \| | 按位或运算符 \| 是双目运算符。 其功能是参与运算的两数各对应的二进位相或。 | (A \| B) 结果为 61, 二进制为 0011 1101 |
-| ^ | 按位异或运算符"^"是双目运算符。 其功能是参与运算的两数各对应的二进位相异或,当两对应的二进位相异时,结果为1。 | (A ^ B) 结果为 49, 二进制为 0011 0001 |
+| & | 按位与运算符"&"是双目运算符。 其功能是参与运算的两数各对应的二进位相与。 | (A & B) 结果为 12, 二进制为 0000 1100 |
+| \| | 按位或运算符 \| 是双目运算符。 其功能是参与运算的两数各对应的二进位相或。 | (A \| B) 结果为 61, 二进制为 0011 1101 |
+| ^ | 按位异或运算符"^"是双目运算符。 其功能是参与运算的两数各对应的二进位相异或,当两对应的二进位相异时,结果为1。 | (A ^ B) 结果为 49, 二进制为 0011 0001 |
| << | 左移运算符"<<"是双目运算符。左移n位就是乘以2的n次方。 其功能把"<<"左边的运算数的各二进位全部左移若干位,由"<<"右边的数指定移动的位数,高位丢弃,低位补0。 | A << 2 结果为 240 ,二进制为 1111 0000 |
| >> | 右移运算符">>"是双目运算符。右移n位就是除以2的n次方。 其功能是把">>"左边的运算数的各二进位全部右移若干位,">>"右边的数指定移动的位数。| A >> 2 结果为 15 ,二进制为 0000 1111 |
@@ -1569,7 +1563,7 @@ func main() {
fmt.Printf("第 3 行 - c 变量类型为 = %T\n", c ); // 第 3 行 - c 变量类型为 = float32
/* & 和 * 运算符实例 */
- ptr = &a /* 'ptr' 包含了 'a' 变量的地址 */
+ ptr = &a /* 'ptr' 包含了 'a' 变量的地址 */
fmt.Printf("a 的值为 %d\n", a); // a 的值为 4
fmt.Printf("*ptr 为 %d\n", *ptr); // *ptr 为 4
}
diff --git a/example/defer/defer.go b/example/defer/defer.go
index 6aa6efa..00ce52e 100644
--- a/example/defer/defer.go
+++ b/example/defer/defer.go
@@ -1,33 +1,33 @@
package main
import "fmt"
func main() {
- // 2. 在输出 world
- defer fmt.Println("world")
- // 1. 先输出 hello
- fmt.Println("hello")
- // 输出结果
- // =======
- // hello
- // world
+ // 2. 在输出 world
+ defer fmt.Println("world")
+ // 1. 先输出 hello
+ fmt.Println("hello")
+ // 输出结果
+ // =======
+ // hello
+ // world
- fmt.Println("counting")
- for i := 0; i < 10; i++ {
- defer fmt.Println(i)
- }
- fmt.Println("done")
- // 输出结果
- // =======
- // counting
- // done
- // 9
- // 8
- // 7
- // 6
- // 5
- // 4
- // 3
- // 2
- // 1
- // 0
+ fmt.Println("counting")
+ for i := 0; i < 10; i++ {
+ defer fmt.Println(i)
+ }
+ fmt.Println("done")
+ // 输出结果
+ // =======
+ // counting
+ // done
+ // 9
+ // 8
+ // 7
+ // 6
+ // 5
+ // 4
+ // 3
+ // 2
+ // 1
+ // 0
}
\ No newline at end of file
diff --git a/example/module/README.md b/example/module/README.md
index ba1c195..45a33e7 100644
--- a/example/module/README.md
+++ b/example/module/README.md
@@ -44,18 +44,18 @@ go help mod
Usage:
- go mod [arguments]
+ go mod [arguments]
The commands are:
- download download modules to local cache
- edit edit go.mod from tools or scripts
- graph print module requirement graph
- init initialize new module in current directory
- tidy add missing and remove unused modules
- vendor make vendored copy of dependencies
- verify verify dependencies have expected content
- why explain why packages or modules are needed
+ download download modules to local cache
+ edit edit go.mod from tools or scripts
+ graph print module requirement graph
+ init initialize new module in current directory
+ tidy add missing and remove unused modules
+ vendor make vendored copy of dependencies
+ verify verify dependencies have expected content
+ why explain why packages or modules are needed
Use "go help mod " for more information about a command.
```
diff --git a/example/module/go.mod b/example/module/go.mod
index 8e4b6ce..e67da1e 100644
--- a/example/module/go.mod
+++ b/example/module/go.mod
@@ -3,36 +3,36 @@ module mod2
go 1.17
require (
- github.com/gin-contrib/sse v0.1.0 // indirect
- github.com/gin-gonic/gin v1.7.7
- github.com/golang/protobuf v1.3.3 // indirect
- github.com/json-iterator/go v1.1.9 // indirect
- github.com/mattn/go-isatty v0.0.12 // indirect
- github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
- github.com/modern-go/reflect2 v1.0.1 // indirect
- github.com/stretchr/testify v1.4.0 // indirect
- github.com/ugorji/go/codec v1.1.7 // indirect
- golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // indirect
- golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
- golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect
- gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
- gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
- gopkg.in/yaml.v2 v2.2.8 // indirect
+ github.com/gin-contrib/sse v0.1.0 // indirect
+ github.com/gin-gonic/gin v1.7.7
+ github.com/golang/protobuf v1.3.3 // indirect
+ github.com/json-iterator/go v1.1.9 // indirect
+ github.com/mattn/go-isatty v0.0.12 // indirect
+ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+ github.com/modern-go/reflect2 v1.0.1 // indirect
+ github.com/stretchr/testify v1.4.0 // indirect
+ github.com/ugorji/go/codec v1.1.7 // indirect
+ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // indirect
+ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
+ golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect
+ gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
+ gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
+ gopkg.in/yaml.v2 v2.2.8 // indirect
)
require (
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/go-playground/assert/v2 v2.0.1 // indirect
- github.com/go-playground/locales v0.13.0 // indirect
- github.com/go-playground/universal-translator v0.17.0 // indirect
- github.com/go-playground/validator/v10 v10.4.1 // indirect
- github.com/google/gofuzz v1.0.0 // indirect
- github.com/leodido/go-urn v1.2.0 // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
- github.com/stretchr/objx v0.1.0 // indirect
- github.com/ugorji/go v1.1.7 // indirect
- golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
- golang.org/x/text v0.3.2 // indirect
- golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e // indirect
- gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 // indirect
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/go-playground/assert/v2 v2.0.1 // indirect
+ github.com/go-playground/locales v0.13.0 // indirect
+ github.com/go-playground/universal-translator v0.17.0 // indirect
+ github.com/go-playground/validator/v10 v10.4.1 // indirect
+ github.com/google/gofuzz v1.0.0 // indirect
+ github.com/leodido/go-urn v1.2.0 // indirect
+ github.com/pmezard/go-difflib v1.0.0 // indirect
+ github.com/stretchr/objx v0.1.0 // indirect
+ github.com/ugorji/go v1.1.7 // indirect
+ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
+ golang.org/x/text v0.3.2 // indirect
+ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e // indirect
+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 // indirect
)
diff --git a/example/module/main.go b/example/module/main.go
index daa6497..11e417a 100644
--- a/example/module/main.go
+++ b/example/module/main.go
@@ -2,10 +2,10 @@ package main
import (
- "html/template"
- "log"
- "os"
- "github.com/gin-gonic/gin"
+ "html/template"
+ "log"
+ "os"
+ "github.com/gin-gonic/gin"
)
var html = template.Must(template.New("https").Parse(`
@@ -21,18 +21,18 @@ var html = template.Must(template.New("https").Parse(`
func main() {
- logger := log.New(os.Stderr, "", 0)
- logger.Println("[WARNING] DON'T USE THE EMBED CERTS FROM THIS EXAMPLE IN PRODUCTION ENVIRONMENT, GENERATE YOUR OWN!")
+ logger := log.New(os.Stderr, "", 0)
+ logger.Println("[WARNING] DON'T USE THE EMBED CERTS FROM THIS EXAMPLE IN PRODUCTION ENVIRONMENT, GENERATE YOUR OWN!")
- r := gin.Default()
- r.SetHTMLTemplate(html)
+ r := gin.Default()
+ r.SetHTMLTemplate(html)
- r.GET("/", func(c *gin.Context) {
- c.HTML(200, "https", gin.H{
- "status": "success",
- })
- })
+ r.GET("/", func(c *gin.Context) {
+ c.HTML(200, "https", gin.H{
+ "status": "success",
+ })
+ })
- // Listen and Server in https://127.0.0.1:8080
- r.Run(":8083")
+ // Listen and Server in https://127.0.0.1:8080
+ r.Run(":8083")
}
\ No newline at end of file
From d0e4bd894dad806daf345ccc1d111b20aeb9ab04 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Wed, 6 Jul 2022 19:41:56 +0800
Subject: [PATCH 06/11] fix(deps): update module github.com/gin-gonic/gin to
v1.8.1 (#7)
---
example/module/go.mod | 61 +++++++++++++++++++++--------------------
example/module/go.sum | 63 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+), 29 deletions(-)
diff --git a/example/module/go.mod b/example/module/go.mod
index e67da1e..d071913 100644
--- a/example/module/go.mod
+++ b/example/module/go.mod
@@ -3,36 +3,39 @@ module mod2
go 1.17
require (
- github.com/gin-contrib/sse v0.1.0 // indirect
- github.com/gin-gonic/gin v1.7.7
- github.com/golang/protobuf v1.3.3 // indirect
- github.com/json-iterator/go v1.1.9 // indirect
- github.com/mattn/go-isatty v0.0.12 // indirect
- github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
- github.com/modern-go/reflect2 v1.0.1 // indirect
- github.com/stretchr/testify v1.4.0 // indirect
- github.com/ugorji/go/codec v1.1.7 // indirect
- golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // indirect
- golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
- golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect
- gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
- gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
- gopkg.in/yaml.v2 v2.2.8 // indirect
+ github.com/gin-contrib/sse v0.1.0 // indirect
+ github.com/gin-gonic/gin v1.8.1
+ github.com/golang/protobuf v1.5.0 // indirect
+ github.com/json-iterator/go v1.1.12 // indirect
+ github.com/mattn/go-isatty v0.0.14 // indirect
+ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+ github.com/modern-go/reflect2 v1.0.2 // indirect
+ github.com/stretchr/testify v1.7.1 // indirect
+ github.com/ugorji/go/codec v1.2.7 // indirect
+ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
+ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
+ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 // indirect
+ gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
+ gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
+ gopkg.in/yaml.v2 v2.4.0 // indirect
)
require (
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/go-playground/assert/v2 v2.0.1 // indirect
- github.com/go-playground/locales v0.13.0 // indirect
- github.com/go-playground/universal-translator v0.17.0 // indirect
- github.com/go-playground/validator/v10 v10.4.1 // indirect
- github.com/google/gofuzz v1.0.0 // indirect
- github.com/leodido/go-urn v1.2.0 // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
- github.com/stretchr/objx v0.1.0 // indirect
- github.com/ugorji/go v1.1.7 // indirect
- golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
- golang.org/x/text v0.3.2 // indirect
- golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e // indirect
- gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 // indirect
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/go-playground/assert/v2 v2.0.1 // indirect
+ github.com/go-playground/locales v0.14.0 // indirect
+ github.com/go-playground/universal-translator v0.18.0 // indirect
+ github.com/go-playground/validator/v10 v10.10.0 // indirect
+ github.com/goccy/go-json v0.9.7 // indirect
+ github.com/google/gofuzz v1.0.0 // indirect
+ github.com/leodido/go-urn v1.2.1 // indirect
+ github.com/pelletier/go-toml/v2 v2.0.1 // indirect
+ github.com/pmezard/go-difflib v1.0.0 // indirect
+ github.com/stretchr/objx v0.1.0 // indirect
+ github.com/ugorji/go v1.2.7 // indirect
+ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
+ golang.org/x/text v0.3.6 // indirect
+ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e // indirect
+ google.golang.org/protobuf v1.28.0 // indirect
+ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
diff --git a/example/module/go.sum b/example/module/go.sum
index 55807b1..2ef0fa6 100644
--- a/example/module/go.sum
+++ b/example/module/go.sum
@@ -1,3 +1,4 @@
+github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -11,52 +12,94 @@ github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=
github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs=
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
+github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8=
+github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
+github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
+github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
+github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
+github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
+github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0=
+github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
+github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM=
+github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
+github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
+github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
+github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
+github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
+github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
+github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU=
+github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
+github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
+github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
+github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
+github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 h1:EICbibRW4JNKMcY+LsWmuwob+CRS1BmdRdjphAm9mH4=
github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
+github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
+github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
+golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20190110200230-915654e7eabc h1:Yx9JGxI1SBhVLFjpAkWMaO1TF+xyqtHLjZpvQboJGiM=
golang.org/x/net v0.0.0-20190110200230-915654e7eabc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190116161447-11f53e031339 h1:g/Jesu8+QLnA0CPzF3E1pURg0Byr7i6jLoX5sqjcAh0=
@@ -65,11 +108,27 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 h1:siQdpVirKtzPhKl3lZWozZraCFObP8S1v6PRp0bLrtU=
+golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
+google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
+gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ=
@@ -78,3 +137,7 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
From b55f06d0d4abf320d2a2b8245aa6265294ac6ef9 Mon Sep 17 00:00:00 2001
From: jaywcjlove <398188662@qq.com>
Date: Wed, 6 Jul 2022 22:09:17 +0800
Subject: [PATCH 07/11] chore: add idoc.yml
---
idoc.yml | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 idoc.yml
diff --git a/idoc.yml b/idoc.yml
new file mode 100644
index 0000000..92e3464
--- /dev/null
+++ b/idoc.yml
@@ -0,0 +1,13 @@
+menus:
+ 首页: index.html
+ 官方文档:
+ url: https://golang.org
+ target: __blank
+
+editButton:
+ label: GitHub 上编辑此页
+ url: https://github.com/jaywcjlove/golang-tutorial/blob/master/
+
+footer: |
+ Released under the MIT License. Copyright © 2022 Kenny Wong
+ Generated by idoc v{{idocVersion}}
\ No newline at end of file
From c06853119a59bea454e961e8d95db1808e1de518 Mon Sep 17 00:00:00 2001
From: Chunyao Chan <24861096+Civon@users.noreply.github.com>
Date: Fri, 12 May 2023 13:01:02 +0800
Subject: [PATCH 08/11] fix: fix typo (#11)
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index ae9f0d4..56841cd 100644
--- a/README.md
+++ b/README.md
@@ -1350,9 +1350,9 @@ func main() {
c = a % b
fmt.Printf("第五行 - c 的值为 %d\n", c ) // 第五行 - c 的值为 1
a++
- fmt.Printf("第六行 - c 的值为 %d\n", a ) // 第六行 - c 的值为 22
+ fmt.Printf("第六行 - a 的值为 %d\n", a ) // 第六行 - a 的值为 22
a--
- fmt.Printf("第七行 - c 的值为 %d\n", a ) // 第七行 - c 的值为 21
+ fmt.Printf("第七行 - a 的值为 %d\n", a ) // 第七行 - a 的值为 21
}
```
From 4369faef360c57acead670f63430ab2993a2acf4 Mon Sep 17 00:00:00 2001
From: jaywcjlove <398188662@qq.com>
Date: Fri, 12 May 2023 13:03:20 +0800
Subject: [PATCH 09/11] ci: update workflows config.
---
.github/workflows/ci.yml | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d301d5c..8d0e88b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -6,12 +6,13 @@ on:
jobs:
website:
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
+ registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm run build
@@ -29,13 +30,13 @@ jobs:
- name: Create Tag
id: create_tag
- uses: jaywcjlove/create-tag-action@v1.3.7
+ uses: jaywcjlove/create-tag-action@main
with:
package-path: ./package.json
- name: get tag version
id: tag_version
- uses: jaywcjlove/changelog-generator@v1.5.7
+ uses: jaywcjlove/changelog-generator@main
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
@@ -48,7 +49,7 @@ jobs:
- name: Generate Changelog
id: changelog
- uses: jaywcjlove/changelog-generator@v1.5.7
+ uses: jaywcjlove/changelog-generator@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
filter-author: (jaywcjlove|小弟调调™|dependabot\[bot\]|Renovate Bot)
From fbff7b43149973af4d1a4f73082f65f50ac261a3 Mon Sep 17 00:00:00 2001
From: jaywcjlove <398188662@qq.com>
Date: Wed, 29 Nov 2023 21:28:54 +0800
Subject: [PATCH 10/11] chore: add sponsor badge.
---
.github/FUNDING.yml | 9 +++++++++
.github/workflows/ci.yml | 4 +++-
README.md | 1 +
idoc.yml | 1 +
4 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 .github/FUNDING.yml
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..021de74
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,9 @@
+# These are supported funding model platforms
+
+# github: [jaywcjlove]
+# patreon: # Replace with a single Patreon username
+# open_collective: # Replace with a single Open Collective username
+# ko_fi: # Replace with a single Ko-fi username
+# tidelift: #npm/xxxx
+# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+custom: https://jaywcjlove.github.io/#/sponsor
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8d0e88b..ec91418 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
- node-version: 16
+ node-version: 18
registry-url: 'https://registry.npmjs.org'
- run: npm install
@@ -63,6 +63,8 @@ jobs:
name: ${{ steps.create_tag.outputs.version }}
tag: ${{ steps.create_tag.outputs.version }}
body: |
+ [](https://jaywcjlove.github.io/#/sponsor)
+
Documentation ${{ steps.changelog.outputs.tag }}: https://raw.githack.com/jaywcjlove/golang-tutorial/${{ steps.changelog.outputs.gh-pages-short-hash }}/index.html
Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
diff --git a/README.md b/README.md
index 56841cd..7d388d8 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@ Go语言快速入门
===
+[](https://jaywcjlove.github.io/#/sponsor)
[](https://github.com/jaywcjlove/golang-tutorial/actions/workflows/ci.yml)

diff --git a/idoc.yml b/idoc.yml
index 92e3464..fbb8a4b 100644
--- a/idoc.yml
+++ b/idoc.yml
@@ -3,6 +3,7 @@ menus:
官方文档:
url: https://golang.org
target: __blank
+ 赞助: https://jaywcjlove.github.io/#/sponsor
editButton:
label: GitHub 上编辑此页
From e95ba478a8d4505980140cb55b57b3553dc131e7 Mon Sep 17 00:00:00 2001
From: jaywcjlove <398188662@qq.com>
Date: Sun, 23 Jun 2024 15:49:02 +0800
Subject: [PATCH 11/11] ci: update workflows config.
---
.github/FUNDING.yml | 12 +++---------
.github/workflows/ci.yml | 9 +++++----
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 021de74..abe8b76 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1,9 +1,3 @@
-# These are supported funding model platforms
-
-# github: [jaywcjlove]
-# patreon: # Replace with a single Patreon username
-# open_collective: # Replace with a single Open Collective username
-# ko_fi: # Replace with a single Ko-fi username
-# tidelift: #npm/xxxx
-# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
-custom: https://jaywcjlove.github.io/#/sponsor
+ko_fi: jaywcjlove
+buy_me_a_coffee: jaywcjlove
+custom: ["https://www.paypal.me/kennyiseeyou", "https://jaywcjlove.github.io/#/sponsor"]
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ec91418..f884921 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,10 +8,10 @@ jobs:
website:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-node@v3
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
with:
- node-version: 18
+ node-version: 20
registry-url: 'https://registry.npmjs.org'
- run: npm install
@@ -39,7 +39,7 @@ jobs:
uses: jaywcjlove/changelog-generator@main
- name: Deploy
- uses: peaceiris/actions-gh-pages@v3
+ uses: peaceiris/actions-gh-pages@v4
with:
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
@@ -59,6 +59,7 @@ jobs:
uses: ncipollo/release-action@v1
if: steps.create_tag.outputs.successful
with:
+ allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ steps.create_tag.outputs.version }}
tag: ${{ steps.create_tag.outputs.version }}