Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
李宇怀
Backend
Commits
827be9bc
Commit
827be9bc
authored
Sep 12, 2023
by
李宇怀
Browse files
更新了readme
parent
5c518d8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
827be9bc
...
@@ -56,27 +56,46 @@ git clone http://xlab.zju.edu.cn/git/future/backend
...
@@ -56,27 +56,46 @@ git clone http://xlab.zju.edu.cn/git/future/backend
# Move to the project root directory
# Move to the project root directory
cd backend
cd backend
```
```
-
如果您的计算机未按照
`MySQL`
,请安装
-
在您运行该项目前,请先完成您的MySQL的配置
-
按照config_demo.yaml修改你的本地mysql对应的密码、ip和数据库。
>关于您的MySQL配置,在config_demo里有详细指导。
-
IP可通过cmd -> 输入ipconfig/all 获取ipv4
### 不用Docker运行
### 不用Docker运行
1.
git clone 所有文件,进入根目录
1.
如果您的计算机未安装
`go`
,请安装
2.
如果您的计算机未安装
`go`
,请安装
2.
进入项目所在根目录 执行go run main.go
3.
如果您的计算机未按照
`MySQL`
,请安装
3.
访问localhost:8080/ping测试
4.
进入项目所在根目录 执行go run main.go
4.
运行前端项目后访问localhost:8000
5.
访问localhost:8080/ping测试
6.
运行前端项目后访问localhost:8000
### 使用Docker运行
### 使用Docker运行
1.
如果您的计算机未配置好
`MySQL`
,请配置
1.
如果您的计算机未配置好
`MySQL`
,请配置
2.
按照config_demo.yaml修改你的本地mysql对应的密码、ip和数据库。
2.
安装Docker,在项目根目录下打开PowerShell输入
3.
安装Docker,在项目根目录下运行
```
docker build shortlink .
```
来创建镜像
你可以通过输入
```
docker images
```
来判断你刚是否成功创建镜像shortlink,若成功创建,您能看到shortlink镜像出现在列表中,类似于这样:
```
REPOSITORY TAG IMAGE ID CREATED SIZE
shortlink latest a5f006e92c71 15 minutes ago 1.07GB
```
3.
随后输入
```
```
docker run --net=bridge -p 8080:8080 --name=shortlink shortlink
docker run --net=bridge -p 8080:8080 --name=shortlink shortlink
```
```
4.
访问localhost:8080/ping测试
创建容器并运行
5.
运行前端项目后访问localhost:8000
3.
访问localhost:8080/ping测试
4.
运行前端项目后访问localhost:8000
## 如何运行测试?
## 如何运行测试?
...
@@ -84,7 +103,7 @@ docker run --net=bridge -p 8080:8080 --name=shortlink shortlink
...
@@ -84,7 +103,7 @@ docker run --net=bridge -p 8080:8080 --name=shortlink shortlink
# 进行测试
# 进行测试
go test ./...
go test ./...
```
```
>我更提倡直接用每个test函数旁边的go test一个一个测试,
比较
测试嘛,肯定要报错的,一堆错误一起报未免不太美观(
>我更提倡直接用每个test函数旁边的go test一个一个测试,
毕竟
测试嘛,肯定要报错的,一堆错误一起报未免不太美观(
## 项目结构图
## 项目结构图
```
```
backend
backend
...
@@ -153,4 +172,7 @@ backend
...
@@ -153,4 +172,7 @@ backend
## todo
## todo
-
等待前端功能补足(×) 自己写个新前端(
-
等待前端功能补足(×) 自己写个新前端(
-
不用登录就能创建短连接
-
不用登录就能创建短连接
## 如果这个项目无论如何都对你有帮助,通过在这个项目✌️上放一个⭐来表达你的爱 ❤️
## 如果这个项目无论如何都对你有帮助,通过在这个项目✌️上放一个⭐来表达你的爱 ❤️
\ No newline at end of file
## 后续感想&建议
()
\ No newline at end of file
config_demo.yaml
View file @
827be9bc
...
@@ -9,4 +9,5 @@ WebServer:
...
@@ -9,4 +9,5 @@ WebServer:
Database
:
Database
:
DSN
:
root:password@tcp(YourIP:3306)/shortlink?charset=utf8mb4&parseTime=True&loc=Local
DSN
:
root:password@tcp(YourIP:3306)/shortlink?charset=utf8mb4&parseTime=True&loc=Local
# 比如您的密码为123456,数据库为test,ip地址为127.0.0.1,则将DSN修改为:
# DSN: root:123456@tcp(127.0.0.1:3306)/test?charset=utf8mb4&parseTime=True&loc=Local
dockerfile
View file @
827be9bc
# 请看readme.md获取操作帮助
FROM
golang:1.20
FROM
golang:1.20
ENV
GO111MODULE=on
ENV
GO111MODULE=on
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment