Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #12 from jacexh/release/0.2.6
Browse files Browse the repository at this point in the history
Release/0.2.6
  • Loading branch information
jacexh authored Mar 22, 2021
2 parents 04c86e9 + 7a004db commit f359055
Show file tree
Hide file tree
Showing 26 changed files with 47 additions and 43 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ gdp

## Change Log

### 0.2.6

- 参考[Project Layout](https://github.com/golang-standards/project-layout)调整项目布局

### 0.2.5

- Graceful Shutdown的exit code改成0
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion router/middleware/ginzap.go → api/middleware/ginzap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"time"

"github.com/gin-gonic/gin"
"{{.Module}}/internal/trace"
"{{.Module}}/pkg/bytespool"
"{{.Module}}/trace"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion router/middleware/index.go → api/middleware/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync/atomic"

"github.com/gin-gonic/gin"
"{{.Module}}/trace"
"{{.Module}}/internal/trace"
)

type (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"github.com/gin-gonic/gin"
"{{.Module}}/trace"
"{{.Module}}/internal/trace"
"go.uber.org/zap"
)

Expand Down
14 changes: 7 additions & 7 deletions router/router.go → api/server.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package router
package api

import (
"net/http"

"github.com/gin-gonic/gin"
"{{.Module}}/logger"
"{{.Module}}/option"
"{{.Module}}/router/api"
"{{.Module}}/router/middleware"
"{{.Module}}/api/middleware"
v1 "{{.Module}}/api/v1"
"{{.Module}}/internal/logger"
"{{.Module}}/internal/option"
)

// BuildRouter 构造Router
Expand All @@ -21,9 +21,9 @@ func BuildRouter(option option.RouterOption) *gin.Engine {
middleware.Ginzap(logger.Logger, option.MergeLog, option.DumpResponse),
)

group := router.Group("/api")
group := router.Group("/v1")
{
group.POST("/user", api.CreateUser)
group.POST("/user", v1.CreateUser)
}

router.GET("/ping", func(c *gin.Context) {
Expand Down
8 changes: 4 additions & 4 deletions router/api/api.go → api/v1/api.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package api
package v1

import (
"net/http"

"github.com/gin-gonic/gin"
"{{.Module}}/application"
"{{.Module}}/trace"
"{{.Module}}/types/dto"
"{{.Module}}/api/dto"
"{{.Module}}/internal/application"
"{{.Module}}/internal/trace"
)

func CreateUser(c *gin.Context) {
Expand Down
12 changes: 6 additions & 6 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"syscall"
"time"

"{{.Module}}/application"
"{{.Module}}/infrastructure/persistence"
"{{.Module}}/logger"
"{{.Module}}/option"
"{{.Module}}/api"
"{{.Module}}/internal/application"
"{{.Module}}/internal/infrastructure/persistence"
"{{.Module}}/internal/logger"
"{{.Module}}/internal/option"
"{{.Module}}/pkg/infection"
"{{.Module}}/router"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -42,7 +42,7 @@ func main() {
application.BuildUserApplication(ur)

// 启动运行web server
eng := router.BuildRouter(opt.Router)
eng := api.BuildRouter(opt.Router)

// 服务启动
srv := &http.Server{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package application

import (
"{{.Module}}/domain/user"
"{{.Module}}/types/dto"
"{{.Module}}/api/dto"
"{{.Module}}/internal/domain/user"
)

func convertUser(user *user.UserEntity) *dto.UserDTO {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package handler
import (
"context"

"{{.Module}}/domain/event"
"{{.Module}}/domain/user"
"{{.Module}}/logger"
"{{.Module}}/trace"
"{{.Module}}/internal/domain/event"
"{{.Module}}/internal/domain/user"
"{{.Module}}/internal/logger"
"{{.Module}}/internal/trace"
"go.uber.org/zap"
)

Expand Down
12 changes: 6 additions & 6 deletions application/user.go → internal/application/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package application
import (
"context"

"{{.Module}}/application/handler"
"{{.Module}}/domain/event"
"{{.Module}}/domain/user"
"{{.Module}}/logger"
"{{.Module}}/trace"
"{{.Module}}/types/dto"
"{{.Module}}/api/dto"
"{{.Module}}/internal/application/handler"
"{{.Module}}/internal/domain/event"
"{{.Module}}/internal/domain/user"
"{{.Module}}/internal/logger"
"{{.Module}}/internal/trace"
"go.uber.org/zap"
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package event
import (
"context"

"{{.Module}}/logger"
"{{.Module}}/trace"
"{{.Module}}/internal/logger"
"{{.Module}}/internal/trace"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion domain/user/event.go → internal/domain/user/event.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package user

import "{{.Module}}/domain/event"
import "{{.Module}}/internal/domain/event"

type (
EventUserCreated struct {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion domain/user/user.go → internal/domain/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package user
import (
"errors"

"{{.Module}}/domain/event"
"{{.Module}}/internal/domain/event"
)

type UserEntity struct {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package persistence

import (
"{{.Module}}/domain/user"
"{{.Module}}/types/do"
"{{.Module}}/internal/domain/user"
"{{.Module}}/internal/infrastructure/do"
)

func convertUser(entity *user.UserEntity) *do.UserDo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"

_ "github.com/go-sql-driver/mysql"
"{{.Module}}/logger"
"{{.Module}}/option"
"{{.Module}}/internal/logger"
"{{.Module}}/internal/option"
"go.uber.org/zap"
"xorm.io/xorm"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package persistence
import (
"context"

"{{.Module}}/domain/user"
"{{.Module}}/internal/domain/user"
"xorm.io/xorm"
)

Expand Down
2 changes: 1 addition & 1 deletion logger/logger.go → internal/logger/logger.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package logger

import (
"{{.Module}}/option"
"{{.Module}}/internal/option"
"github.com/jacexh/goutil/zaphelper"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand Down
2 changes: 1 addition & 1 deletion logger/xorm.go → internal/logger/xorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package logger
import (
"fmt"

"{{.Module}}/trace"
"{{.Module}}/internal/trace"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"xorm.io/xorm/log"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f359055

Please sign in to comment.