├── LICENSE ├── README.md ├── api └── v1 │ └── clientreq.go ├── chatgpt ├── answers.go ├── api.go ├── assistant.go ├── common.go ├── completion.go ├── edits.go ├── embeddings.go ├── engines.go ├── error.go ├── files.go ├── moderation.go └── search.go ├── config.yaml ├── config ├── local.go ├── proxy.go ├── server.go ├── system.go └── zap.go ├── core ├── server.go ├── server_other.go ├── viper.go └── zap.go ├── global ├── global.go └── model.go ├── go.mod ├── go.sum ├── initialize ├── gogptclient.go └── router.go ├── main.go ├── middleware ├── cors.go └── tls.go ├── model ├── clientquest.go └── response │ └── response.go ├── router └── clientreq.go ├── service └── cliengreq.go └── utils ├── constant.go ├── directory.go ├── guid.go ├── rotatelogs_unix.go └── rotatelogs_windows.go /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 oldseven 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ChatGPTCnServer 2 | 3 | 基于golang的ChatGPT反向代理服务器,项目起的名字有点夸张,见笑 4 | 5 | ## 部署方式 6 | 7 | 1. 从本站下载好 [二进制](https://github.com/xaseven/chatgptcnserver/releases)(或者自己编译)文件,附带config.yaml配置文件即可. 8 | 2. nginx配置: 9 | location /api/ { 10 | add_header Access-Control-Allow-Origin * always; 11 | add_header Access-Control-Allow-Credentials false always; 12 | add_header Access-Control-Allow-Methods * always; 13 | add_header Access-Control-Allow-Headers * always; 14 | if ($request_method = 'OPTIONS') { 15 | return 204; 16 | } 17 | proxy_set_header Host $http_host; 18 | proxy_set_header X-Real-IP $remote_addr; 19 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 20 | proxy_set_header X-Forwarded-Proto $scheme; 21 | rewrite ^/api/(.*)$ /$1 break; 22 | proxy_pass http://127.0.0.1:8899/; 23 | } 24 | 3. config.yml说明详见本文件内部说明 25 | 4. 前端html代码详见 https://github.com/xaseven/chatgptcnhtml 26 | 主要使用接口:/api/base/quest (配合nginx做api目录重写) 27 | 28 | ## Build from source 29 | 30 | 1. Clone the repo。go get github.com/xaseven/chatgptcnserver 31 | 2. Install dependencies with `go mod tidy` 32 | 3. `GOOS=linux GO111MODULE=on GOARCH=amd64 go build` 33 | ## 视频教程 34 | https://www.youtube.com/@qilaoxi/videos 35 | 36 | https://www.bilibili.com/video/BV1MR4y1r7xQ/ 37 | 38 | QQ群:816577341 39 | ## 广告 40 |
赚钱项目:游鱼赚钱项目平台
41 |服务器购买①:【腾讯云】云服务器等爆品抢先购,低至4.2元/月
42 | 43 | 44 | -------------------------------------------------------------------------------- /api/v1/clientreq.go: -------------------------------------------------------------------------------- 1 | package v1 2 | 3 | import ( 4 | "chatgptcnserver/global" 5 | "chatgptcnserver/model" 6 | "chatgptcnserver/model/response" 7 | "chatgptcnserver/service" 8 | "github.com/gin-gonic/gin" 9 | "go.uber.org/zap" 10 | ) 11 | 12 | func Questansw(c *gin.Context) { 13 | var a model.ClientQuest 14 | _ = c.ShouldBind(&a) 15 | 16 | if respstr, err := service.RespClientQuest(a.Prompt); err != nil { 17 | global.Chatgptcn_LOG.Error("失败!", zap.Any("err", err)) 18 | response.FailWithMessage("创建失败:"+err.Error(), c) 19 | } else { 20 | response.OkWithData(gin.H{"answ": respstr}, c) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /chatgpt/answers.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "net/http" 8 | ) 9 | 10 | type AnswerRequest struct { 11 | Documents []string `json:"documents,omitempty"` 12 | File string `json:"file,omitempty"` 13 | Question string `json:"question"` 14 | SearchModel string `json:"search_model,omitempty"` 15 | Model string `json:"model"` 16 | ExamplesContext string `json:"examples_context"` 17 | Examples [][]string `json:"examples"` 18 | MaxTokens int `json:"max_tokens,omitempty"` 19 | Stop []string `json:"stop,omitempty"` 20 | Temperature *float64 `json:"temperature,omitempty"` 21 | } 22 | 23 | type AnswerResponse struct { 24 | Answers []string `json:"answers"` 25 | Completion string `json:"completion"` 26 | Model string `json:"model"` 27 | Object string `json:"object"` 28 | SearchModel string `json:"search_model"` 29 | SelectedDocuments []struct { 30 | Document int `json:"document"` 31 | Text string `json:"text"` 32 | } `json:"selected_documents"` 33 | } 34 | 35 | // Search — perform a semantic search api call over a list of documents. 36 | func (c *Client) Answers(ctx context.Context, request AnswerRequest) (response AnswerResponse, err error) { 37 | var reqBytes []byte 38 | reqBytes, err = json.Marshal(request) 39 | if err != nil { 40 | return 41 | } 42 | 43 | req, err := http.NewRequest("POST", c.fullURL("/answers"), bytes.NewBuffer(reqBytes)) 44 | if err != nil { 45 | return 46 | } 47 | 48 | req = req.WithContext(ctx) 49 | err = c.sendRequest(req, &response) 50 | return 51 | } 52 | -------------------------------------------------------------------------------- /chatgpt/api.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/http" 7 | "time" 8 | ) 9 | 10 | const apiURLv1 = "https://api.openai.com/v1" 11 | 12 | func newTransport() *http.Client { 13 | return &http.Client{ 14 | Timeout: time.Minute, 15 | } 16 | } 17 | 18 | // Client is OpenAI GPT-3 API client. 19 | type Client struct { 20 | BaseURL string 21 | AssistantUrl string 22 | HTTPClient *http.Client 23 | authToken string 24 | idOrg string 25 | } 26 | 27 | // NewClient creates new OpenAI API client. 28 | func NewClient(authToken string) *Client { 29 | return &Client{ 30 | BaseURL: apiURLv1, 31 | AssistantUrl: apiURLv1 + "/assistant", 32 | HTTPClient: newTransport(), 33 | authToken: authToken, 34 | idOrg: "", 35 | } 36 | } 37 | 38 | // NewOrgClient creates new OpenAI API client for specified Organization ID. 39 | func NewOrgClient(authToken, org string) *Client { 40 | return &Client{ 41 | BaseURL: apiURLv1, 42 | AssistantUrl: apiURLv1 + "/assistant", 43 | HTTPClient: newTransport(), 44 | authToken: authToken, 45 | idOrg: org, 46 | } 47 | } 48 | 49 | func (c *Client) sendRequest(req *http.Request, v interface{}) error { 50 | req.Header.Set("Accept", "application/json; charset=utf-8") 51 | req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.authToken)) 52 | 53 | // Check whether Content-Type is already set, Upload Files API requires 54 | // Content-Type == multipart/form-data 55 | contentType := req.Header.Get("Content-Type") 56 | if contentType == "" { 57 | req.Header.Set("Content-Type", "application/json; charset=utf-8") 58 | } 59 | 60 | if len(c.idOrg) > 0 { 61 | req.Header.Set("OpenAI-Organization", c.idOrg) 62 | } 63 | 64 | res, err := c.HTTPClient.Do(req) 65 | //bodystr, _ := ioutil.ReadAll(res.Body) 66 | //fmt.Println(string(bodystr)) 67 | if err != nil { 68 | return err 69 | } 70 | 71 | defer res.Body.Close() 72 | 73 | if res.StatusCode < http.StatusOK || res.StatusCode >= http.StatusBadRequest { 74 | var errRes ErrorResponse 75 | err = json.NewDecoder(res.Body).Decode(&errRes) 76 | if err != nil || errRes.Error == nil { 77 | return fmt.Errorf("error, status code: %d", res.StatusCode) 78 | } 79 | return fmt.Errorf("error, status code: %d, message: %s", res.StatusCode, errRes.Error.Message) 80 | } 81 | 82 | if v != nil { 83 | if err = json.NewDecoder(res.Body).Decode(&v); err != nil { 84 | return err 85 | } 86 | } 87 | 88 | return nil 89 | } 90 | 91 | func (c *Client) fullURL(suffix string) string { 92 | return fmt.Sprintf("%s%s", c.BaseURL, suffix) 93 | } 94 | 95 | func (c *Client) assistantURL(suffix string) string { 96 | return fmt.Sprintf("%s%s", c.AssistantUrl, suffix) 97 | } 98 | -------------------------------------------------------------------------------- /chatgpt/assistant.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "net/http" 8 | "net/url" 9 | "strconv" 10 | ) 11 | 12 | type OverviewRequest struct { 13 | Prompt string `json:"prompt"` 14 | Model string `json:"model"` 15 | Temperature float64 `json:"temperature"` 16 | MaxTokens int `json:"max_tokens"` 17 | TopP float64 `json:"top_p"` 18 | FrequencyPenalty float64 `json:"frequency_penalty"` 19 | PresencePenalty float64 `json:"presence_penalty"` 20 | SessionID string `json:"session_id"` 21 | } 22 | 23 | // 24 | func (c *Client) CreateOverview( 25 | ctx context.Context, 26 | request OverviewRequest, 27 | ) (response CompletionResponse, err error) { 28 | var reqBytes []byte 29 | reqBytes, err = json.Marshal(request) 30 | if err != nil { 31 | return 32 | } 33 | 34 | urlSuffix := "/overview" 35 | req, err := http.NewRequest("POST", c.assistantURL(urlSuffix), bytes.NewBuffer(reqBytes)) 36 | if err != nil { 37 | return 38 | } 39 | 40 | req = req.WithContext(ctx) 41 | err = c.sendRequest(req, &response) 42 | return 43 | } 44 | 45 | //func (c *Client) CreateOverview(ctx context.Context, request OverviewRequest) (response CompletionResponse, err error) { 46 | // urlSuffix := "/overview" 47 | // apiURL := c.assistantURL(urlSuffix) 48 | // requestURL := buildURL(apiURL, request) 49 | // req, err := http.NewRequest("GET", requestURL, nil) 50 | // if err != nil { 51 | // return 52 | // } 53 | // 54 | // req = req.WithContext(ctx) 55 | // err = c.sendRequest(req, &response) 56 | 57 | // 58 | //// Send the request 59 | //resp, err := http.Get(requestURL) 60 | //if err != nil { 61 | // log.Fatal(err) 62 | //} 63 | // 64 | //// Read the response 65 | //defer resp.Body.Close() 66 | //body, err := ioutil.ReadAll(resp.Body) 67 | //if err != nil { 68 | // return 69 | //} 70 | //// Print the response 71 | //fmt.Println(string(body)) 72 | // return 73 | //} 74 | 75 | /* 76 | params := make(map[string]string) 77 | params["prompt"] = request.Prompt 78 | params["model"] = request.Model 79 | params["temperature"] = strconv.FormatFloat(request.Temperature, 'f', -1, 64) 80 | params["max_tokens"] = strconv.FormatInt(int64(request.MaxTokens), 10) 81 | params["top_p"] = strconv.FormatFloat(request.TopP, 'f', -1, 64) 82 | params["frequency_penalty"] = strconv.FormatFloat(request.FrequencyPenalty, 'f', -1, 64) 83 | params["presence_penalty"] = strconv.FormatFloat(request.PresencePenalty, 'f', -1, 64) 84 | params["session_id"] = request.SessionID 85 | */ 86 | func buildURL(apiURL string, request OverviewRequest) (urlStr string) { 87 | queryParams := url.Values{} 88 | queryParams.Add("prompt", request.Prompt) 89 | queryParams.Add("model", request.Model) 90 | queryParams.Add("temperature", strconv.FormatFloat(request.Temperature, 'f', -1, 64)) 91 | queryParams.Add("max_tokens", strconv.FormatInt(int64(request.MaxTokens), 10)) 92 | queryParams.Add("top_p", strconv.FormatFloat(request.TopP, 'f', -1, 64)) 93 | queryParams.Add("frequency_penalty", strconv.FormatFloat(request.FrequencyPenalty, 'f', -1, 64)) 94 | queryParams.Add("presence_penalty", strconv.FormatFloat(request.PresencePenalty, 'f', -1, 64)) 95 | queryParams.Add("session_id", request.SessionID) 96 | // 构建 URL 97 | u, err := url.Parse(apiURL) 98 | if err != nil { 99 | // 处理错误 100 | } 101 | u.RawQuery = queryParams.Encode() // 将查询参数添加到 URL 中 102 | urlStr = u.String() // 获取完整的 URL 字符串 103 | return 104 | } 105 | -------------------------------------------------------------------------------- /chatgpt/common.go: -------------------------------------------------------------------------------- 1 | // common.go defines common types used throughout the OpenAI API. 2 | package gogpt 3 | 4 | // Usage Represents the total token usage per request to OpenAI. 5 | type Usage struct { 6 | PromptTokens int `json:"prompt_tokens"` 7 | CompletionTokens int `json:"completion_tokens"` 8 | TotalTokens int `json:"total_tokens"` 9 | } 10 | -------------------------------------------------------------------------------- /chatgpt/completion.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "net/http" 8 | ) 9 | 10 | // GPT3 Defines the models provided by OpenAI to use when generating 11 | // completions from OpenAI. 12 | // GPT3 Models are designed for text-based tasks. For code-specific 13 | // tasks, please refer to the Codex series of models. 14 | const ( 15 | GPT3TextDavinci003 = "text-davinci-003" 16 | GPT3TextDavinci002 = "text-davinci-002" 17 | GPT3TextCurie001 = "text-curie-001" 18 | GPT3TextBabbage001 = "text-babbage-001" 19 | GPT3TextAda001 = "text-ada-001" 20 | GPT3TextDavinci001 = "text-davinci-001" 21 | GPT3DavinciInstructBeta = "davinci-instruct-beta" 22 | GPT3Davinci = "davinci" 23 | GPT3CurieInstructBeta = "curie-instruct-beta" 24 | GPT3Curie = "curie" 25 | GPT3Ada = "ada" 26 | GPT3Babbage = "babbage" 27 | ) 28 | 29 | // Codex Defines the models provided by OpenAI. 30 | // These models are designed for code-specific tasks, and use 31 | // a different tokenizer which optimizes for whitespace. 32 | const ( 33 | CodexCodeDavinci002 = "code-davinci-002" 34 | CodexCodeCushman001 = "code-cushman-001" 35 | CodexCodeDavinci001 = "code-davinci-001" 36 | ) 37 | 38 | // CompletionRequest represents a request structure for completion API. 39 | type CompletionRequest struct { 40 | Model string `json:"model"` 41 | Prompt string `json:"prompt,omitempty"` 42 | Suffix string `json:"suffix,omitempty"` 43 | MaxTokens int `json:"max_tokens,omitempty"` 44 | Temperature float32 `json:"temperature,omitempty"` 45 | TopP float32 `json:"top_p,omitempty"` 46 | N int `json:"n,omitempty"` 47 | Stream bool `json:"stream,omitempty"` 48 | LogProbs int `json:"logprobs,omitempty"` 49 | Echo bool `json:"echo,omitempty"` 50 | Stop []string `json:"stop,omitempty"` 51 | PresencePenalty float32 `json:"presence_penalty,omitempty"` 52 | FrequencyPenalty float32 `json:"frequency_penalty,omitempty"` 53 | BestOf int `json:"best_of,omitempty"` 54 | LogitBias map[string]int `json:"logit_bias,omitempty"` 55 | User string `json:"user,omitempty"` 56 | //SessionID string `json:"session_id"` 57 | } 58 | 59 | // CompletionChoice represents one of possible completions. 60 | type CompletionChoice struct { 61 | Text string `json:"text"` 62 | Index int `json:"index"` 63 | FinishReason string `json:"finish_reason"` 64 | LogProbs LogprobResult `json:"logprobs"` 65 | } 66 | 67 | // LogprobResult represents logprob result of Choice. 68 | type LogprobResult struct { 69 | Tokens []string `json:"tokens"` 70 | TokenLogprobs []float32 `json:"token_logprobs"` 71 | TopLogprobs []map[string]float32 `json:"top_logprobs"` 72 | TextOffset []int `json:"text_offset"` 73 | } 74 | 75 | // CompletionResponse represents a response structure for completion API. 76 | type CompletionResponse struct { 77 | ID string `json:"id"` 78 | Object string `json:"object"` 79 | Created uint64 `json:"created"` 80 | Model string `json:"model"` 81 | Choices []CompletionChoice `json:"choices"` 82 | Usage Usage `json:"usage"` 83 | } 84 | 85 | // CreateCompletion — API call to create a completion. This is the main endpoint of the API. Returns new text as well 86 | // as, if requested, the probabilities over each alternative token at each position. 87 | // 88 | // If using a fine-tuned model, simply provide the model's ID in the CompletionRequest object, 89 | // and the server will use the model's parameters to generate the completion. 90 | func (c *Client) CreateCompletion( 91 | ctx context.Context, 92 | request CompletionRequest, 93 | ) (response CompletionResponse, err error) { 94 | var reqBytes []byte 95 | reqBytes, err = json.Marshal(request) 96 | if err != nil { 97 | return 98 | } 99 | 100 | urlSuffix := "/completions" 101 | req, err := http.NewRequest("POST", c.fullURL(urlSuffix), bytes.NewBuffer(reqBytes)) 102 | if err != nil { 103 | return 104 | } 105 | 106 | req = req.WithContext(ctx) 107 | err = c.sendRequest(req, &response) 108 | return 109 | } 110 | -------------------------------------------------------------------------------- /chatgpt/edits.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "net/http" 8 | ) 9 | 10 | // EditsRequest represents a request structure for Edits API. 11 | type EditsRequest struct { 12 | Model *string `json:"model,omitempty"` 13 | Input string `json:"input,omitempty"` 14 | Instruction string `json:"instruction,omitempty"` 15 | N int `json:"n,omitempty"` 16 | Temperature float32 `json:"temperature,omitempty"` 17 | TopP float32 `json:"top_p,omitempty"` 18 | } 19 | 20 | // EditsChoice represents one of possible edits. 21 | type EditsChoice struct { 22 | Text string `json:"text"` 23 | Index int `json:"index"` 24 | } 25 | 26 | // EditsResponse represents a response structure for Edits API. 27 | type EditsResponse struct { 28 | Object string `json:"object"` 29 | Created uint64 `json:"created"` 30 | Usage Usage `json:"usage"` 31 | Choices []EditsChoice `json:"choices"` 32 | } 33 | 34 | // Perform an API call to the Edits endpoint. 35 | func (c *Client) Edits(ctx context.Context, request EditsRequest) (response EditsResponse, err error) { 36 | var reqBytes []byte 37 | reqBytes, err = json.Marshal(request) 38 | if err != nil { 39 | return 40 | } 41 | 42 | req, err := http.NewRequest("POST", c.fullURL("/edits"), bytes.NewBuffer(reqBytes)) 43 | if err != nil { 44 | return 45 | } 46 | 47 | req = req.WithContext(ctx) 48 | err = c.sendRequest(req, &response) 49 | return 50 | } 51 | -------------------------------------------------------------------------------- /chatgpt/embeddings.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "net/http" 8 | ) 9 | 10 | // EmbeddingModel enumerates the models which can be used 11 | // to generate Embedding vectors. 12 | type EmbeddingModel int 13 | 14 | // String implements the fmt.Stringer interface. 15 | func (e EmbeddingModel) String() string { 16 | return enumToString[e] 17 | } 18 | 19 | // MarshalText implements the encoding.TextMarshaler interface. 20 | func (e EmbeddingModel) MarshalText() ([]byte, error) { 21 | return []byte(e.String()), nil 22 | } 23 | 24 | // UnmarshalText implements the encoding.TextUnmarshaler interface. 25 | // On unrecognized value, it sets |e| to Unknown. 26 | func (e *EmbeddingModel) UnmarshalText(b []byte) error { 27 | if val, ok := stringToEnum[(string(b))]; ok { 28 | *e = val 29 | return nil 30 | } 31 | 32 | *e = Unknown 33 | 34 | return nil 35 | } 36 | 37 | const ( 38 | Unknown EmbeddingModel = iota 39 | AdaSimilarity 40 | BabbageSimilarity 41 | CurieSimilarity 42 | DavinciSimilarity 43 | AdaSearchDocument 44 | AdaSearchQuery 45 | BabbageSearchDocument 46 | BabbageSearchQuery 47 | CurieSearchDocument 48 | CurieSearchQuery 49 | DavinciSearchDocument 50 | DavinciSearchQuery 51 | AdaCodeSearchCode 52 | AdaCodeSearchText 53 | BabbageCodeSearchCode 54 | BabbageCodeSearchText 55 | AdaEmbeddingV2 56 | ) 57 | 58 | var enumToString = map[EmbeddingModel]string{ 59 | AdaSimilarity: "text-similarity-ada-001", 60 | BabbageSimilarity: "text-similarity-babbage-001", 61 | CurieSimilarity: "text-similarity-curie-001", 62 | DavinciSimilarity: "text-similarity-davinci-001", 63 | AdaSearchDocument: "text-search-ada-doc-001", 64 | AdaSearchQuery: "text-search-ada-query-001", 65 | BabbageSearchDocument: "text-search-babbage-doc-001", 66 | BabbageSearchQuery: "text-search-babbage-query-001", 67 | CurieSearchDocument: "text-search-curie-doc-001", 68 | CurieSearchQuery: "text-search-curie-query-001", 69 | DavinciSearchDocument: "text-search-davinci-doc-001", 70 | DavinciSearchQuery: "text-search-davinci-query-001", 71 | AdaCodeSearchCode: "code-search-ada-code-001", 72 | AdaCodeSearchText: "code-search-ada-text-001", 73 | BabbageCodeSearchCode: "code-search-babbage-code-001", 74 | BabbageCodeSearchText: "code-search-babbage-text-001", 75 | AdaEmbeddingV2: "text-embedding-ada-002", 76 | } 77 | 78 | var stringToEnum = map[string]EmbeddingModel{ 79 | "text-similarity-ada-001": AdaSimilarity, 80 | "text-similarity-babbage-001": BabbageSimilarity, 81 | "text-similarity-curie-001": CurieSimilarity, 82 | "text-similarity-davinci-001": DavinciSimilarity, 83 | "text-search-ada-doc-001": AdaSearchDocument, 84 | "text-search-ada-query-001": AdaSearchQuery, 85 | "text-search-babbage-doc-001": BabbageSearchDocument, 86 | "text-search-babbage-query-001": BabbageSearchQuery, 87 | "text-search-curie-doc-001": CurieSearchDocument, 88 | "text-search-curie-query-001": CurieSearchQuery, 89 | "text-search-davinci-doc-001": DavinciSearchDocument, 90 | "text-search-davinci-query-001": DavinciSearchQuery, 91 | "code-search-ada-code-001": AdaCodeSearchCode, 92 | "code-search-ada-text-001": AdaCodeSearchText, 93 | "code-search-babbage-code-001": BabbageCodeSearchCode, 94 | "code-search-babbage-text-001": BabbageCodeSearchText, 95 | "text-embedding-ada-002": AdaEmbeddingV2, 96 | } 97 | 98 | // Embedding is a special format of data representation that can be easily utilized by machine 99 | // learning models and algorithms. The embedding is an information dense representation of the 100 | // semantic meaning of a piece of text. Each embedding is a vector of floating point numbers, 101 | // such that the distance between two embeddings in the vector space is correlated with semantic similarity 102 | // between two inputs in the original format. For example, if two texts are similar, 103 | // then their vector representations should also be similar. 104 | type Embedding struct { 105 | Object string `json:"object"` 106 | Embedding []float64 `json:"embedding"` 107 | Index int `json:"index"` 108 | } 109 | 110 | // EmbeddingResponse is the response from a Create embeddings request. 111 | type EmbeddingResponse struct { 112 | Object string `json:"object"` 113 | Data []Embedding `json:"data"` 114 | Model EmbeddingModel `json:"model"` 115 | Usage Usage `json:"usage"` 116 | } 117 | 118 | // EmbeddingRequest is the input to a Create embeddings request. 119 | type EmbeddingRequest struct { 120 | // Input is a slice of strings for which you want to generate an Embedding vector. 121 | // Each input must not exceed 2048 tokens in length. 122 | // OpenAPI suggests replacing newlines (\n) in your input with a single space, as they 123 | // have observed inferior results when newlines are present. 124 | // E.g. 125 | // "The food was delicious and the waiter..." 126 | Input []string `json:"input"` 127 | // ID of the model to use. You can use the List models API to see all of your available models, 128 | // or see our Model overview for descriptions of them. 129 | Model EmbeddingModel `json:"model"` 130 | // A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse. 131 | User string `json:"user"` 132 | } 133 | 134 | // CreateEmbeddings returns an EmbeddingResponse which will contain an Embedding for every item in |request.Input|. 135 | // https://beta.openai.com/docs/api-reference/embeddings/create 136 | func (c *Client) CreateEmbeddings(ctx context.Context, request EmbeddingRequest) (resp EmbeddingResponse, err error) { 137 | var reqBytes []byte 138 | reqBytes, err = json.Marshal(request) 139 | if err != nil { 140 | return 141 | } 142 | 143 | urlSuffix := "/embeddings" 144 | req, err := http.NewRequest(http.MethodPost, c.fullURL(urlSuffix), bytes.NewBuffer(reqBytes)) 145 | if err != nil { 146 | return 147 | } 148 | 149 | req = req.WithContext(ctx) 150 | err = c.sendRequest(req, &resp) 151 | 152 | return 153 | } 154 | -------------------------------------------------------------------------------- /chatgpt/engines.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "net/http" 7 | ) 8 | 9 | // Engine struct represents engine from OpenAPI API. 10 | type Engine struct { 11 | ID string `json:"id"` 12 | Object string `json:"object"` 13 | Owner string `json:"owner"` 14 | Ready bool `json:"ready"` 15 | } 16 | 17 | // EnginesList is a list of engines. 18 | type EnginesList struct { 19 | Engines []Engine `json:"data"` 20 | } 21 | 22 | // ListEngines Lists the currently available engines, and provides basic 23 | // information about each option such as the owner and availability. 24 | func (c *Client) ListEngines(ctx context.Context) (engines EnginesList, err error) { 25 | req, err := http.NewRequest("GET", c.fullURL("/engines"), nil) 26 | if err != nil { 27 | return 28 | } 29 | 30 | req = req.WithContext(ctx) 31 | err = c.sendRequest(req, &engines) 32 | return 33 | } 34 | 35 | // GetEngine Retrieves an engine instance, providing basic information about 36 | // the engine such as the owner and availability. 37 | func (c *Client) GetEngine( 38 | ctx context.Context, 39 | engineID string, 40 | ) (engine Engine, err error) { 41 | urlSuffix := fmt.Sprintf("/engines/%s", engineID) 42 | req, err := http.NewRequest("GET", c.fullURL(urlSuffix), nil) 43 | if err != nil { 44 | return 45 | } 46 | 47 | req = req.WithContext(ctx) 48 | err = c.sendRequest(req, &engine) 49 | return 50 | } 51 | -------------------------------------------------------------------------------- /chatgpt/error.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | type ErrorResponse struct { 4 | Error *struct { 5 | Code *int `json:"code,omitempty"` 6 | Message string `json:"message"` 7 | Param *string `json:"param,omitempty"` 8 | Type string `json:"type"` 9 | } `json:"error,omitempty"` 10 | } 11 | -------------------------------------------------------------------------------- /chatgpt/files.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "fmt" 7 | "io" 8 | "mime/multipart" 9 | "net/http" 10 | "net/url" 11 | "os" 12 | "strings" 13 | ) 14 | 15 | type FileRequest struct { 16 | FileName string `json:"file"` 17 | FilePath string `json:"-"` 18 | Purpose string `json:"purpose"` 19 | } 20 | 21 | // File struct represents an OpenAPI file. 22 | type File struct { 23 | Bytes int `json:"bytes"` 24 | CreatedAt int `json:"created_at"` 25 | ID string `json:"id"` 26 | FileName string `json:"filename"` 27 | Object string `json:"object"` 28 | Owner string `json:"owner"` 29 | Purpose string `json:"purpose"` 30 | } 31 | 32 | // FilesList is a list of files that belong to the user or organization. 33 | type FilesList struct { 34 | Files []File `json:"data"` 35 | } 36 | 37 | // isUrl is a helper function that determines whether the given FilePath 38 | // is a remote URL or a local file path. 39 | func isURL(path string) bool { 40 | _, err := url.ParseRequestURI(path) 41 | if err != nil { 42 | return false 43 | } 44 | 45 | u, err := url.Parse(path) 46 | if err != nil || u.Scheme == "" || u.Host == "" { 47 | return false 48 | } 49 | 50 | return true 51 | } 52 | 53 | // CreateFile uploads a jsonl file to GPT3 54 | // FilePath can be either a local file path or a URL. 55 | func (c *Client) CreateFile(ctx context.Context, request FileRequest) (file File, err error) { 56 | var b bytes.Buffer 57 | w := multipart.NewWriter(&b) 58 | 59 | var fw, pw io.Writer 60 | pw, err = w.CreateFormField("purpose") 61 | if err != nil { 62 | return 63 | } 64 | 65 | _, err = io.Copy(pw, strings.NewReader(request.Purpose)) 66 | if err != nil { 67 | return 68 | } 69 | 70 | fw, err = w.CreateFormFile("file", request.FileName) 71 | if err != nil { 72 | return 73 | } 74 | 75 | var fileData io.ReadCloser 76 | if isURL(request.FilePath) { 77 | var remoteFile *http.Response 78 | remoteFile, err = http.Get(request.FilePath) 79 | if err != nil { 80 | return 81 | } 82 | 83 | defer remoteFile.Body.Close() 84 | 85 | // Check server response 86 | if remoteFile.StatusCode != http.StatusOK { 87 | err = fmt.Errorf("error, status code: %d, message: failed to fetch file", remoteFile.StatusCode) 88 | return 89 | } 90 | 91 | fileData = remoteFile.Body 92 | } else { 93 | fileData, err = os.Open(request.FilePath) 94 | if err != nil { 95 | return 96 | } 97 | } 98 | 99 | _, err = io.Copy(fw, fileData) 100 | if err != nil { 101 | return 102 | } 103 | 104 | w.Close() 105 | 106 | req, err := http.NewRequest("POST", c.fullURL("/files"), &b) 107 | if err != nil { 108 | return 109 | } 110 | 111 | req = req.WithContext(ctx) 112 | req.Header.Set("Content-Type", w.FormDataContentType()) 113 | 114 | err = c.sendRequest(req, &file) 115 | 116 | return 117 | } 118 | 119 | // DeleteFile deletes an existing file. 120 | func (c *Client) DeleteFile(ctx context.Context, fileID string) (err error) { 121 | req, err := http.NewRequest("DELETE", c.fullURL("/files/"+fileID), nil) 122 | if err != nil { 123 | return 124 | } 125 | 126 | req = req.WithContext(ctx) 127 | err = c.sendRequest(req, nil) 128 | return 129 | } 130 | 131 | // ListFiles Lists the currently available files, 132 | // and provides basic information about each file such as the file name and purpose. 133 | func (c *Client) ListFiles(ctx context.Context) (files FilesList, err error) { 134 | req, err := http.NewRequest("GET", c.fullURL("/files"), nil) 135 | if err != nil { 136 | return 137 | } 138 | 139 | req = req.WithContext(ctx) 140 | err = c.sendRequest(req, &files) 141 | return 142 | } 143 | 144 | // GetFile Retrieves a file instance, providing basic information about the file 145 | // such as the file name and purpose. 146 | func (c *Client) GetFile(ctx context.Context, fileID string) (file File, err error) { 147 | urlSuffix := fmt.Sprintf("/files/%s", fileID) 148 | req, err := http.NewRequest("GET", c.fullURL(urlSuffix), nil) 149 | if err != nil { 150 | return 151 | } 152 | 153 | req = req.WithContext(ctx) 154 | err = c.sendRequest(req, &file) 155 | return 156 | } 157 | -------------------------------------------------------------------------------- /chatgpt/moderation.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "net/http" 8 | ) 9 | 10 | // ModerationRequest represents a request structure for moderation API. 11 | type ModerationRequest struct { 12 | Input string `json:"input,omitempty"` 13 | Model *string `json:"model,omitempty"` 14 | } 15 | 16 | // Result represents one of possible moderation results. 17 | type Result struct { 18 | Categories ResultCategories `json:"categories"` 19 | CategoryScores ResultCategoryScores `json:"category_scores"` 20 | Flagged bool `json:"flagged"` 21 | } 22 | 23 | // ResultCategories represents Categories of Result. 24 | type ResultCategories struct { 25 | Hate bool `json:"hate"` 26 | HateThreatening bool `json:"hate/threatening"` 27 | SelfHarm bool `json:"self-harm"` 28 | Sexual bool `json:"sexual"` 29 | SexualMinors bool `json:"sexual/minors"` 30 | Violence bool `json:"violence"` 31 | ViolenceGraphic bool `json:"violence/graphic"` 32 | } 33 | 34 | // ResultCategoryScores represents CategoryScores of Result. 35 | type ResultCategoryScores struct { 36 | Hate float32 `json:"hate"` 37 | HateThreatening float32 `json:"hate/threatening"` 38 | SelfHarm float32 `json:"self-harm"` 39 | Sexual float32 `json:"sexual"` 40 | SexualMinors float32 `json:"sexual/minors"` 41 | Violence float32 `json:"violence"` 42 | ViolenceGraphic float32 `json:"violence/graphic"` 43 | } 44 | 45 | // ModerationResponse represents a response structure for moderation API. 46 | type ModerationResponse struct { 47 | ID string `json:"id"` 48 | Model string `json:"model"` 49 | Results []Result `json:"results"` 50 | } 51 | 52 | // Moderations — perform a moderation api call over a string. 53 | // Input can be an array or slice but a string will reduce the complexity. 54 | func (c *Client) Moderations(ctx context.Context, request ModerationRequest) (response ModerationResponse, err error) { 55 | var reqBytes []byte 56 | reqBytes, err = json.Marshal(request) 57 | if err != nil { 58 | return 59 | } 60 | 61 | req, err := http.NewRequest("POST", c.fullURL("/moderations"), bytes.NewBuffer(reqBytes)) 62 | if err != nil { 63 | return 64 | } 65 | 66 | req = req.WithContext(ctx) 67 | err = c.sendRequest(req, &response) 68 | return 69 | } 70 | -------------------------------------------------------------------------------- /chatgpt/search.go: -------------------------------------------------------------------------------- 1 | package gogpt 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "fmt" 8 | "net/http" 9 | ) 10 | 11 | /* 12 | - SearchRequest represents a request structure for search API. 13 | 14 | - Info (*): 15 | - 1*) You should specify either 'documents' or a 'file', but not both. 16 | - 2*) This flag only takes effect when file is set. 17 | */ 18 | type SearchRequest struct { 19 | Query string `json:"query"` 20 | Documents []string `json:"documents"` // 1* 21 | FileID string `json:"file,omitempty"` // 1* 22 | MaxRerank int `json:"max_rerank,omitempty"` // 2* 23 | ReturnMetadata bool `json:"return_metadata,omitempty"` 24 | User string `json:"user,omitempty"` 25 | } 26 | 27 | // SearchResult represents single result from search API. 28 | type SearchResult struct { 29 | Document int `json:"document"` 30 | Object string `json:"object"` 31 | Score float32 `json:"score"` 32 | Metadata string `json:"metadata"` // 2* 33 | } 34 | 35 | // SearchResponse represents a response structure for search API. 36 | type SearchResponse struct { 37 | SearchResults []SearchResult `json:"data"` 38 | Object string `json:"object"` 39 | } 40 | 41 | // Search — perform a semantic search api call over a list of documents. 42 | func (c *Client) Search( 43 | ctx context.Context, 44 | engineID string, 45 | request SearchRequest, 46 | ) (response SearchResponse, err error) { 47 | var reqBytes []byte 48 | reqBytes, err = json.Marshal(request) 49 | if err != nil { 50 | return 51 | } 52 | 53 | urlSuffix := fmt.Sprintf("/engines/%s/search", engineID) 54 | req, err := http.NewRequest("POST", c.fullURL(urlSuffix), bytes.NewBuffer(reqBytes)) 55 | if err != nil { 56 | return 57 | } 58 | 59 | req = req.WithContext(ctx) 60 | err = c.sendRequest(req, &response) 61 | return 62 | } 63 | -------------------------------------------------------------------------------- /config.yaml: -------------------------------------------------------------------------------- 1 | 2 | # zap logger configuration 3 | zap: 4 | level: 'info' 5 | format: 'console' 6 | prefix: '[chatgptcn]' 7 | director: 'log' 8 | link-name: 'latest_log' 9 | show-line: true 10 | encode-level: 'LowercaseColorLevelEncoder' 11 | stacktrace-key: 'stacktrace' 12 | log-in-console: false 13 | 14 | # system configuration 15 | system: 16 | env: prod # Change to "develop" to skip authentication for development mode 17 | addr: 8899 18 | oss-type: local 19 | use-multipoint: true 20 | 21 | # 开启proxy的enable(true)的情况下,才会去调用GPT-3的API接口,如果enable为false,则不会去调用GPT-3的接口,而是会给客户端输出 info 的配置信息 22 | proxy: 23 | enable : false 24 | info: '正在调试程序,请稍候……' 25 | chatgptmodel: 'text-davinci-003' #默认是达芬奇模型,可以自己修改成想要的 26 | chatgpttoken : '123456' #换成自己在OpenAI的API-Key -------------------------------------------------------------------------------- /config/local.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Local struct { 4 | Path string `mapstructure:"path" json:"path" yaml:"path" ` 5 | } 6 | -------------------------------------------------------------------------------- /config/proxy.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Proxy struct { 4 | Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"` 5 | Info string `mapstructure:"info" json:"info" yaml:"info"` 6 | Chatgptmodel string `mapstructure:"chatgptmodel" json:"chatgptmodel" yaml:"chatgptmodel"` 7 | Chatgpttoken string `mapstructure:"chatgpttoken" json:"chatgpttoken" yaml:"chatgpttoken"` 8 | } 9 | -------------------------------------------------------------------------------- /config/server.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Server struct { 4 | Zap Zap `mapstructure:"zap" json:"zap" yaml:"zap"` 5 | System System `mapstructure:"system" json:"system" yaml:"system"` 6 | Local Local `mapstructure:"local" json:"local" yaml:"local"` 7 | Proxy Proxy `mapstructure:"proxy" json:"proxy" yaml:"proxy"` 8 | } 9 | -------------------------------------------------------------------------------- /config/system.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type System struct { 4 | Env string `mapstructure:"env" json:"env" yaml:"env"` 5 | Addr int `mapstructure:"addr" json:"addr" yaml:"addr"` 6 | DbType string `mapstructure:"db-type" json:"dbType" yaml:"db-type"` 7 | OssType string `mapstructure:"oss-type" json:"ossType" yaml:"oss-type"` 8 | UseMultipoint bool `mapstructure:"use-multipoint" json:"useMultipoint" yaml:"use-multipoint"` 9 | } 10 | -------------------------------------------------------------------------------- /config/zap.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Zap struct { 4 | Level string `mapstructure:"level" json:"level" yaml:"level"` 5 | Format string `mapstructure:"format" json:"format" yaml:"format"` 6 | Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` 7 | Director string `mapstructure:"director" json:"director" yaml:"director"` 8 | LinkName string `mapstructure:"link-name" json:"linkName" yaml:"link-name"` 9 | ShowLine bool `mapstructure:"show-line" json:"showLine" yaml:"showLine"` 10 | EncodeLevel string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level"` 11 | StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key"` 12 | LogInConsole bool `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console"` 13 | } 14 | -------------------------------------------------------------------------------- /core/server.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "chatgptcnserver/global" 5 | "chatgptcnserver/initialize" 6 | "fmt" 7 | "go.uber.org/zap" 8 | "time" 9 | ) 10 | 11 | type server interface { 12 | ListenAndServe() error 13 | } 14 | 15 | func RunWindowsServer() { 16 | Router := initialize.Routers() 17 | address := fmt.Sprintf(":%d", global.Chatgptcn_CONFIG.System.Addr) 18 | s := initServer(address, Router) 19 | // 保证文本顺序输出 20 | // In order to ensure that the text order output can be deleted 21 | time.Sleep(10 * time.Microsecond) 22 | global.Chatgptcn_LOG.Info("server run success on ", zap.String("address", address)) 23 | 24 | fmt.Printf(` 25 | 欢迎使用 Chatgptcn 26 | %s 27 | `, address) 28 | global.Chatgptcn_LOG.Error(s.ListenAndServe().Error()) 29 | } 30 | -------------------------------------------------------------------------------- /core/server_other.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "github.com/fvbock/endless" 5 | "github.com/gin-gonic/gin" 6 | "time" 7 | ) 8 | 9 | func initServer(address string, router *gin.Engine) server { 10 | s := endless.NewServer(address, router) 11 | s.ReadHeaderTimeout = 30 * time.Second 12 | s.WriteTimeout = 60 * time.Second 13 | s.MaxHeaderBytes = 1 << 20 14 | return s 15 | } 16 | -------------------------------------------------------------------------------- /core/viper.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "chatgptcnserver/global" 5 | "chatgptcnserver/utils" 6 | "flag" 7 | "fmt" 8 | "github.com/fsnotify/fsnotify" 9 | "github.com/spf13/viper" 10 | "os" 11 | ) 12 | 13 | func Viper(path ...string) *viper.Viper { 14 | var config string 15 | if len(path) == 0 { 16 | flag.StringVar(&config, "c", "", "choose config file.") 17 | flag.Parse() 18 | if config == "" { // 优先级: 命令行 > 环境变量 > 默认值 19 | if configEnv := os.Getenv(utils.ConfigEnv); configEnv == "" { 20 | config = utils.ConfigFile 21 | fmt.Printf("您正在使用config的默认值,config的路径为%v\n", utils.ConfigFile) 22 | } else { 23 | config = configEnv 24 | fmt.Printf("您正在使用ChatGPTCN_CONFIG环境变量,config的路径为%v\n", config) 25 | } 26 | } else { 27 | fmt.Printf("您正在使用命令行的-c参数传递的值,config的路径为%v\n", config) 28 | } 29 | } else { 30 | config = path[0] 31 | fmt.Printf("您正在使用func Viper()传递的值,config的路径为%v\n", config) 32 | } 33 | 34 | v := viper.New() 35 | v.SetConfigFile(config) 36 | err := v.ReadInConfig() 37 | if err != nil { 38 | panic(fmt.Errorf("Fatal error config file: %s \n", err)) 39 | } 40 | v.WatchConfig() 41 | 42 | v.OnConfigChange(func(e fsnotify.Event) { 43 | fmt.Println("config file changed:", e.Name) 44 | if err := v.Unmarshal(&global.Chatgptcn_CONFIG); err != nil { 45 | fmt.Println(err) 46 | } 47 | }) 48 | 49 | if err := v.Unmarshal(&global.Chatgptcn_CONFIG); err != nil { 50 | fmt.Println(err) 51 | } 52 | return v 53 | } 54 | -------------------------------------------------------------------------------- /core/zap.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "chatgptcnserver/global" 5 | "chatgptcnserver/utils" 6 | "fmt" 7 | "go.uber.org/zap" 8 | "go.uber.org/zap/zapcore" 9 | "os" 10 | "time" 11 | ) 12 | 13 | var level zapcore.Level 14 | 15 | func Zap() (logger *zap.Logger) { 16 | if ok, _ := utils.PathExists(global.Chatgptcn_CONFIG.Zap.Director); !ok { // 判断是否有Director文件夹 17 | fmt.Printf("create %v directory\n", global.Chatgptcn_CONFIG.Zap.Director) 18 | _ = os.Mkdir(global.Chatgptcn_CONFIG.Zap.Director, os.ModePerm) 19 | } 20 | 21 | switch global.Chatgptcn_CONFIG.Zap.Level { // 初始化配置文件的Level 22 | case "debug": 23 | level = zap.DebugLevel 24 | case "info": 25 | level = zap.InfoLevel 26 | case "warn": 27 | level = zap.WarnLevel 28 | case "error": 29 | level = zap.ErrorLevel 30 | case "dpanic": 31 | level = zap.DPanicLevel 32 | case "panic": 33 | level = zap.PanicLevel 34 | case "fatal": 35 | level = zap.FatalLevel 36 | default: 37 | level = zap.InfoLevel 38 | } 39 | 40 | if level == zap.DebugLevel || level == zap.ErrorLevel { 41 | logger = zap.New(getEncoderCore(), zap.AddStacktrace(level)) 42 | } else { 43 | logger = zap.New(getEncoderCore()) 44 | } 45 | if global.Chatgptcn_CONFIG.Zap.ShowLine { 46 | logger = logger.WithOptions(zap.AddCaller()) 47 | } 48 | return logger 49 | } 50 | 51 | // getEncoderConfig 获取zapcore.EncoderConfig 52 | func getEncoderConfig() (config zapcore.EncoderConfig) { 53 | config = zapcore.EncoderConfig{ 54 | MessageKey: "message", 55 | LevelKey: "level", 56 | TimeKey: "time", 57 | NameKey: "logger", 58 | CallerKey: "caller", 59 | StacktraceKey: global.Chatgptcn_CONFIG.Zap.StacktraceKey, 60 | LineEnding: zapcore.DefaultLineEnding, 61 | EncodeLevel: zapcore.LowercaseLevelEncoder, 62 | EncodeTime: CustomTimeEncoder, 63 | EncodeDuration: zapcore.SecondsDurationEncoder, 64 | EncodeCaller: zapcore.FullCallerEncoder, 65 | } 66 | switch { 67 | case global.Chatgptcn_CONFIG.Zap.EncodeLevel == "LowercaseLevelEncoder": // 小写编码器(默认) 68 | config.EncodeLevel = zapcore.LowercaseLevelEncoder 69 | case global.Chatgptcn_CONFIG.Zap.EncodeLevel == "LowercaseColorLevelEncoder": // 小写编码器带颜色 70 | config.EncodeLevel = zapcore.LowercaseColorLevelEncoder 71 | case global.Chatgptcn_CONFIG.Zap.EncodeLevel == "CapitalLevelEncoder": // 大写编码器 72 | config.EncodeLevel = zapcore.CapitalLevelEncoder 73 | case global.Chatgptcn_CONFIG.Zap.EncodeLevel == "CapitalColorLevelEncoder": // 大写编码器带颜色 74 | config.EncodeLevel = zapcore.CapitalColorLevelEncoder 75 | default: 76 | config.EncodeLevel = zapcore.LowercaseLevelEncoder 77 | } 78 | return config 79 | } 80 | 81 | // getEncoder 获取zapcore.Encoder 82 | func getEncoder() zapcore.Encoder { 83 | if global.Chatgptcn_CONFIG.Zap.Format == "json" { 84 | return zapcore.NewJSONEncoder(getEncoderConfig()) 85 | } 86 | return zapcore.NewConsoleEncoder(getEncoderConfig()) 87 | } 88 | 89 | // getEncoderCore 获取Encoder的zapcore.Core 90 | func getEncoderCore() (core zapcore.Core) { 91 | writer, err := utils.GetWriteSyncer() // 使用file-rotatelogs进行日志分割 92 | if err != nil { 93 | fmt.Printf("Get Write Syncer Failed err:%v", err.Error()) 94 | return 95 | } 96 | return zapcore.NewCore(getEncoder(), writer, level) 97 | } 98 | 99 | // 自定义日志输出时间格式 100 | func CustomTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) { 101 | enc.AppendString(t.Format(global.Chatgptcn_CONFIG.Zap.Prefix + "2006/01/02 - 15:04:05.000")) 102 | } 103 | -------------------------------------------------------------------------------- /global/global.go: -------------------------------------------------------------------------------- 1 | package global 2 | 3 | import ( 4 | gogpt "chatgptcnserver/chatgpt" 5 | "chatgptcnserver/config" 6 | "github.com/spf13/viper" 7 | "go.uber.org/zap" 8 | ) 9 | 10 | var ( 11 | Chatgptcn_CONFIG config.Server 12 | Chatgptcn_LOG *zap.Logger 13 | Chatgptcn_VP *viper.Viper 14 | Gogpt *gogpt.Client 15 | ) 16 | -------------------------------------------------------------------------------- /global/model.go: -------------------------------------------------------------------------------- 1 | package global 2 | 3 | import ( 4 | "gorm.io/gorm" 5 | "time" 6 | ) 7 | 8 | type ChatGPT_MODEL struct { 9 | ID uint `gorm:"primarykey"` 10 | CreatedAt time.Time 11 | UpdatedAt time.Time 12 | DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` 13 | } 14 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module chatgptcnserver 2 | 3 | go 1.18 4 | 5 | require ( 6 | github.com/fsnotify/fsnotify v1.6.0 7 | github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 8 | github.com/gin-gonic/gin v1.8.1 9 | github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible 10 | github.com/spf13/viper v1.14.0 11 | go.uber.org/zap v1.24.0 12 | golang.org/x/net v0.4.0 13 | gorm.io/driver/mysql v1.4.4 14 | gorm.io/gorm v1.24.2 15 | ) 16 | 17 | require ( 18 | github.com/gin-contrib/cors v1.4.0 // indirect 19 | github.com/gin-contrib/sse v0.1.0 // indirect 20 | github.com/go-playground/locales v0.14.0 // indirect 21 | github.com/go-playground/universal-translator v0.18.0 // indirect 22 | github.com/go-playground/validator/v10 v10.10.0 // indirect 23 | github.com/go-sql-driver/mysql v1.6.0 // indirect 24 | github.com/goccy/go-json v0.9.7 // indirect 25 | github.com/hashicorp/hcl v1.0.0 // indirect 26 | github.com/jinzhu/inflection v1.0.0 // indirect 27 | github.com/jinzhu/now v1.1.5 // indirect 28 | github.com/jonboulle/clockwork v0.3.0 // indirect 29 | github.com/json-iterator/go v1.1.12 // indirect 30 | github.com/leodido/go-urn v1.2.1 // indirect 31 | github.com/lestrrat-go/strftime v1.0.6 // indirect 32 | github.com/magiconair/properties v1.8.6 // indirect 33 | github.com/mattn/go-isatty v0.0.14 // indirect 34 | github.com/mitchellh/mapstructure v1.5.0 // indirect 35 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 36 | github.com/modern-go/reflect2 v1.0.2 // indirect 37 | github.com/pelletier/go-toml v1.9.5 // indirect 38 | github.com/pelletier/go-toml/v2 v2.0.5 // indirect 39 | github.com/pkg/errors v0.9.1 // indirect 40 | github.com/sashabaranov/go-gpt3 v0.0.0-20221216095610-1c20931ead68 // indirect 41 | github.com/spf13/afero v1.9.2 // indirect 42 | github.com/spf13/cast v1.5.0 // indirect 43 | github.com/spf13/jwalterweatherman v1.1.0 // indirect 44 | github.com/spf13/pflag v1.0.5 // indirect 45 | github.com/subosito/gotenv v1.4.1 // indirect 46 | github.com/ugorji/go/codec v1.2.7 // indirect 47 | github.com/unrolled/secure v1.13.0 // indirect 48 | go.uber.org/atomic v1.9.0 // indirect 49 | go.uber.org/multierr v1.8.0 // indirect 50 | golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect 51 | golang.org/x/sys v0.3.0 // indirect 52 | golang.org/x/text v0.5.0 // indirect 53 | google.golang.org/protobuf v1.28.1 // indirect 54 | gopkg.in/ini.v1 v1.67.0 // indirect 55 | gopkg.in/yaml.v2 v2.4.0 // indirect 56 | gopkg.in/yaml.v3 v3.0.1 // indirect 57 | ) 58 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= 4 | cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= 5 | cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= 6 | cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= 7 | cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= 8 | cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= 9 | cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= 10 | cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= 11 | cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= 12 | cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= 13 | cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= 14 | cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= 15 | cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= 16 | cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= 17 | cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= 18 | cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= 19 | cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= 20 | cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= 21 | cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= 22 | cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= 23 | cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= 24 | cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= 25 | cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= 26 | cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= 27 | cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= 28 | cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= 29 | cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= 30 | cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= 31 | cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= 32 | cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= 33 | cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= 34 | cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= 35 | cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= 36 | cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= 37 | cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= 38 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= 39 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 40 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= 41 | github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= 42 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 43 | github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= 44 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= 45 | github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= 46 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 47 | github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= 48 | github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= 49 | github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= 50 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 51 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 52 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 53 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 54 | github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 55 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 56 | github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= 57 | github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= 58 | github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= 59 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 60 | github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= 61 | github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= 62 | github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= 63 | github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 h1:6VSn3hB5U5GeA6kQw4TwWIWbOhtvR2hmbBJnTOtqTWc= 64 | github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6/go.mod h1:YxOVT5+yHzKvwhsiSIWmbAYM3Dr9AEEbER2dVayfBkg= 65 | github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g= 66 | github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs= 67 | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= 68 | github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= 69 | github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= 70 | github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= 71 | github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= 72 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= 73 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= 74 | github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= 75 | github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= 76 | github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= 77 | github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= 78 | github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= 79 | github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= 80 | github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0= 81 | github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= 82 | github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= 83 | github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= 84 | github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM= 85 | github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= 86 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 87 | github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 88 | github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 89 | github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 90 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 91 | github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 92 | github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= 93 | github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 94 | github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 95 | github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 96 | github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= 97 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 98 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 99 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 100 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 101 | github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 102 | github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= 103 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 104 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 105 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 106 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 107 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 108 | github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= 109 | github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 110 | github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 111 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 112 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 113 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 114 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 115 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 116 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 117 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 118 | github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 119 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 120 | github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 121 | github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 122 | github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 123 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 124 | github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= 125 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 126 | github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= 127 | github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= 128 | github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= 129 | github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 130 | github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 131 | github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 132 | github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 133 | github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 134 | github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 135 | github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 136 | github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 137 | github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 138 | github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 139 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= 140 | github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 141 | github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= 142 | github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= 143 | github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= 144 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 145 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 146 | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= 147 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 148 | github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= 149 | github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= 150 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 151 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 152 | github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 153 | github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= 154 | github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 155 | github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= 156 | github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= 157 | github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= 158 | github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= 159 | github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= 160 | github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= 161 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 162 | github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= 163 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 164 | github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 165 | github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= 166 | github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= 167 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 168 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 169 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 170 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 171 | github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= 172 | github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= 173 | github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8= 174 | github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is= 175 | github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4= 176 | github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA= 177 | github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ= 178 | github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw= 179 | github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= 180 | github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= 181 | github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= 182 | github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= 183 | github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= 184 | github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= 185 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 186 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 187 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 188 | github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= 189 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 190 | github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= 191 | github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= 192 | github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= 193 | github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg= 194 | github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas= 195 | github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= 196 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 197 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 198 | github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= 199 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 200 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 201 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 202 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= 203 | github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= 204 | github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= 205 | github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= 206 | github.com/sashabaranov/go-gpt3 v0.0.0-20221216095610-1c20931ead68 h1:0g+W77usi8tTHViKpQQr7MHphLsI32zX8HtOeigDGKo= 207 | github.com/sashabaranov/go-gpt3 v0.0.0-20221216095610-1c20931ead68/go.mod h1:BIZdbwdzxZbCrcKGMGH6u2eyGe1xFuX9Anmh3tCP8lQ= 208 | github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw= 209 | github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= 210 | github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= 211 | github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= 212 | github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= 213 | github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= 214 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= 215 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 216 | github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU= 217 | github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As= 218 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 219 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 220 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 221 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 222 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 223 | github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= 224 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 225 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 226 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 227 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 228 | github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= 229 | github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= 230 | github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= 231 | github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= 232 | github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= 233 | github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= 234 | github.com/unrolled/secure v1.13.0 h1:sdr3Phw2+f8Px8HE5sd1EHdj1aV3yUwed/uZXChLFsk= 235 | github.com/unrolled/secure v1.13.0/go.mod h1:BmF5hyM6tXczk3MpQkFf1hpKSRqCyhqcbiQtiAF7+40= 236 | github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 237 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 238 | github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 239 | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 240 | go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= 241 | go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= 242 | go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 243 | go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 244 | go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 245 | go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= 246 | go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= 247 | go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= 248 | go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= 249 | go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= 250 | go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= 251 | go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= 252 | go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= 253 | go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= 254 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 255 | golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 256 | golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 257 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 258 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 259 | golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= 260 | golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 261 | golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 262 | golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= 263 | golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 264 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 265 | golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 266 | golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= 267 | golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= 268 | golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= 269 | golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 270 | golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 271 | golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 272 | golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= 273 | golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= 274 | golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= 275 | golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= 276 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 277 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 278 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 279 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 280 | golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 281 | golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 282 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 283 | golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= 284 | golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 285 | golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 286 | golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 287 | golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= 288 | golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= 289 | golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= 290 | golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= 291 | golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 292 | golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 293 | golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 294 | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 295 | golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 296 | golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 297 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 298 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 299 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 300 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 301 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 302 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 303 | golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 304 | golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 305 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 306 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 307 | golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 308 | golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 309 | golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 310 | golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 311 | golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 312 | golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 313 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 314 | golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 315 | golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 316 | golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 317 | golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 318 | golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 319 | golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 320 | golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 321 | golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 322 | golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 323 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 324 | golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 325 | golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 326 | golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 327 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 328 | golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= 329 | golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= 330 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 331 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 332 | golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 333 | golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 334 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 335 | golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 336 | golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 337 | golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 338 | golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 339 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 340 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 341 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 342 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 343 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 344 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 345 | golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 346 | golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 347 | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 348 | golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 349 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 350 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 351 | golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 352 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 353 | golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 354 | golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 355 | golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 356 | golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 357 | golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 358 | golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 359 | golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 360 | golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 361 | golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 362 | golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 363 | golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 364 | golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 365 | golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 366 | golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 367 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 368 | golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 369 | golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 370 | golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 371 | golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 372 | golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 373 | golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 374 | golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 375 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 376 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 377 | golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 378 | golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 379 | golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 380 | golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 381 | golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 382 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 383 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 384 | golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 385 | golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 386 | golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= 387 | golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 388 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 389 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 390 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 391 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 392 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 393 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 394 | golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 395 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 396 | golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= 397 | golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 398 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 399 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 400 | golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 401 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 402 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 403 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 404 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 405 | golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 406 | golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 407 | golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 408 | golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 409 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 410 | golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 411 | golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 412 | golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 413 | golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 414 | golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 415 | golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 416 | golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 417 | golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 418 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 419 | golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 420 | golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 421 | golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 422 | golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 423 | golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 424 | golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 425 | golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 426 | golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 427 | golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 428 | golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 429 | golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 430 | golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 431 | golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= 432 | golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= 433 | golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= 434 | golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 435 | golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 436 | golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 437 | golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 438 | golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 439 | golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 440 | golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 441 | golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= 442 | golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 443 | golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 444 | golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 445 | golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 446 | golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 447 | golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= 448 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 449 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 450 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 451 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 452 | google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= 453 | google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= 454 | google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 455 | google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 456 | google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 457 | google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 458 | google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 459 | google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 460 | google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 461 | google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 462 | google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 463 | google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 464 | google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= 465 | google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= 466 | google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= 467 | google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= 468 | google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= 469 | google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= 470 | google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= 471 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 472 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 473 | google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 474 | google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= 475 | google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 476 | google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 477 | google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 478 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 479 | google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 480 | google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 481 | google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 482 | google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 483 | google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 484 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 485 | google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= 486 | google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 487 | google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 488 | google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 489 | google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 490 | google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 491 | google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 492 | google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= 493 | google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 494 | google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 495 | google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 496 | google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 497 | google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 498 | google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 499 | google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 500 | google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 501 | google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= 502 | google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= 503 | google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= 504 | google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 505 | google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 506 | google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 507 | google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 508 | google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 509 | google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 510 | google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 511 | google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 512 | google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 513 | google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 514 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 515 | google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= 516 | google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 517 | google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 518 | google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= 519 | google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 520 | google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 521 | google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 522 | google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= 523 | google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= 524 | google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 525 | google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 526 | google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 527 | google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= 528 | google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= 529 | google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= 530 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 531 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 532 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 533 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 534 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 535 | google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 536 | google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 537 | google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 538 | google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= 539 | google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 540 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 541 | google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 542 | google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= 543 | google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 544 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 545 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 546 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= 547 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= 548 | gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= 549 | gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= 550 | gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= 551 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 552 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 553 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 554 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 555 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 556 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 557 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 558 | gorm.io/driver/mysql v1.4.4 h1:MX0K9Qvy0Na4o7qSC/YI7XxqUw5KDw01umqgID+svdQ= 559 | gorm.io/driver/mysql v1.4.4/go.mod h1:BCg8cKI+R0j/rZRQxeKis/forqRwRSYOR8OM3Wo6hOM= 560 | gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= 561 | gorm.io/gorm v1.24.2 h1:9wR6CFD+G8nOusLdvkZelOEhpJVwwHzpQOUM+REd6U0= 562 | gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= 563 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 564 | honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 565 | honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 566 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 567 | honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= 568 | honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= 569 | honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= 570 | rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= 571 | rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= 572 | rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= 573 | -------------------------------------------------------------------------------- /initialize/gogptclient.go: -------------------------------------------------------------------------------- 1 | package initialize 2 | 3 | import ( 4 | gogpt "chatgptcnserver/chatgpt" 5 | "chatgptcnserver/global" 6 | ) 7 | 8 | func InitGoGPTclient() (client *gogpt.Client) { 9 | api_key := global.Chatgptcn_CONFIG.Proxy.Chatgpttoken 10 | client = gogpt.NewClient(api_key) 11 | return 12 | } 13 | -------------------------------------------------------------------------------- /initialize/router.go: -------------------------------------------------------------------------------- 1 | package initialize 2 | 3 | import ( 4 | "chatgptcnserver/global" 5 | "chatgptcnserver/router" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | func Routers() *gin.Engine { 10 | var Router = gin.Default() 11 | // 方便统一添加路由组前缀 多服务器上线使用 12 | ApiGroup := Router.Group("") 13 | router.InitBaseRouter(ApiGroup) // 注册用户路由 14 | global.Chatgptcn_LOG.Info("router register success") 15 | return Router 16 | } 17 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "chatgptcnserver/core" 5 | "chatgptcnserver/global" 6 | "chatgptcnserver/initialize" 7 | ) 8 | 9 | func main() { 10 | global.Chatgptcn_VP = core.Viper() // 初始化Viper 11 | global.Chatgptcn_LOG = core.Zap() // 初始化zap日志库 12 | global.Gogpt = initialize.InitGoGPTclient() 13 | core.RunWindowsServer() 14 | } 15 | -------------------------------------------------------------------------------- /middleware/cors.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | "net/http" 6 | ) 7 | 8 | // 处理跨域请求,支持options访问 9 | func Cors() gin.HandlerFunc { 10 | return func(c *gin.Context) { 11 | method := c.Request.Method 12 | //origin := c.Request.Header.Get("Origin") 13 | c.Header("Access-Control-Allow-Origin", "*") 14 | c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id") 15 | c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS,DELETE,PUT") 16 | c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type, New-Token, New-Expires-At") 17 | c.Header("Access-Control-Allow-Credentials", "true") 18 | // 放行所有OPTIONS方法 19 | if method == "OPTIONS" { 20 | c.AbortWithStatus(http.StatusNoContent) 21 | } 22 | // 处理请求 23 | c.Next() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /middleware/tls.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "fmt" 5 | "github.com/gin-gonic/gin" 6 | "github.com/unrolled/secure" 7 | ) 8 | 9 | func LoadTls() gin.HandlerFunc { 10 | return func(c *gin.Context) { 11 | middleware := secure.New(secure.Options{ 12 | SSLRedirect: true, 13 | SSLHost: "localhost:8899", 14 | }) 15 | err := middleware.Process(c.Writer, c.Request) 16 | if err != nil { 17 | // 如果出现错误,请不要继续 18 | fmt.Println(err) 19 | return 20 | } 21 | // 继续往下处理 22 | c.Next() 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /model/clientquest.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type ClientQuest struct { 4 | Prompt string `json:"prompt" form:"prompt"` 5 | } 6 | -------------------------------------------------------------------------------- /model/response/response.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | "net/http" 6 | ) 7 | 8 | type Response struct { 9 | Code int `json:"code"` 10 | Data interface{} `json:"data"` 11 | Msg string `json:"msg"` 12 | } 13 | 14 | const ( 15 | ERROR = 7 16 | SUCCESS = 0 17 | MUSTCOM = 2 18 | ) 19 | 20 | func Result(code int, data interface{}, msg string, c *gin.Context) { 21 | // 开始时间 22 | c.JSON(http.StatusOK, Response{ 23 | code, 24 | data, 25 | msg, 26 | }) 27 | } 28 | 29 | func Ok(c *gin.Context) { 30 | Result(SUCCESS, map[string]interface{}{}, "success", c) 31 | } 32 | 33 | func OkWithMessage(message string, c *gin.Context) { 34 | Result(SUCCESS, map[string]interface{}{}, message, c) 35 | } 36 | 37 | func OkWithData(data interface{}, c *gin.Context) { 38 | Result(SUCCESS, data, "success", c) 39 | } 40 | func OkWithDatac(data interface{}, c *gin.Context) { 41 | Result(1, data, "success", c) 42 | } 43 | func OkWithDetailed(data interface{}, message string, c *gin.Context) { 44 | Result(SUCCESS, data, message, c) 45 | } 46 | 47 | func Fail(c *gin.Context) { 48 | Result(ERROR, map[string]interface{}{}, "failed", c) 49 | } 50 | 51 | func FailWithMessage(message string, c *gin.Context) { 52 | Result(ERROR, map[string]interface{}{}, message, c) 53 | } 54 | 55 | func FailWithDetailed(data interface{}, message string, c *gin.Context) { 56 | Result(ERROR, data, message, c) 57 | } 58 | 59 | func FailWithMustcom(data interface{}, message string, c *gin.Context) { 60 | Result(MUSTCOM, data, message, c) 61 | } 62 | -------------------------------------------------------------------------------- /router/clientreq.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | import ( 4 | "chatgptcnserver/api/v1" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | func InitBaseRouter(Router *gin.RouterGroup) { 9 | UserRouter := Router.Group("base") 10 | { 11 | UserRouter.POST("quest", v1.Questansw) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /service/cliengreq.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | gogpt "chatgptcnserver/chatgpt" 5 | "chatgptcnserver/global" 6 | "context" 7 | ) 8 | 9 | func RespClientQuest(prompt string) (res string, err error) { 10 | if !global.Chatgptcn_CONFIG.Proxy.Enable { 11 | res = global.Chatgptcn_CONFIG.Proxy.Info 12 | return 13 | } 14 | ctx := context.Background() 15 | req := gogpt.CompletionRequest{ 16 | Model: global.Chatgptcn_CONFIG.Proxy.Chatgptmodel, 17 | MaxTokens: 2048, 18 | Prompt: prompt, 19 | TopP: 1, 20 | FrequencyPenalty: 0, 21 | PresencePenalty: 0, 22 | } 23 | var resp gogpt.CompletionResponse 24 | resp, err = global.Gogpt.CreateCompletion(ctx, req) 25 | if err != nil { 26 | return 27 | } 28 | res = resp.Choices[0].Text 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /utils/constant.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | const ( 4 | ConfigEnv = "ChatGPTCN.TK" 5 | ConfigFile = "config.yaml" 6 | ) 7 | -------------------------------------------------------------------------------- /utils/directory.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "chatgptcnserver/global" 5 | "go.uber.org/zap" 6 | "os" 7 | ) 8 | 9 | // @title PathExists 10 | // @description 文件目录是否存在 11 | // @auth (2020/04/05 20:22) 12 | // @param path string 13 | // @return err error 14 | 15 | func PathExists(path string) (bool, error) { 16 | _, err := os.Stat(path) 17 | if err == nil { 18 | return true, nil 19 | } 20 | if os.IsNotExist(err) { 21 | return false, nil 22 | } 23 | return false, err 24 | } 25 | 26 | // @title createDir 27 | // @description 批量创建文件夹 28 | // @auth (2020/04/05 20:22) 29 | // @param dirs string 30 | // @return err error 31 | 32 | func CreateDir(dirs ...string) (err error) { 33 | for _, v := range dirs { 34 | exist, err := PathExists(v) 35 | if err != nil { 36 | return err 37 | } 38 | if !exist { 39 | global.Chatgptcn_LOG.Debug("create directory" + v) 40 | err = os.MkdirAll(v, os.ModePerm) 41 | if err != nil { 42 | global.Chatgptcn_LOG.Error("create directory"+v, zap.Any(" error:", err)) 43 | } 44 | } 45 | } 46 | return err 47 | } 48 | -------------------------------------------------------------------------------- /utils/guid.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "crypto/md5" 5 | "crypto/rand" 6 | "encoding/binary" 7 | "encoding/hex" 8 | "fmt" 9 | "io" 10 | "os" 11 | "sync/atomic" 12 | "time" 13 | ) 14 | 15 | var objectIdCounter uint32 = 0 16 | 17 | var machineId = readMachineId() 18 | 19 | type ObjectId string 20 | 21 | func readMachineId() []byte { 22 | var sum [3]byte 23 | id := sum[:] 24 | hostname, err1 := os.Hostname() 25 | if err1 != nil { 26 | _, err2 := io.ReadFull(rand.Reader, id) 27 | if err2 != nil { 28 | panic(fmt.Errorf("cannot get hostname: %v; %v", err1, err2)) 29 | } 30 | return id 31 | } 32 | hw := md5.New() 33 | hw.Write([]byte(hostname)) 34 | copy(id, hw.Sum(nil)) 35 | fmt.Println("readMachineId:" + string(id)) 36 | return id 37 | } 38 | 39 | // GUID returns a new unique ObjectId. 40 | // 4byte 时间, 41 | // 3byte 机器ID 42 | // 2byte pid 43 | // 3byte 自增ID 44 | func GetGUID() ObjectId { 45 | var b [12]byte 46 | // Timestamp, 4 bytes, big endian 47 | binary.BigEndian.PutUint32(b[:], uint32(time.Now().Unix())) 48 | // Machine, first 3 bytes of md5(hostname) 49 | b[4] = machineId[0] 50 | b[5] = machineId[1] 51 | b[6] = machineId[2] 52 | // Pid, 2 bytes, specs don't specify endianness, but we use big endian. 53 | pid := os.Getpid() 54 | b[7] = byte(pid >> 8) 55 | b[8] = byte(pid) 56 | // Increment, 3 bytes, big endian 57 | i := atomic.AddUint32(&objectIdCounter, 1) 58 | b[9] = byte(i >> 16) 59 | b[10] = byte(i >> 8) 60 | b[11] = byte(i) 61 | return ObjectId(b[:]) 62 | } 63 | 64 | // Hex returns a hex representation of the ObjectId. 65 | // 返回16进制对应的字符串 66 | func (id ObjectId) Hex() string { 67 | return hex.EncodeToString([]byte(id)) 68 | } 69 | -------------------------------------------------------------------------------- /utils/rotatelogs_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package utils 4 | 5 | import ( 6 | "chatgptcnserver/global" 7 | zaprotatelogs "github.com/lestrrat-go/file-rotatelogs" 8 | "go.uber.org/zap/zapcore" 9 | "os" 10 | "path" 11 | "time" 12 | ) 13 | 14 | // GetWriteSyncer zap logger中加入file-rotatelogs 15 | func GetWriteSyncer() (zapcore.WriteSyncer, error) { 16 | fileWriter, err := zaprotatelogs.New( 17 | path.Join(global.Chatgptcn_CONFIG.Zap.Director, "%Y-%m-%d.log"), 18 | zaprotatelogs.WithLinkName(global.Chatgptcn_CONFIG.Zap.LinkName), 19 | zaprotatelogs.WithMaxAge(365*24*time.Hour), 20 | zaprotatelogs.WithRotationTime(24*time.Hour), 21 | ) 22 | if global.Chatgptcn_CONFIG.Zap.LogInConsole { 23 | return zapcore.NewMultiWriteSyncer(zapcore.AddSync(os.Stdout), zapcore.AddSync(fileWriter)), err 24 | } 25 | return zapcore.AddSync(fileWriter), err 26 | } 27 | -------------------------------------------------------------------------------- /utils/rotatelogs_windows.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "chatgptcnserver/global" 5 | zaprotatelogs "github.com/lestrrat-go/file-rotatelogs" 6 | "go.uber.org/zap/zapcore" 7 | "os" 8 | "path" 9 | "time" 10 | ) 11 | 12 | // GetWriteSyncer zap logger中加入file-rotatelogs 13 | func GetWriteSyncer() (zapcore.WriteSyncer, error) { 14 | fileWriter, err := zaprotatelogs.New( 15 | path.Join(global.YIA_CONFIG.Zap.Director, "%Y-%m-%d.log"), 16 | zaprotatelogs.WithMaxAge(365*24*time.Hour), 17 | zaprotatelogs.WithRotationTime(24*time.Hour), 18 | ) 19 | if global.YIA_CONFIG.Zap.LogInConsole { 20 | return zapcore.NewMultiWriteSyncer(zapcore.AddSync(os.Stdout), zapcore.AddSync(fileWriter)), err 21 | } 22 | return zapcore.AddSync(fileWriter), err 23 | } 24 | --------------------------------------------------------------------------------