Init: bootstrap go module with basic framework
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
amane
|
||||
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
#FROM gcr.io/distroless/static-debian12
|
||||
FROM gitea.konchin.com/image/alpine:main
|
||||
|
||||
ADD amane /amane
|
||||
|
||||
WORKDIR /
|
||||
ENTRYPOINT ["/amane"]
|
||||
27
Makefile
Normal file
27
Makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
.PHONY: all swagger docker install test sh
|
||||
|
||||
SWAG ?= ~/go/bin/swag
|
||||
|
||||
GO_ENV += CGO_ENABLED=0
|
||||
TARGET := $(shell find . -type f -name '*.go')
|
||||
|
||||
all: swagger docker install
|
||||
|
||||
docker: amane
|
||||
docker compose up -d --force-recreate --build backend
|
||||
|
||||
install:
|
||||
$(GO_ENV) go install
|
||||
|
||||
test:
|
||||
go test -v ./tests/units
|
||||
|
||||
swagger:
|
||||
$(SWAG) fmt
|
||||
$(SWAG) init -o handlers/docs -g cmd/backend.go -pdl 1
|
||||
|
||||
amane: $(TARGET)
|
||||
$(GO_ENV) go build -o $@
|
||||
|
||||
sh:
|
||||
docker compose exec -it backend sh
|
||||
84
cmd/backend.go
Normal file
84
cmd/backend.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
httpSwagger "github.com/swaggo/http-swagger"
|
||||
"github.com/uptrace/bun"
|
||||
"github.com/uptrace/bun/dialect/pgdialect"
|
||||
"github.com/uptrace/bun/driver/pgdriver"
|
||||
"github.com/uptrace/bun/extra/bunotel"
|
||||
"github.com/uptrace/bunrouter"
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/handlers/api"
|
||||
_ "gitea.konchin.com/service/amane-tanikaze-dcbot/amane/handlers/docs"
|
||||
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/middlewares"
|
||||
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/tracing"
|
||||
)
|
||||
|
||||
// @Title Amane Tanikaze Discord Bot Backend
|
||||
// @Version 2.0-alpha1
|
||||
// @TermsOfService http://swagger.io/terms/
|
||||
|
||||
// @License.Name 0BSD
|
||||
// @BasePath /
|
||||
var backendCmd = &cobra.Command{
|
||||
Use: "backend",
|
||||
Short: "backend server",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx := cmd.Context()
|
||||
tracing.InitTracer()
|
||||
|
||||
sqldb := sql.OpenDB(pgdriver.NewConnector(pgdriver.WithDSN(
|
||||
viper.GetString("pg-dsn"))))
|
||||
db := bun.NewDB(sqldb, pgdialect.New())
|
||||
db.AddQueryHook(bunotel.NewQueryHook(bunotel.WithDBName("PostgreSQL")))
|
||||
|
||||
router := bunrouter.New()
|
||||
|
||||
middlewaresHandlers := middlewares.NewHandlers(db)
|
||||
|
||||
backend := router.NewGroup("").
|
||||
Use(middlewaresHandlers.ErrorHandler)
|
||||
|
||||
if viper.GetBool("swagger") {
|
||||
backend.GET("/docs/*any",
|
||||
bunrouter.HTTPHandlerFunc(httpSwagger.Handler()))
|
||||
}
|
||||
|
||||
apiHandlers := api.NewHandlers(db)
|
||||
|
||||
apiGroup := backend.NewGroup("/api")
|
||||
apiGroup.GET("/image",
|
||||
apiHandlers.GetImage)
|
||||
|
||||
tracing.Logger.Ctx(ctx).
|
||||
Info("http server up",
|
||||
zap.String("http.port", viper.GetString("port")))
|
||||
|
||||
log.Println(http.ListenAndServe(":"+viper.GetString("port"),
|
||||
otelhttp.NewHandler(router, "")))
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
backendCmd.Flags().
|
||||
String("port", "8080", "Port to listen on")
|
||||
|
||||
backendCmd.Flags().
|
||||
String("pg-dsn",
|
||||
"postgres://amane:amane@postgres:5432/amane?sslmode=disable",
|
||||
"PostgreSQL connection string")
|
||||
|
||||
backendCmd.Flags().
|
||||
Bool("zap-develop", false, "Enable development log")
|
||||
|
||||
backendCmd.Flags().
|
||||
Bool("swagger", false, "Enable swagger")
|
||||
}
|
||||
7
cmd/dcbot.go
Normal file
7
cmd/dcbot.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package cmd
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var dcbotCmd = &cobra.Command{
|
||||
Use: "dcbot",
|
||||
}
|
||||
15
cmd/migrates/init.go
Normal file
15
cmd/migrates/init.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package migrates
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var initCmd = &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "Initialize migration table",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
ctx := cmd.Context()
|
||||
|
||||
return migrator.Init(ctx)
|
||||
},
|
||||
}
|
||||
13
cmd/migrates/lock.go
Normal file
13
cmd/migrates/lock.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package migrates
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var lockCmd = &cobra.Command{
|
||||
Use: "lock",
|
||||
Short: "Lock migrations",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return migrator.Lock(cmd.Context())
|
||||
},
|
||||
}
|
||||
33
cmd/migrates/rollback.go
Normal file
33
cmd/migrates/rollback.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package migrates
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var rollbackCmd = &cobra.Command{
|
||||
Use: "rollback",
|
||||
Short: "Rollback from last migration group",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
ctx := cmd.Context()
|
||||
|
||||
if err := migrator.Lock(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
defer migrator.Unlock(ctx)
|
||||
|
||||
group, err := migrator.Rollback(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if group.IsZero() {
|
||||
fmt.Printf("there are no groups to roll back\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Printf("roll back from %s\n", group)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
44
cmd/migrates/root.go
Normal file
44
cmd/migrates/root.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package migrates
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/migrations"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/uptrace/bun"
|
||||
"github.com/uptrace/bun/dialect/pgdialect"
|
||||
"github.com/uptrace/bun/driver/pgdriver"
|
||||
"github.com/uptrace/bun/extra/bundebug"
|
||||
"github.com/uptrace/bun/migrate"
|
||||
)
|
||||
|
||||
var (
|
||||
migrator *migrate.Migrator
|
||||
db *bun.DB
|
||||
)
|
||||
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "migrate",
|
||||
Short: "Migration related commands",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
sqldb := sql.OpenDB(pgdriver.NewConnector(
|
||||
pgdriver.WithDSN(viper.GetString("pg-dsn"))))
|
||||
db = bun.NewDB(sqldb, pgdialect.New())
|
||||
db.AddQueryHook(bundebug.NewQueryHook(bundebug.WithVerbose(true)))
|
||||
|
||||
migrator = migrate.NewMigrator(db, migrations.Migrations)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(upCmd)
|
||||
RootCmd.AddCommand(initCmd)
|
||||
RootCmd.AddCommand(rollbackCmd)
|
||||
RootCmd.AddCommand(lockCmd)
|
||||
RootCmd.AddCommand(unlockCmd)
|
||||
RootCmd.PersistentFlags().
|
||||
String("pg-dsn",
|
||||
"postgres://amane:amane@postgres:5432/amane?sslmode=disable",
|
||||
"Postgres connection string")
|
||||
}
|
||||
11
cmd/migrates/unlock.go
Normal file
11
cmd/migrates/unlock.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package migrates
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var unlockCmd = &cobra.Command{
|
||||
Use: "unlock",
|
||||
Short: "Unlock migrations",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return migrator.Unlock(cmd.Context())
|
||||
},
|
||||
}
|
||||
33
cmd/migrates/up.go
Normal file
33
cmd/migrates/up.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package migrates
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var upCmd = &cobra.Command{
|
||||
Use: "up",
|
||||
Short: "migrate up",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
ctx := cmd.Context()
|
||||
|
||||
if err := migrator.Lock(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
defer migrator.Unlock(ctx)
|
||||
|
||||
group, err := migrator.Migrate(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if group.IsZero() {
|
||||
fmt.Printf("there are no new migrations to run\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Printf("migrated to %s\n", group)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
27
cmd/root.go
Normal file
27
cmd/root.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/cmd/migrates"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "amane",
|
||||
Short: "Amane Tanikaze Discord Bot",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
viper.AutomaticEnv()
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
||||
viper.BindPFlags(cmd.PersistentFlags())
|
||||
viper.BindPFlags(cmd.Flags())
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
cobra.EnableTraverseRunHooks = true
|
||||
RootCmd.AddCommand(dcbotCmd)
|
||||
RootCmd.AddCommand(backendCmd)
|
||||
RootCmd.AddCommand(migrates.RootCmd)
|
||||
}
|
||||
45
docker-compose.yaml
Normal file
45
docker-compose.yaml
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17.2
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: poop
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- ./docker/postgres/:/docker-entrypoint-initdb.d/
|
||||
- postgres:/var/lib/postgresql/data
|
||||
restart: unless-stopped
|
||||
|
||||
minio:
|
||||
image: minio/minio:RELEASE.2025-07-23T15-54-02Z
|
||||
environment:
|
||||
MINIO_ROOT_USER: poop
|
||||
MINIO_ROOT_PASSWORD: poop1145141919810
|
||||
command: ["server", "/data", "--console-address", ":9001"]
|
||||
ports:
|
||||
- 9000:9000
|
||||
- 9001:9001
|
||||
volumes:
|
||||
- minio:/data
|
||||
restart: unless-stopped
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: .
|
||||
env_file:
|
||||
- path: .env
|
||||
command:
|
||||
- backend
|
||||
ports:
|
||||
- 8080:8080
|
||||
depends_on:
|
||||
- postgres
|
||||
- minio
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
redis: {}
|
||||
postgres: {}
|
||||
minio: {}
|
||||
4
docker/postgres/amane.sql
Normal file
4
docker/postgres/amane.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
CREATE USER amane;
|
||||
CREATE DATABASE amane;
|
||||
ALTER DATABASE amane OWNER TO amane;
|
||||
ALTER USER amane ENCRYPTED PASSWORD 'amane';
|
||||
67
go.mod
Normal file
67
go.mod
Normal file
@@ -0,0 +1,67 @@
|
||||
module gitea.konchin.com/service/amane-tanikaze-dcbot/amane
|
||||
|
||||
go 1.25.1
|
||||
|
||||
require (
|
||||
github.com/spf13/cobra v1.10.1
|
||||
github.com/spf13/viper v1.21.0
|
||||
github.com/swaggo/http-swagger v1.3.4
|
||||
github.com/swaggo/swag v1.16.2
|
||||
github.com/uptrace/bun v1.2.15
|
||||
github.com/uptrace/bun/dialect/pgdialect v1.2.15
|
||||
github.com/uptrace/bun/driver/pgdriver v1.2.15
|
||||
github.com/uptrace/bunrouter v1.0.23
|
||||
github.com/uptrace/opentelemetry-go-extra/otelzap v0.3.2
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0
|
||||
go.opentelemetry.io/otel v1.38.0
|
||||
go.opentelemetry.io/otel/trace v1.38.0
|
||||
go.uber.org/zap v1.27.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||
github.com/go-openapi/spec v0.20.9 // indirect
|
||||
github.com/go-openapi/swag v0.22.3 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect
|
||||
github.com/sagikazarmark/locafero v0.11.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
|
||||
github.com/spf13/afero v1.15.0 // indirect
|
||||
github.com/spf13/cast v1.10.0 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect
|
||||
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
|
||||
github.com/uptrace/bun/extra/bundebug v1.2.15 // indirect
|
||||
github.com/uptrace/bun/extra/bunotel v1.2.15 // indirect
|
||||
github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.2 // indirect
|
||||
github.com/uptrace/opentelemetry-go-extra/otelutil v0.3.2 // indirect
|
||||
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel/log v0.6.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.38.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/crypto v0.40.0 // indirect
|
||||
golang.org/x/net v0.42.0 // indirect
|
||||
golang.org/x/sys v0.35.0 // indirect
|
||||
golang.org/x/text v0.28.0 // indirect
|
||||
golang.org/x/tools v0.35.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
mellium.im/sasl v0.3.2 // indirect
|
||||
)
|
||||
188
go.sum
Normal file
188
go.sum
Normal file
@@ -0,0 +1,188 @@
|
||||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
|
||||
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
|
||||
github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo=
|
||||
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
|
||||
github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
|
||||
github.com/go-openapi/spec v0.20.9 h1:xnlYNQAwKd2VQRRfwTEI0DcK+2cbuvI/0c7jx3gA8/8=
|
||||
github.com/go-openapi/spec v0.20.9/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA=
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
|
||||
github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g=
|
||||
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/puzpuzpuz/xsync/v3 v3.5.1 h1:GJYJZwO6IdxN/IKbneznS6yPkVC+c3zyY/j19c++5Fg=
|
||||
github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
|
||||
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U=
|
||||
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
|
||||
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
|
||||
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
|
||||
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
|
||||
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
|
||||
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe h1:K8pHPVoTgxFJt1lXuIzzOX7zZhZFldJQK/CgKx9BFIc=
|
||||
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w=
|
||||
github.com/swaggo/http-swagger v1.3.4 h1:q7t/XLx0n15H1Q9/tk3Y9L4n210XzJF5WtnDX64a5ww=
|
||||
github.com/swaggo/http-swagger v1.3.4/go.mod h1:9dAh0unqMBAlbp1uE2Uc2mQTxNMU/ha4UbucIg1MFkQ=
|
||||
github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04=
|
||||
github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E=
|
||||
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
|
||||
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
|
||||
github.com/uptrace/bun v1.2.15 h1:Ut68XRBLDgp9qG9QBMa9ELWaZOmzHNdczHQdrOZbEFE=
|
||||
github.com/uptrace/bun v1.2.15/go.mod h1:Eghz7NonZMiTX/Z6oKYytJ0oaMEJ/eq3kEV4vSqG038=
|
||||
github.com/uptrace/bun/dialect/pgdialect v1.2.15 h1:er+/3giAIqpfrXJw+KP9B7ujyQIi5XkPnFmgjAVL6bA=
|
||||
github.com/uptrace/bun/dialect/pgdialect v1.2.15/go.mod h1:QSiz6Qpy9wlGFsfpf7UMSL6mXAL1jDJhFwuOVacCnOQ=
|
||||
github.com/uptrace/bun/driver/pgdriver v1.2.15 h1:eZZ60ZtUUE6jjv6VAI1pCMaTgtx3sxmChQzwbvchOOo=
|
||||
github.com/uptrace/bun/driver/pgdriver v1.2.15/go.mod h1:s2zz/BAeScal4KLFDI8PURwATN8s9RDBsElEbnPAjv4=
|
||||
github.com/uptrace/bun/extra/bundebug v1.2.15 h1:IY2Z/pVyVg0ApWnQ/pEnwe6BWxlDDATCz7IFZghutCs=
|
||||
github.com/uptrace/bun/extra/bundebug v1.2.15/go.mod h1:JuE+BT7NjTZ9UKr74eC8s9yZ9dnQCeufDwFRTC8w3Xo=
|
||||
github.com/uptrace/bun/extra/bunotel v1.2.15 h1:6KAvKRpH9BC/7n3eMXVgDYLqghHf2H3FJOvxs/yjFJM=
|
||||
github.com/uptrace/bun/extra/bunotel v1.2.15/go.mod h1:qnASdcJVuoEE+13N3Gd8XHi5gwCydt2S1TccJnefH2k=
|
||||
github.com/uptrace/bunrouter v1.0.23 h1:Bi7NKw3uCQkcA/GUCtDNPq5LE5UdR9pe+UyWbjHB/wU=
|
||||
github.com/uptrace/bunrouter v1.0.23/go.mod h1:O3jAcl+5qgnF+ejhgkmbceEk0E/mqaK+ADOocdNpY8M=
|
||||
github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.2 h1:ZjUj9BLYf9PEqBn8W/OapxhPjVRdC6CsXTdULHsyk5c=
|
||||
github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.2/go.mod h1:O8bHQfyinKwTXKkiKNGmLQS7vRsqRxIQTFZpYpHK3IQ=
|
||||
github.com/uptrace/opentelemetry-go-extra/otelutil v0.3.2 h1:3/aHKUq7qaFMWxyQV0W2ryNgg8x8rVeKVA20KJUkfS0=
|
||||
github.com/uptrace/opentelemetry-go-extra/otelutil v0.3.2/go.mod h1:Zit4b8AQXaXvA68+nzmbyDzqiyFRISyw1JiD5JqUBjw=
|
||||
github.com/uptrace/opentelemetry-go-extra/otelzap v0.3.2 h1:cj/Z6FKTTYBnstI0Lni9PA+k2foounKIPUmj1LBwNiQ=
|
||||
github.com/uptrace/opentelemetry-go-extra/otelzap v0.3.2/go.mod h1:LDaXk90gKEC2nC7JH3Lpnhfu+2V7o/TsqomJJmqA39o=
|
||||
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
|
||||
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0/go.mod h1:h06DGIukJOevXaj/xrNjhi/2098RZzcLTbc0jDAUbsg=
|
||||
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
|
||||
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
|
||||
go.opentelemetry.io/otel/log v0.6.0 h1:nH66tr+dmEgW5y+F9LanGJUBYPrRgP4g2EkmPE3LeK8=
|
||||
go.opentelemetry.io/otel/log v0.6.0/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM=
|
||||
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
|
||||
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
|
||||
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
|
||||
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
|
||||
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
|
||||
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
|
||||
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
|
||||
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
|
||||
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
|
||||
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
|
||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
||||
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=
|
||||
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
mellium.im/sasl v0.3.2 h1:PT6Xp7ccn9XaXAnJ03FcEjmAn7kK1x7aoXV6F+Vmrl0=
|
||||
mellium.im/sasl v0.3.2/go.mod h1:NKXDi1zkr+BlMHLQjY3ofYuU4KSPFxknb8mfEu6SveY=
|
||||
26
go.work.sum
Normal file
26
go.work.sum
Normal file
@@ -0,0 +1,26 @@
|
||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/santhosh-tekuri/jsonschema/v5 v5.2.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
|
||||
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/telemetry v0.0.0-20250710130107-8d8967aff50b/go.mod h1:4ZwOYna0/zsOKwuR5X/m0QFOJpSZvAxFfkQT+Erd9D4=
|
||||
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
|
||||
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
|
||||
15
handlers/api/getAliases.go
Normal file
15
handlers/api/getAliases.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/uptrace/bunrouter"
|
||||
)
|
||||
|
||||
func (*Handlers) GetAliases(
|
||||
w http.ResponseWriter,
|
||||
req bunrouter.Request,
|
||||
) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
28
handlers/api/getImage.go
Normal file
28
handlers/api/getImage.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/middlewares"
|
||||
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/utils"
|
||||
"github.com/uptrace/bunrouter"
|
||||
)
|
||||
|
||||
// GetImage
|
||||
//
|
||||
// @Param id query string true "image id"
|
||||
// @Success 200
|
||||
// @Router /api/image [get]
|
||||
func (*Handlers) GetImage(
|
||||
w http.ResponseWriter,
|
||||
req bunrouter.Request,
|
||||
) error {
|
||||
imageId := req.URL.Query().Get("id")
|
||||
if imageId == "" {
|
||||
return middlewares.HTTPError{
|
||||
StatusCode: http.StatusBadRequest,
|
||||
Message: "must provide id",
|
||||
}
|
||||
}
|
||||
return utils.Success(w)
|
||||
}
|
||||
11
handlers/api/handlers.go
Normal file
11
handlers/api/handlers.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package api
|
||||
|
||||
import "github.com/uptrace/bun"
|
||||
|
||||
type Handlers struct {
|
||||
db *bun.DB
|
||||
}
|
||||
|
||||
func NewHandlers(db *bun.DB) *Handlers {
|
||||
return &Handlers{db: db}
|
||||
}
|
||||
1
handlers/api/postAlias.go
Normal file
1
handlers/api/postAlias.go
Normal file
@@ -0,0 +1 @@
|
||||
package api
|
||||
1
handlers/api/putImage.go
Normal file
1
handlers/api/putImage.go
Normal file
@@ -0,0 +1 @@
|
||||
package api
|
||||
1
handlers/auth/postLogin.go
Normal file
1
handlers/auth/postLogin.go
Normal file
@@ -0,0 +1 @@
|
||||
package auth
|
||||
59
handlers/docs/docs.go
Normal file
59
handlers/docs/docs.go
Normal file
@@ -0,0 +1,59 @@
|
||||
// Package docs Code generated by swaggo/swag. DO NOT EDIT
|
||||
package docs
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
|
||||
const docTemplate = `{
|
||||
"schemes": {{ marshal .Schemes }},
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "{{escape .Description}}",
|
||||
"title": "{{.Title}}",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {},
|
||||
"license": {
|
||||
"name": "0BSD"
|
||||
},
|
||||
"version": "{{.Version}}"
|
||||
},
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"paths": {
|
||||
"/api/image": {
|
||||
"get": {
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "image id",
|
||||
"name": "id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "2.0-alpha1",
|
||||
Host: "",
|
||||
BasePath: "/",
|
||||
Schemes: []string{},
|
||||
Title: "Amane Tanikaze Discord Bot Backend",
|
||||
Description: "",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
RightDelim: "}}",
|
||||
}
|
||||
|
||||
func init() {
|
||||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
||||
}
|
||||
33
handlers/docs/swagger.json
Normal file
33
handlers/docs/swagger.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "Amane Tanikaze Discord Bot Backend",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {},
|
||||
"license": {
|
||||
"name": "0BSD"
|
||||
},
|
||||
"version": "2.0-alpha1"
|
||||
},
|
||||
"basePath": "/",
|
||||
"paths": {
|
||||
"/api/image": {
|
||||
"get": {
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "image id",
|
||||
"name": "id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
handlers/docs/swagger.yaml
Normal file
21
handlers/docs/swagger.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
basePath: /
|
||||
info:
|
||||
contact: {}
|
||||
license:
|
||||
name: 0BSD
|
||||
termsOfService: http://swagger.io/terms/
|
||||
title: Amane Tanikaze Discord Bot Backend
|
||||
version: 2.0-alpha1
|
||||
paths:
|
||||
/api/image:
|
||||
get:
|
||||
parameters:
|
||||
- description: image id
|
||||
in: query
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
swagger: "2.0"
|
||||
7
main.go
Normal file
7
main.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "gitea.konchin.com/service/amane-tanikaze-dcbot/amane/cmd"
|
||||
|
||||
func main() {
|
||||
cmd.RootCmd.Execute()
|
||||
}
|
||||
87
middlewares/errorHandler.go
Normal file
87
middlewares/errorHandler.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/tracing"
|
||||
"github.com/uptrace/bunrouter"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type HTTPError struct {
|
||||
StatusCode int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
OriginError error `json:"-"`
|
||||
}
|
||||
|
||||
func (e HTTPError) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func NewHTTPError(err error) HTTPError {
|
||||
return HTTPError{
|
||||
StatusCode: http.StatusInternalServerError,
|
||||
Message: "Internal server error with unknown reason",
|
||||
OriginError: err,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Handlers) ErrorHandler(
|
||||
next bunrouter.HandlerFunc,
|
||||
) bunrouter.HandlerFunc {
|
||||
return func(w http.ResponseWriter, req bunrouter.Request) error {
|
||||
err := next(w, req)
|
||||
ctx := req.Context()
|
||||
|
||||
var httpErr HTTPError
|
||||
switch err := err.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
|
||||
case HTTPError:
|
||||
httpErr = err
|
||||
|
||||
default:
|
||||
tracing.Logger.Ctx(ctx).
|
||||
Error("unhandled error",
|
||||
zap.Error(err))
|
||||
httpErr = NewHTTPError(err)
|
||||
}
|
||||
|
||||
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||
span := trace.SpanFromContext(ctx)
|
||||
span.SetAttributes(
|
||||
attribute.Int("http.response.status_code", httpErr.StatusCode),
|
||||
)
|
||||
|
||||
if 500 <= httpErr.StatusCode && httpErr.StatusCode <= 599 {
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
if httpErr.OriginError == nil {
|
||||
tracing.Logger.Ctx(ctx).
|
||||
Error(httpErr.Message)
|
||||
} else {
|
||||
tracing.Logger.Ctx(ctx).
|
||||
Error(httpErr.Message,
|
||||
zap.Error(httpErr.OriginError))
|
||||
}
|
||||
} else {
|
||||
span.SetStatus(codes.Ok, "")
|
||||
if httpErr.OriginError == nil {
|
||||
tracing.Logger.Ctx(ctx).
|
||||
Warn(httpErr.Message)
|
||||
} else {
|
||||
tracing.Logger.Ctx(ctx).
|
||||
Warn(httpErr.Message,
|
||||
zap.Error(httpErr.OriginError))
|
||||
}
|
||||
}
|
||||
|
||||
w.WriteHeader(httpErr.StatusCode)
|
||||
_ = bunrouter.JSON(w, httpErr)
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
11
middlewares/handlers.go
Normal file
11
middlewares/handlers.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package middlewares
|
||||
|
||||
import "github.com/uptrace/bun"
|
||||
|
||||
type Handlers struct {
|
||||
db *bun.DB
|
||||
}
|
||||
|
||||
func NewHandlers(db *bun.DB) *Handlers {
|
||||
return &Handlers{db: db}
|
||||
}
|
||||
1
migrations/202509250652_create_table_image.tx.down.sql
Normal file
1
migrations/202509250652_create_table_image.tx.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS "image";
|
||||
4
migrations/202509250652_create_table_image.tx.up.sql
Normal file
4
migrations/202509250652_create_table_image.tx.up.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
CREATE TABLE "image" (
|
||||
id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
ext character varying NOT NULL
|
||||
);
|
||||
1
migrations/202509250727_create_table_guild.tx.down.sql
Normal file
1
migrations/202509250727_create_table_guild.tx.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS "guild";
|
||||
7
migrations/202509250727_create_table_guild.tx.up.sql
Normal file
7
migrations/202509250727_create_table_guild.tx.up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE "guild" (
|
||||
id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
dc_id character varying UNIQUE,
|
||||
name character varying NOT NULL,
|
||||
|
||||
auto_role_log_chan_id character varying
|
||||
);
|
||||
1
migrations/202509250744_create_table_alias.tx.down.sql
Normal file
1
migrations/202509250744_create_table_alias.tx.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS "alias";
|
||||
7
migrations/202509250744_create_table_alias.tx.up.sql
Normal file
7
migrations/202509250744_create_table_alias.tx.up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE "alias" (
|
||||
id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
guild_id integer,
|
||||
alias character varying,
|
||||
|
||||
UNIQUE (guild_id, alias)
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS "auto_role_msg";
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE "auto_role_msg" (
|
||||
guild_id integer,
|
||||
message_id character varying,
|
||||
role_id character varying NOT NULL,
|
||||
emoji character varying,
|
||||
|
||||
PRIMARY KEY (guild_id, message_id)
|
||||
);
|
||||
@@ -0,0 +1,7 @@
|
||||
ALTER TABLE "alias" ADD CONSTRAINT "guild_id_fk"
|
||||
FOREIGN KEY (guild_id) REFERENCES "guild" (id) ON DELETE CASCADE;
|
||||
|
||||
--bun:split
|
||||
|
||||
ALTER TABLE "auto_role_msg" ADD CONSTRAINT "guild_id_fk"
|
||||
FOREIGN KEY (guild_id) REFERENCES "guild" (id) ON DELETE CASCADE;
|
||||
18
migrations/main.go
Normal file
18
migrations/main.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"embed"
|
||||
|
||||
"github.com/uptrace/bun/migrate"
|
||||
)
|
||||
|
||||
var Migrations = migrate.NewMigrations()
|
||||
|
||||
//go:embed *.sql
|
||||
var sqlMigrations embed.FS
|
||||
|
||||
func init() {
|
||||
if err := Migrations.Discover(sqlMigrations); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
23
models/alias.go
Normal file
23
models/alias.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type Alias struct {
|
||||
bun.BaseModel `bun:"table:alias"`
|
||||
|
||||
Id int `bun:"id,pk,autoincrement"`
|
||||
GuildId int `bun:"guild_id,unique:text"`
|
||||
Alias string `bun:"alias,unique:text"`
|
||||
|
||||
Guild *Guild `bun:"belongs-to,join:guild_id=id"`
|
||||
Images []Image `bun:"m2m:alias_to_image,join:Alias=Image"`
|
||||
}
|
||||
|
||||
type AliasToImage struct {
|
||||
AliasId int `bun:"alias_id,pk"`
|
||||
Alias *Alias `bun:"rel:belongs-to,join:alias_id=id"`
|
||||
ImageId int `bun:"image_id,pk"`
|
||||
Image *Image `bun:"rel:belongs-to,join:image_id=id"`
|
||||
}
|
||||
14
models/autoRoleMsg.go
Normal file
14
models/autoRoleMsg.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package models
|
||||
|
||||
import "github.com/uptrace/bun"
|
||||
|
||||
type AutoRoleMsg struct {
|
||||
bun.BaseModel `bun:"table:auto_role_msg"`
|
||||
|
||||
GuildId int `bun:"guild_id,pk"`
|
||||
MessageId string `bun:"message_id,pk"`
|
||||
RoleId string `bun:"role_id,notnull"`
|
||||
Emoji string `bun:"emoji"`
|
||||
|
||||
Guild *Guild `bun:"belongs-to:guild,join:guild_id=id"`
|
||||
}
|
||||
13
models/guild.go
Normal file
13
models/guild.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package models
|
||||
|
||||
import "github.com/uptrace/bun"
|
||||
|
||||
type Guild struct {
|
||||
bun.BaseModel `bun:"table:guild"`
|
||||
|
||||
Id int64 `bun:"id,pk,autoincrement"`
|
||||
DcId string `bun:"dc_id,unique"`
|
||||
Name string `bun:"name,notnull"`
|
||||
|
||||
AutoRoleLogChanId string `bun:"auto_role_log_chan_id"`
|
||||
}
|
||||
10
models/image.go
Normal file
10
models/image.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package models
|
||||
|
||||
import "github.com/uptrace/bun"
|
||||
|
||||
type Image struct {
|
||||
bun.BaseModel `bun:"table:image"`
|
||||
|
||||
Id int64 `bun:"id,pk,autoincrement"`
|
||||
Ext string `bun:"ext"`
|
||||
}
|
||||
34
tracing/tracer.go
Normal file
34
tracing/tracer.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package tracing
|
||||
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
"github.com/uptrace/opentelemetry-go-extra/otelzap"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var (
|
||||
Tracer trace.Tracer
|
||||
Logger *otelzap.Logger
|
||||
|
||||
appname string = "amane"
|
||||
version string = "2.0.0-alpha1"
|
||||
)
|
||||
|
||||
func InitTracer() {
|
||||
Tracer = otel.Tracer(appname)
|
||||
|
||||
var l *zap.Logger
|
||||
var err error
|
||||
if viper.GetBool("zap-develop") {
|
||||
l, err = zap.NewDevelopment()
|
||||
} else {
|
||||
l, err = zap.NewProduction()
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Logger = otelzap.New(l)
|
||||
}
|
||||
10
utils/initDB.go
Normal file
10
utils/initDB.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/models"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
func InitDB(db *bun.DB) {
|
||||
db.RegisterModel((*models.AliasToImage)(nil))
|
||||
}
|
||||
14
utils/success.go
Normal file
14
utils/success.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func Success(w http.ResponseWriter) error {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
_, err := io.WriteString(w,
|
||||
`{"code":200, "message": "success"}`+"\n")
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user