16 Commits
Author SHA1 Message Date
ben Gutier 8f5a79d92b Initial commit 2023-09-09 12:27:23 +08:00
ben Gutier 25fec4fee2 Merge branch 'master' of https://gitee.com/chuangxxt/share-copilot 2023-09-09 12:25:34 +08:00
ben Gutier ed4644fd58 Merge branch 'master' of https://gitlab.com/luyoyu/share-copilot 2023-09-09 12:24:21 +08:00
ben Gutier 3965fb17e9 Merge branch 'master' of https://gitlab.com/luyoyu/share-copilot 2023-09-09 12:21:16 +08:00
ben Gutier 875fd92f43 1 2023-09-09 12:14:13 +08:00
ben Gutier 3e2905df51 1 2023-09-09 12:10:43 +08:00
ben Gutier 90bf9e0ac9 Initial commit 2023-09-09 12:02:49 +08:00
ben Gutier 6c5a520a4d Initial commit 2023-09-09 12:01:50 +08:00
ben Gutier 0ff00c6e3c Initial commit 2023-09-09 11:59:46 +08:00
ben Gutier 5fd13795e9 Initial commit 2023-09-09 11:58:07 +08:00
ben Gutier bd78d0b91a Initial commit 2023-09-09 11:57:10 +08:00
ben Gutier 236af69bd8 Initial commit 2023-09-09 11:52:47 +08:00
ben Gutier df0a863a7c Initial commit 2023-09-09 11:49:30 +08:00
ben Gutier 762adeea49 Update README.md 2023-09-09 02:59:06 +00:00
ben Gutier d05bd9652e Initial commit 2023-09-09 10:47:53 +08:00
ben Gutier 0929683600 2023.9.9 2023-09-09 10:35:39 +08:00
2 changed files with 49 additions and 11 deletions
+38 -9
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"
}
}
}
```
测试:
+11 -2
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)
}