Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
golang1.22.5-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eazy-template
golang1.22.5-template
Commits
e60960d5
Commit
e60960d5
authored
Sep 17, 2025
by
xiezhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix makefile
parent
5cdd0ff6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
91 deletions
+5
-91
Makefile
Makefile
+2
-67
README.md
README.md
+3
-24
No files found.
Makefile
View file @
e60960d5
...
@@ -53,11 +53,7 @@ run: install
...
@@ -53,11 +53,7 @@ run: install
# 停止命令
# 停止命令
.PHONY
:
stop
.PHONY
:
stop
stop
:
kill
stop
:
# 强制杀死所有相关Go进程
.PHONY
:
kill
kill
:
@
echo
"正在查找并杀死所有相关的Go进程..."
@
echo
"正在查找并杀死所有相关的Go进程..."
@
PIDS
=
$$
(
ps aux |
grep
-E
"hello_world|
$(APP_NAME)
"
|
grep
-v
grep
|
awk
'{print $$2}'
)
;
\
@
PIDS
=
$$
(
ps aux |
grep
-E
"hello_world|
$(APP_NAME)
"
|
grep
-v
grep
|
awk
'{print $$2}'
)
;
\
if
[
-n
"
$$
PIDS"
]
;
then
\
if
[
-n
"
$$
PIDS"
]
;
then
\
...
@@ -72,65 +68,4 @@ kill:
...
@@ -72,65 +68,4 @@ kill:
echo
"未找到相关的Go进程"
;
\
echo
"未找到相关的Go进程"
;
\
fi
fi
@
rm
-f
$(PID_FILE)
@
rm
-f
$(PID_FILE)
@
echo
"✅ 强制停止操作完成"
@
echo
"✅ 停止操作完成"
# 重启命令
.PHONY
:
restart
restart
:
stop run
# 查看状态
.PHONY
:
status
status
:
@
if
[
-f
"
$(PID_FILE)
"
]
;
then
\
PID
=
$$
(
cat
$(PID_FILE)
)
;
\
if
ps
-p
$$
PID
>
/dev/null 2>&1
;
then
\
echo
"✅ 服务器正在运行,PID:
$$
PID"
;
\
echo
"端口:
$(APP_PORT)
"
;
\
echo
"日志:
$(LOG_FILE)
"
;
\
else
\
echo
"❌ 服务器未运行(PID文件存在但进程不存在)"
;
\
rm
-f
$(PID_FILE)
;
\
fi
;
\
else
\
echo
"❌ 服务器未运行"
;
\
fi
# 开发模式运行
.PHONY
:
dev
dev
:
@
echo
"开发模式运行Go程序..."
@
APP_PORT_1
=
$(APP_PORT)
$(GO_RUN)
main.go
# 清理编译文件
.PHONY
:
clean
clean
:
@
echo
"清理编译文件..."
rm
-rf
$(BUILD_DIR)
@
echo
"清理完成!"
# 显示帮助信息
.PHONY
:
help
help
:
@
echo
"Go 1.22.5 HTTP 服务器项目"
@
echo
""
@
echo
"可用命令:"
@
echo
" make install - 安装依赖并编译项目"
@
echo
" make run - 启动HTTP服务器(后台运行)"
@
echo
" make stop - 停止HTTP服务器(优雅停止)"
@
echo
" make kill - 强制杀死所有相关Go进程"
@
echo
" make restart - 重启HTTP服务器"
@
echo
" make status - 查看服务器状态"
@
echo
" make dev - 开发模式运行"
@
echo
" make clean - 清理编译文件"
@
echo
" make help - 显示此帮助信息"
@
echo
""
@
echo
"示例:"
@
echo
" make run # 启动服务器"
@
echo
" make status # 查看状态"
@
echo
" make stop # 优雅停止服务器"
@
echo
" make kill # 强制停止所有相关进程"
@
echo
" make restart # 重启服务器"
@
echo
" make dev # 开发模式运行"
@
echo
""
@
echo
"环境变量:"
@
echo
" APP_PORT_1 - 服务器端口(默认: 8000)"
README.md
View file @
e60960d5
...
@@ -50,23 +50,8 @@ make install
...
@@ -50,23 +50,8 @@ make install
# 启动服务器(后台运行)
# 启动服务器(后台运行)
make run
make run
# 开发模式运行
make dev
# 查看服务器状态
make status
# 停止服务器
# 停止服务器
make stop
make stop
# 重启服务器
make restart
# 清理编译文件
make clean
# 查看帮助
make
help
```
```
### 3. 直接使用 Go 命令
### 3. 直接使用 Go 命令
...
@@ -164,11 +149,8 @@ if port == "" {
...
@@ -164,11 +149,8 @@ if port == "" {
### 查看日志
### 查看日志
```
bash
```
bash
#
使用 Makefile
查看日志
# 查看日志
tail
-f
.logs/app.log
tail
-f
.logs/app.log
# 查看服务器状态
make status
```
```
### 健康检查
### 健康检查
...
@@ -216,8 +198,8 @@ make stop
...
@@ -216,8 +198,8 @@ make stop
2.
**编译错误**
2.
**编译错误**
```
bash
```
bash
#
清理并
重新编译
# 重新编译
make clean
rm
-rf
build
make
install
make
install
```
```
...
@@ -230,9 +212,6 @@ docker build --no-cache -t test .
...
@@ -230,9 +212,6 @@ docker build --no-cache -t test .
### 调试模式
### 调试模式
```
bash
```
bash
# 开发模式运行(显示详细日志)
make dev
# 直接运行 Go 程序
# 直接运行 Go 程序
go run main.go
go run main.go
```
```
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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