mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 19:39:11 +00:00
automatically go fmt on lint
This commit is contained in:
parent
2e1e63a789
commit
d93592f1a2
4 changed files with 85 additions and 84 deletions
|
@ -15,6 +15,7 @@
|
|||
"scripts": {
|
||||
"lint": "run-p -c lint:* --",
|
||||
"lint:eslint": "eslint",
|
||||
"lint:go": "go fmt ./...",
|
||||
"lint:prettier": "cross-env prettier -c '**/*.{ts,tsx,css,yml,yaml,md,json,js,jsx,sh,gitignore,mdx,Dockerfile}'",
|
||||
"lint:stylelint": "cross-env stylelint '**/*.{ts,tsx}'",
|
||||
"lint:types": "tsc --noEmit",
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
GitCommit = "unknown"
|
||||
GitBranch = "unknown"
|
||||
BuildDate = "unknown"
|
||||
)
|
||||
|
||||
func StartupInfo(serviceName string) string {
|
||||
return fmt.Sprintf(
|
||||
"Starting %s service.\n Build %s (%s) at %s",
|
||||
serviceName,
|
||||
GitCommit,
|
||||
GitBranch,
|
||||
BuildDate,
|
||||
)
|
||||
}
|
||||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
GitCommit = "unknown"
|
||||
GitBranch = "unknown"
|
||||
BuildDate = "unknown"
|
||||
)
|
||||
|
||||
func StartupInfo(serviceName string) string {
|
||||
return fmt.Sprintf(
|
||||
"Starting %s service.\n Build %s (%s) at %s",
|
||||
serviceName,
|
||||
GitCommit,
|
||||
GitBranch,
|
||||
BuildDate,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestStartup(t *testing.T) {
|
||||
GitBranch = "test"
|
||||
GitCommit = "e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e"
|
||||
BuildDate = time.Now().UTC().Format("2006-01-02T15:04:05.000Z")
|
||||
|
||||
expected := "Starting test service.\n Build e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e (test) at " + BuildDate
|
||||
value := StartupInfo("test")
|
||||
if value != expected {
|
||||
t.Error("Incorrect render, got `", value, "`")
|
||||
}
|
||||
}
|
||||
package version
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestStartup(t *testing.T) {
|
||||
GitBranch = "test"
|
||||
GitCommit = "e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e"
|
||||
BuildDate = time.Now().UTC().Format("2006-01-02T15:04:05.000Z")
|
||||
|
||||
expected := "Starting test service.\n Build e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e (test) at " + BuildDate
|
||||
value := StartupInfo("test")
|
||||
if value != expected {
|
||||
t.Error("Incorrect render, got `", value, "`")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/discordgo"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/roleypoly/roleypoly/src/common"
|
||||
"github.com/roleypoly/roleypoly/src/common/bot"
|
||||
"github.com/roleypoly/roleypoly/src/common/version"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
var (
|
||||
botToken = common.Getenv("BOT_TOKEN").String()
|
||||
botClientID = common.Getenv("BOT_CLIENT_ID").String()
|
||||
rootUsers = common.Getenv("ROOT_USERS").StringSlice()
|
||||
allowedBots = common.Getenv("ALLOWED_BOTS").StringSlice()
|
||||
appURL = common.Getenv("UI_PUBLIC_URI").SafeURL()
|
||||
selfMention = bot.MentionMatcher(botClientID)
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.Info(version.StartupInfo("discord-bot"))
|
||||
|
||||
err := bot.ScaffoldBot(bot.BotScaffolding{
|
||||
RootUsers: rootUsers,
|
||||
AllowBots: true,
|
||||
BotClientID: botClientID,
|
||||
BotToken: botToken,
|
||||
GatewayIntents: discordgo.IntentsGuildMessages,
|
||||
Handler: handle,
|
||||
})
|
||||
if err != nil {
|
||||
klog.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func isBotAllowlisted(userID string) bool {
|
||||
for _, id := range allowedBots {
|
||||
if id == userID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/discordgo"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/roleypoly/roleypoly/src/common"
|
||||
"github.com/roleypoly/roleypoly/src/common/bot"
|
||||
"github.com/roleypoly/roleypoly/src/common/version"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
var (
|
||||
botToken = common.Getenv("BOT_TOKEN").String()
|
||||
botClientID = common.Getenv("BOT_CLIENT_ID").String()
|
||||
rootUsers = common.Getenv("ROOT_USERS").StringSlice()
|
||||
allowedBots = common.Getenv("ALLOWED_BOTS").StringSlice()
|
||||
appURL = common.Getenv("UI_PUBLIC_URI").SafeURL()
|
||||
selfMention = bot.MentionMatcher(botClientID)
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.Info(version.StartupInfo("discord-bot"))
|
||||
|
||||
err := bot.ScaffoldBot(bot.BotScaffolding{
|
||||
RootUsers: rootUsers,
|
||||
AllowBots: true,
|
||||
BotClientID: botClientID,
|
||||
BotToken: botToken,
|
||||
GatewayIntents: discordgo.IntentsGuildMessages,
|
||||
Handler: handle,
|
||||
})
|
||||
if err != nil {
|
||||
klog.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func isBotAllowlisted(userID string) bool {
|
||||
for _, id := range allowedBots {
|
||||
if id == userID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue