server

command module
v0.0.0-...-093ec34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

gin框架运行的服务

1.安装项目运行环境
  • 默认你已经安装好了Golang环境
  • 确保安装了 mysql、redis、rabbitmq 等服务。

如果您不知道如何安装这些服务,可以参考docker-compose目录下的docker-compose.yaml文件,使用docker-compose启动这些服务。

如果您不会使用docker,可以参考Docker.md文档,或者其他相关博客。

如果你不想使用这些服务,可以在server.go OnInitialize 函数中,注释掉相关初始化代码。

  • 初始化数据库,创建表和数据
go run main.go migrate --action=migrate \
--file=./blog-veweiyi.sql \
--host=127.0.0.1 \
--port=3307 \
--username=root \
--password=mysql7914 \
--name='blog-veweiyi'  
2.修改配置文件

在server目录下新增config.yaml文件,修改config.yaml配置文件中的配置信息,文件内容参考config.default.yaml

3.项目本地启动

启动方式二选一

  1. 使用本地配置文件 config.yaml 启动项目
go run main.go api --config=./config.yaml 
  1. 使用nacos的配置文件启动项目
go run main.go api --use-nacos=true --n-ns=test
4.其他

格式化代码

go fmt ./...

格式化swagger注解

swag fmt

生成swagger注解

swag init

Documentation

Overview

Copyright © 2023 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL