Skip to content

Commit d2bfcca

Browse files
author
王炳明
committed
新增文章
1 parent 6d89342 commit d2bfcca

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

source/c05/c05_01.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
1-
# 6.1 Gin 实战:Hello World
1+
# 5.1 Gin 实战:Hello World
22

3-
## 1. 最简单的web示例
3+
## 1. 环境准备
44

5-
新建一个项目目录,比如我使用 Goland ,那我的项目目录就为 `~/GolandProjects/gin-web-example`
5+
打开你的 Goland,设置好 GOPATH,我这里设置的是 `E:\MING-Code\Golang\`
66

7-
然后使用 go mod 命令初始化
7+
![image-20200419133606190](E:\MING-Git\GolangCodingTime\source\c05\image-20200419133606190.png)
8+
9+
并新建一个项目目录: `E:\MING-Code\Golang\src\github.com\iswbm\gin-example`
10+
11+
> 以上示例仅为我个人习惯,你无需要照搬,可根据你个人使用习惯灵活配置。
12+
13+
14+
15+
接下来使用 go mod 命令进行项目的初始化。
816

917
```shell
10-
$ go mod init github.com/iswbm/gin-web-example
11-
go: creating new go.mod: module github.com/iswbm/gin-web-example
18+
$ go mod init github.com/iswbm/gin-example
19+
go: creating new go.mod: module github.com/iswbm/gin-example
1220
```
1321

14-
按照之前讲过的,此时会生成 `go.mod` 文件。
22+
最后使用 `go get` 下载安装 gin 框架
23+
24+
```shell
25+
$ go get -u github.com/gin-gonic/gin
26+
```
27+
28+
29+
30+
## 2. 最简单的示例
1531

16-
接着,还是在这个目录下,新建一个 `main.go` 的文件
32+
在 gin-example 根目录下,新建一个 `main.go` 的文件
1733

1834
```go
1935
package main
@@ -32,11 +48,12 @@ func main(){
3248
})
3349

3450
// 默认在监听 0.0.0.0:8080
51+
// r.Run("localhost:8080")
3552
r.Run()
3653
}
3754
```
3855

39-
一切准备好后,就可以运行了
56+
一切准备好后,就可以运行了.
4057

4158
```
4259
$ go run main.go

source/c05/c05_02.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 5.2 学 gin 需要了解哪些库
2+
3+
4+
5+
1、github.com/go-ini/ini:读取配置
6+
7+
2、github.com/jinzhu/gorm:[操作数据库](http://gorm.book.jasperxu.com/)
8+
9+
3、log: [日志的使用](https://studygolang.com/articles/14595)

source/c06/c06_02.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 6.2 配置高颜值 IDE:Goland

0 commit comments

Comments
 (0)