mirror of
https://gitee.com/chuangxxt/share-copilot
synced 2025-04-16 09:13:26 +00:00
Initial commit
This commit is contained in:
parent
cbdf9b4253
commit
202fd4d29c
@ -12,11 +12,13 @@ import (
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Server struct {
|
||||
Domain string `json:"domain"`
|
||||
@ -31,12 +33,14 @@ type Config struct {
|
||||
} `json:"copilot_config"`
|
||||
Verification string `json:"verification"`
|
||||
}
|
||||
|
||||
var (
|
||||
requestCountMutex sync.Mutex
|
||||
requestCount int
|
||||
successCount int
|
||||
configFile = Config{}
|
||||
)
|
||||
|
||||
func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
gin.DefaultWriter = io.Discard
|
||||
@ -152,9 +156,9 @@ func initConfig() Config {
|
||||
// 设置日志输出到文件
|
||||
log.SetOutput(logFile)
|
||||
// 读取配置文件
|
||||
configFile, err := os.Open("./config.json")
|
||||
exePath, err := os.Executable()
|
||||
if err != nil {
|
||||
panic("file \"./config.json\" not found")
|
||||
panic(err)
|
||||
}
|
||||
// 获取可执行文件所在目录
|
||||
exeDir := filepath.Dir(exePath)
|
||||
@ -218,7 +222,6 @@ func showRequestCount() {
|
||||
countStr := fmt.Sprintf("\x1b[34m%d\x1b[0m", count)
|
||||
// 绿色文本
|
||||
successCountStr := fmt.Sprintf("\x1b[32m%d\x1b[0m", sCount)
|
||||
// 红色文本
|
||||
failureCountStr := fmt.Sprintf("\x1b[31m%d\x1b[0m", count-sCount)
|
||||
fmt.Printf("\033[1G%s - Total Count: %s | Success Count %s | Fail Count %s ", timeStr, countStr, successCountStr, failureCountStr)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user