Compare commits

..

No commits in common. "89c6e2ffc1d0f1a69b8dc6267d42de34515f99d7" and "8f5a79d92b7678f5d31672b6ecfefad03925cc7d" have entirely different histories.

2 changed files with 49 additions and 11 deletions

View File

@ -3,15 +3,40 @@
```
测试环境:Linux4.18.0-305.3.1.el8.x86_64 GNU/Linux
```
# 一、自编译:
需要 go环境 出问题自行chatgpt
```sh
wget https://dl.google.com/go/go1.21.1.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz
vim ~/.bashrc
#添加下列环境
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
#使生效环境变量
source ~/.bashrc
#验证安装
go version
#cd到main.go源码目录
cd /share-copilot/source
go build
```
# 二、使用现成:
### 1.安装
```sh
git clone https://gitlab.com/luyoyu/share-copilot.git
```
git clone https://gitee.com/chuangxxt/share-copilot.git
```
```
```sh
cd share-copilot
```
```
```sh
bash install.sh
```
@ -101,14 +126,18 @@ config.json
时间-合计请求次数: 0 | 成功次数 0 | 失败次数 0 统计次数在00:00:00归零
修改%userprofile%\AppData\Local\github-copilot\host.json
```json
{"github.com":{"user":"suibian","oauth_token":"i_am_free","dev_override":{"copilot_token_url":"https://api.example.com/copilot_internal/v2/token"}}}
{
"github.com":{
"user":"suibian",
"oauth_token":"i_am_free",
"dev_override":{
"copilot_token_url":"https://api.example.com/copilot_internal/v2/token"
}
}
}
```
测试:

View File

@ -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,7 +156,13 @@ func initConfig() Config {
// 设置日志输出到文件
log.SetOutput(logFile)
// 读取配置文件
configFile, err := os.Open("./config.json")
exePath, err := os.Executable()
if err != nil {
panic(err)
}
// 获取可执行文件所在目录
exeDir := filepath.Dir(exePath)
configFile, err := os.Open(exeDir + "/config.json")
if err != nil {
panic("file \"./config.json\" not found")
}
@ -212,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)
}