diff --git a/cmd/notify.go b/cmd/notify.go deleted file mode 100644 index 0e25afe..0000000 --- a/cmd/notify.go +++ /dev/null @@ -1,23 +0,0 @@ -package cmd - -import ( - "github.com/kondohiroki/go-boilerplate/internal/app" - "github.com/kondohiroki/go-boilerplate/internal/jobs" - "github.com/spf13/cobra" -) - -func init() { - rootCmd.AddCommand( - notifyDiscordCommand(), - ) -} - -func notifyDiscordCommand() *cobra.Command { - return &cobra.Command{ - Use: "notify:discord", - Short: "Notify to Discord", - Run: func(cmd *cobra.Command, args []string) { - jobs.SendNotificationViaDiscord(app.GetAppContext()) - }, - } -} diff --git a/doc/.DS_Store b/doc/.DS_Store deleted file mode 100644 index c77f406..0000000 Binary files a/doc/.DS_Store and /dev/null differ diff --git a/doc/images/.DS_Store b/doc/images/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/doc/images/.DS_Store and /dev/null differ diff --git a/doc/.gitkeep b/docs/.gitkeep similarity index 100% rename from doc/.gitkeep rename to docs/.gitkeep diff --git a/docs/doc.go b/docs/doc.go new file mode 100644 index 0000000..a7e432a --- /dev/null +++ b/docs/doc.go @@ -0,0 +1,34 @@ +// Code generated by swaggo/swag. DO NOT EDIT +package doc + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": {} +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "", + Description: "", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/docs/image/choice.png b/docs/image/choice.png new file mode 100644 index 0000000..1f5b654 Binary files /dev/null and b/docs/image/choice.png differ diff --git a/docs/image/diagram.png b/docs/image/diagram.png new file mode 100644 index 0000000..3b88acf Binary files /dev/null and b/docs/image/diagram.png differ diff --git a/docs/image/homepage.png b/docs/image/homepage.png new file mode 100644 index 0000000..fd114ff Binary files /dev/null and b/docs/image/homepage.png differ diff --git a/doc/images/.gitkeep b/docs/images/.gitkeep similarity index 100% rename from doc/images/.gitkeep rename to docs/images/.gitkeep diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 0000000..ec416cd --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,7 @@ +{ + "swagger": "2.0", + "info": { + "contact": {} + }, + "paths": {} +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 0000000..b64379c --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,4 @@ +info: + contact: {} +paths: {} +swagger: "2.0" diff --git a/internal/app/context.go b/internal/app/context.go deleted file mode 100644 index 91d76bd..0000000 --- a/internal/app/context.go +++ /dev/null @@ -1,30 +0,0 @@ -package app - -import ( - "context" - "sync" - - "github.com/kondohiroki/go-boilerplate/config" - "github.com/kondohiroki/go-boilerplate/internal/discord" - "go.uber.org/zap" -) - -var appCtx *AppContext // Read-only global variable -var m sync.Mutex - -type AppContext struct { - Ctx context.Context - Config *config.Config - Discord *discord.Discord - Logger *zap.Logger -} - -func GetAppContext() *AppContext { - return appCtx -} - -func SetAppContext(ctx *AppContext) { - m.Lock() - defer m.Unlock() - appCtx = ctx -} diff --git a/internal/discord/discord.go b/internal/discord/discord.go deleted file mode 100644 index 94bd0f2..0000000 --- a/internal/discord/discord.go +++ /dev/null @@ -1,37 +0,0 @@ -package discord - -import ( - "fmt" - - "github.com/bwmarrin/discordgo" -) - -type Discord struct { - *discordgo.Session -} - -type Color string - -const ( - SuccessColor Color = "0x198754" - FailedColor Color = "0xDC3545" - WarningColor Color = "0xFFC107" - InfoColor Color = "0x0D6EFD" -) - -func NewDiscord(token string) *Discord { - discord, err := discordgo.New("Bot " + token) - if err != nil { - fmt.Println("Error creating Discord session: ", err) - return nil - } - - // Open the Discord session - err = discord.Open() - if err != nil { - fmt.Println("Error opening Discord session: ", err) - return nil - } - - return &Discord{discord} -} diff --git a/internal/jobs/discord.go b/internal/jobs/discord.go deleted file mode 100644 index fb61bd4..0000000 --- a/internal/jobs/discord.go +++ /dev/null @@ -1,18 +0,0 @@ -package jobs - -import ( - "github.com/kondohiroki/go-boilerplate/internal/app" - "go.uber.org/zap" -) - -func SendNotificationViaDiscord(c *app.AppContext) { - // Send a message to the channel - _, err := c.Discord.ChannelMessageSend(c.Config.Discord.ChannelID, "Hello, World!") - if err != nil { - c.Logger.Error("Error sending message: ", zap.Error(err)) - return - } - - c.Logger.Info("Message sent successfully.") // Use logger from app context - // fmt.Println("Message sent successfully.") -}