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