diff --git a/README.md b/README.md index e3f329a..6f240ae 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,36 @@ ``` 测试环境:Linux4.18.0-305.3.1.el8.x86_64 GNU/Linux ``` +# 一、自编译: + +需要 go环境 出问题自行chatgpt + +```sh +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 /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 ``` diff --git a/source/main.go b/source/main.go index f5f133d..ae2f8f7 100644 --- a/source/main.go +++ b/source/main.go @@ -156,6 +156,12 @@ func initConfig() Config { if err != nil { panic("file \"./config.json\" not found") } + // 获取可执行文件所在目录 + exeDir := filepath.Dir(exePath) + configFile, err := os.Open(exeDir + "/config.json") + if err != nil { + panic("file \"./config.json\" not found") + } defer func(configFile *os.File) { err := configFile.Close() if err != nil {