Skip to content

Commit

Permalink
fix: module
Browse files Browse the repository at this point in the history
  • Loading branch information
ultrazg committed Aug 1, 2024
1 parent 0978836 commit 14673ba
Show file tree
Hide file tree
Showing 58 changed files with 20 additions and 12 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download && go mod verify
RUN go clean -modcache && \
go mod download -x && \
go mod verify

COPY . .

Expand Down
6 changes: 6 additions & 0 deletions doc/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package docs

import "embed"

//go:embed docs/*
var Fs embed.FS
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package main

import "github.com/ultrazg/xyz/service"

func main() {
err := Start()
err := service.Start()
if err != nil {
panic(err)
}
Expand Down
9 changes: 3 additions & 6 deletions route.go → router/router.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package main
package router

import (
"embed"
"github.com/gin-gonic/gin"
"github.com/ultrazg/xyz/doc"
"github.com/ultrazg/xyz/handlers"
"github.com/ultrazg/xyz/utils"
"net/http"
)

//go:embed docs/*
var fs embed.FS

func RegisterRouters(engine *gin.Engine) {
engine.GET("/docs/*filepath", func(context *gin.Context) {
server := http.FileServer(http.FS(fs))
server := http.FileServer(http.FS(docs.Fs))
server.ServeHTTP(context.Writer, context.Request)
})
engine.GET("/ping", handlers.Pong)
Expand Down
9 changes: 5 additions & 4 deletions server.go → service/service.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package main
package service

import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/ultrazg/xyz/router"
"github.com/ultrazg/xyz/utils"
"log"
"net/http"
)

func Start() (err error) {
func Start() error {
p, d := utils.InitFlag()
port := fmt.Sprintf("%d", p)

Expand All @@ -26,7 +27,7 @@ func Start() (err error) {

engine.Use(Cors())

RegisterRouters(engine)
router.RegisterRouters(engine)

log.Printf("server start on %s", port)

Expand All @@ -39,7 +40,7 @@ func Start() (err error) {
}
}

err = engine.Run(":" + port)
err := engine.Run(":" + port)
if err != nil {
log.Println("server start fail")

Expand Down

0 comments on commit 14673ba

Please sign in to comment.