Skip to content

Commit

Permalink
update config
Browse files Browse the repository at this point in the history
  • Loading branch information
mustang2247 committed Apr 12, 2022
1 parent 6a97b30 commit 513f164
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@ clean:
@rm -rf _dev
@rm -rf _release
@rm -rf _docker
@rm -rf log
@echo "clean okay"

docker-build: clean pack-release
@mkdir -p _docker
@cp -f Dockerfile _docker
@cp _release/$(RELEASE_NAME).tar.gz _docker/
@cp docker/Shanghai _docker/
#docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t username/demo:latest --push .
#cd _docker && docker build --no-cache -t $(DOCKER_TARGET) --build-arg modeenv=$(ENV_SERVER_MODE) --build-arg exposeport=$(PORT) --build-arg procname=$(NAME) --build-arg packagefile=$(RELEASE_NAME).tar.gz .
cd _docker && docker buildx build --platform linux/amd64 --no-cache -t $(DOCKER_TARGET) --build-arg modeenv=$(ENV_SERVER_MODE) --build-arg exposeport=$(PORT) --build-arg procname=$(NAME) --build-arg packagefile=$(RELEASE_NAME).tar.gz .
@echo "docker-build okay"

Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Golang + Gin + Gorm + MySQL 基础手脚架

Golang + Gin + Gorm + MySQL 基础手脚架,支持容器和k8s部署。打包后自动生成 docker image 可以直接配置好账户,直接自动化上传。

## make 打包
Expand All @@ -11,17 +10,15 @@

## 生成`swagger`文档
```
Download Swag for Go by using:
go get -u github.com/swaggo/swag/cmd/swag
Run the Swag in your Go project root folder which contains main.go file, Swag will parse comments and generate required files(docs folder and docs/doc.go).
swag init
# 基于Makefile
make swagger
# OR 使用 swag 命令(注意:main.go 的路径)
swag init --generalInfo ./cmd/gin-admin/main.go --output ./internal/app/swagger
swag init -g ./src/cmd/main.go
swag init -g ./app/cmd/main.go -o ./docs/
```

Expand Down
3 changes: 2 additions & 1 deletion app/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
_ "golang-common-base/pkg/config"
"golang-common-base/pkg/connection"
"golang-common-base/pkg/logger"
"golang-common-base/pkg/service/auth_rsync"
"os"

"github.com/spf13/viper"
Expand All @@ -36,7 +37,7 @@ func init() {
// http://localhost:9088/api/v1/swagger/index.html
func main() {
// 同步用户和部门数据
//go auth_rsync.Main()
go auth_rsync.Main()

// 同步数据结构
models.AutoMigrateTable()
Expand Down
2 changes: 1 addition & 1 deletion app/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/swaggo/gin-swagger/swaggerFiles"
)

// 加载路由
// Load 加载路由
func Load(g *gin.Engine) {
// 404
g.NoRoute(func(c *gin.Context) {
Expand Down
2 changes: 1 addition & 1 deletion conf/config_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ db:
name: db_common
addr: 127.0.0.1:3306
username: root
password: 123456
password: mustang
gorm:
logMode: 0
maxOpenConn: 100
Expand Down
18 changes: 9 additions & 9 deletions pkg/service/auth_rsync/rsync.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package auth_rsync

// import (
// "time"
// )
import (
"time"
)

// func Main() {
// for range time.Tick(300 * time.Second) {
// _ = GetAllDeparts()
// GetAllUsers()
// }
// }
func Main() {
for range time.Tick(300 * time.Second) {
//_ = GetAllDeparts()
//GetAllUsers()
}
}
2 changes: 1 addition & 1 deletion pkg/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
@Author : Mustang Kong
*/

// 获取当前项目路径
// ObjectPath 获取当前项目路径
func ObjectPath() (projectPath string) {
projectPath, err := os.Getwd()
if err != nil {
Expand Down

0 comments on commit 513f164

Please sign in to comment.