mirror of
https://gitee.com/chuangxxt/share-copilot
synced 2025-06-09 06:13:26 +00:00
Compare commits
No commits in common. "8f5a79d92b7678f5d31672b6ecfefad03925cc7d" and "89c6e2ffc1d0f1a69b8dc6267d42de34515f99d7" have entirely different histories.
8f5a79d92b
...
89c6e2ffc1
47
README.md
47
README.md
@ -3,40 +3,15 @@
|
|||||||
```
|
```
|
||||||
测试环境:Linux4.18.0-305.3.1.el8.x86_64 GNU/Linux
|
测试环境: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.安装
|
### 1.安装
|
||||||
|
|
||||||
```sh
|
|
||||||
git clone https://gitlab.com/luyoyu/share-copilot.git
|
|
||||||
```
|
```
|
||||||
```sh
|
git clone https://gitee.com/chuangxxt/share-copilot.git
|
||||||
|
```
|
||||||
|
```
|
||||||
cd share-copilot
|
cd share-copilot
|
||||||
```
|
```
|
||||||
```sh
|
```
|
||||||
bash install.sh
|
bash install.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -126,18 +101,14 @@ config.json
|
|||||||
|
|
||||||
时间-合计请求次数: 0 | 成功次数 0 | 失败次数 0 统计次数在00:00:00归零
|
时间-合计请求次数: 0 | 成功次数 0 | 失败次数 0 统计次数在00:00:00归零
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
修改%userprofile%\AppData\Local\github-copilot\host.json
|
修改%userprofile%\AppData\Local\github-copilot\host.json
|
||||||
|
|
||||||
```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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
测试:
|
测试:
|
||||||
|
|
||||||
|
@ -12,13 +12,11 @@ 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"`
|
||||||
@ -33,14 +31,12 @@ 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
|
||||||
@ -156,13 +152,7 @@ func initConfig() Config {
|
|||||||
// 设置日志输出到文件
|
// 设置日志输出到文件
|
||||||
log.SetOutput(logFile)
|
log.SetOutput(logFile)
|
||||||
// 读取配置文件
|
// 读取配置文件
|
||||||
exePath, err := os.Executable()
|
configFile, err := os.Open("./config.json")
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
// 获取可执行文件所在目录
|
|
||||||
exeDir := filepath.Dir(exePath)
|
|
||||||
configFile, err := os.Open(exeDir + "/config.json")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("file \"./config.json\" not found")
|
panic("file \"./config.json\" not found")
|
||||||
}
|
}
|
||||||
@ -222,6 +212,7 @@ 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