diff options
author | guoguangwu <guoguangwug@gmail.com> | 2024-04-26 15:24:28 +0800 |
---|---|---|
committer | sudoforge <no-reply@sudoforge.com> | 2024-07-23 20:22:15 -0700 |
commit | d4f6f273bc36d8ce376cd7aee794458011fee2e0 (patch) | |
tree | bd2f95e167152d7554b10acd29d353370913e6f6 | |
parent | 1fa858dcf4c4e7b572316705d70c08545abae7ff (diff) | |
download | git-bug-d4f6f273bc36d8ce376cd7aee794458011fee2e0.tar.gz |
chore: remove refs to deprecated io/ioutil
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
chore: remove refs to deprecated io/ioutil
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
-rw-r--r-- | api/http/git_file_upload_handler.go | 4 | ||||
-rw-r--r-- | bridge/github/config.go | 8 | ||||
-rw-r--r-- | bridge/github/export.go | 6 | ||||
-rw-r--r-- | bridge/jira/client.go | 36 | ||||
-rw-r--r-- | commands/input/input.go | 8 | ||||
-rw-r--r-- | repository/gogit.go | 5 | ||||
-rw-r--r-- | termui/input_popup.go | 4 | ||||
-rw-r--r-- | webui/packed_assets.go | 3 |
8 files changed, 36 insertions, 38 deletions
diff --git a/api/http/git_file_upload_handler.go b/api/http/git_file_upload_handler.go index 1702b8b1..2f02baf1 100644 --- a/api/http/git_file_upload_handler.go +++ b/api/http/git_file_upload_handler.go @@ -3,7 +3,7 @@ package http import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "github.com/gorilla/mux" @@ -64,7 +64,7 @@ func (gufh *gitUploadFileHandler) ServeHTTP(rw http.ResponseWriter, r *http.Requ return } defer file.Close() - fileBytes, err := ioutil.ReadAll(file) + fileBytes, err := io.ReadAll(file) if err != nil { http.Error(rw, "invalid file", http.StatusBadRequest) return diff --git a/bridge/github/config.go b/bridge/github/config.go index 2f5d1f3b..9ae1d187 100644 --- a/bridge/github/config.go +++ b/bridge/github/config.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "regexp" @@ -233,7 +233,7 @@ func requestUserVerificationCode(scope string) (*githRespT, error) { return nil, fmt.Errorf("unexpected response status code %d from Github API", resp.StatusCode) } - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrap(err, "error requesting user verification code") } @@ -284,7 +284,7 @@ func pollGithubForAuthorization(deviceCode string, intervalSec int64) (string, e return "", fmt.Errorf("unexpected response status code %d from Github API", resp.StatusCode) } - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { _ = resp.Body.Close() return "", errors.Wrap(err, "error polling the Github API") @@ -490,7 +490,7 @@ func validateUsername(username string) (bool, string, error) { return false, "", nil } - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { return false, "", err } diff --git a/bridge/github/export.go b/bridge/github/export.go index 0d340b49..30e064c0 100644 --- a/bridge/github/export.go +++ b/bridge/github/export.go @@ -5,7 +5,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "os" "strings" @@ -452,7 +452,7 @@ func getRepositoryNodeID(ctx context.Context, token *auth.Token, owner, project NodeID string `json:"node_id"` }{} - data, _ := ioutil.ReadAll(resp.Body) + data, _ := io.ReadAll(resp.Body) err = resp.Body.Close() if err != nil { return "", err @@ -564,7 +564,7 @@ func (ge *githubExporter) createGithubLabel(ctx context.Context, label, color st Color string `json:"color"` }{} - data, _ = ioutil.ReadAll(resp.Body) + data, _ = io.ReadAll(resp.Body) defer resp.Body.Close() err = json.Unmarshal(data, &aux) diff --git a/bridge/jira/client.go b/bridge/jira/client.go index 0e4e561f..3ceffff2 100644 --- a/bridge/jira/client.go +++ b/bridge/jira/client.go @@ -6,7 +6,7 @@ import ( "encoding/base64" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/cookiejar" "net/url" @@ -421,12 +421,12 @@ func (client *Client) RefreshSessionTokenRaw(credentialsJSON []byte) error { defer response.Body.Close() if response.StatusCode != http.StatusOK { - content, _ := ioutil.ReadAll(response.Body) + content, _ := io.ReadAll(response.Body) return fmt.Errorf( "error creating token %v: %s", response.StatusCode, content) } - data, _ := ioutil.ReadAll(response.Body) + data, _ := io.ReadAll(response.Body) var aux SessionResponse err = json.Unmarshal(data, &aux) if err != nil { @@ -495,7 +495,7 @@ func (client *Client) Search(jql string, maxResults int, startAt int) (*SearchRe var message SearchResult - data, _ := ioutil.ReadAll(response.Body) + data, _ := io.ReadAll(response.Body) err = json.Unmarshal(data, &message) if err != nil { err := fmt.Errorf("Decoding response %v", err) @@ -623,7 +623,7 @@ func (client *Client) GetIssue(idOrKey string, fields []string, expand []string, var issue Issue - data, _ := ioutil.ReadAll(response.Body) + data, _ := io.ReadAll(response.Body) err = json.Unmarshal(data, &issue) if err != nil { err := fmt.Errorf("Decoding response %v", err) @@ -677,7 +677,7 @@ func (client *Client) GetComments(idOrKey string, maxResults int, startAt int) ( var comments CommentPage - data, _ := ioutil.ReadAll(response.Body) + data, _ := io.ReadAll(response.Body) err = json.Unmarshal(data, &comments) if err != nil { err := fmt.Errorf("Decoding response %v", err) @@ -819,7 +819,7 @@ func (client *Client) GetChangeLog(idOrKey string, maxResults int, startAt int) var changelog ChangeLogPage - data, _ := ioutil.ReadAll(response.Body) + data, _ := io.ReadAll(response.Body) err = json.Unmarshal(data, &changelog) if err != nil { err := fmt.Errorf("Decoding response %v", err) @@ -937,7 +937,7 @@ func (client *Client) GetProject(projectIDOrKey string) (*Project, error) { var project Project - data, _ := ioutil.ReadAll(response.Body) + data, _ := io.ReadAll(response.Body) err = json.Unmarshal(data, &project) if err != nil { err := fmt.Errorf("Decoding response %v", err) @@ -996,7 +996,7 @@ func (client *Client) CreateIssue(projectIDOrKey, title, body string, defer response.Body.Close() if response.StatusCode != http.StatusCreated { - content, _ := ioutil.ReadAll(response.Body) + content, _ := io.ReadAll(response.Body) err := fmt.Errorf( "HTTP response %d, query was %s\n data: %s\n response: %s", response.StatusCode, request.URL.String(), data, content) @@ -1005,7 +1005,7 @@ func (client *Client) CreateIssue(projectIDOrKey, title, body string, var result IssueCreateResult - data, _ = ioutil.ReadAll(response.Body) + data, _ = io.ReadAll(response.Body) err = json.Unmarshal(data, &result) if err != nil { err := fmt.Errorf("Decoding response %v", err) @@ -1048,7 +1048,7 @@ func (client *Client) UpdateIssueTitle(issueKeyOrID, title string) (time.Time, e defer response.Body.Close() if response.StatusCode != http.StatusNoContent { - content, _ := ioutil.ReadAll(response.Body) + content, _ := io.ReadAll(response.Body) err := fmt.Errorf( "HTTP response %d, query was %s\n data: %s\n response: %s", response.StatusCode, request.URL.String(), data, content) @@ -1108,7 +1108,7 @@ func (client *Client) UpdateIssueBody(issueKeyOrID, body string) (time.Time, err defer response.Body.Close() if response.StatusCode != http.StatusNoContent { - content, _ := ioutil.ReadAll(response.Body) + content, _ := io.ReadAll(response.Body) err := fmt.Errorf( "HTTP response %d, query was %s\n data: %s\n response: %s", response.StatusCode, request.URL.String(), data, content) @@ -1160,7 +1160,7 @@ func (client *Client) AddComment(issueKeyOrID, body string) (*Comment, error) { defer response.Body.Close() if response.StatusCode != http.StatusCreated { - content, _ := ioutil.ReadAll(response.Body) + content, _ := io.ReadAll(response.Body) err := fmt.Errorf( "HTTP response %d, query was %s\n data: %s\n response: %s", response.StatusCode, request.URL.String(), data, content) @@ -1169,7 +1169,7 @@ func (client *Client) AddComment(issueKeyOrID, body string) (*Comment, error) { var result Comment - data, _ = ioutil.ReadAll(response.Body) + data, _ = io.ReadAll(response.Body) err = json.Unmarshal(data, &result) if err != nil { err := fmt.Errorf("Decoding response %v", err) @@ -1219,7 +1219,7 @@ func (client *Client) UpdateComment(issueKeyOrID, commentID, body string) ( var result Comment - data, _ = ioutil.ReadAll(response.Body) + data, _ = io.ReadAll(response.Body) err = json.Unmarshal(data, &result) if err != nil { err := fmt.Errorf("Decoding response %v", err) @@ -1276,7 +1276,7 @@ func (client *Client) UpdateLabels(issueKeyOrID string, added, removed []bug.Lab defer response.Body.Close() if response.StatusCode != http.StatusNoContent { - content, _ := ioutil.ReadAll(response.Body) + content, _ := io.ReadAll(response.Body) err := fmt.Errorf( "HTTP response %d, query was %s\n data: %s\n response: %s", response.StatusCode, request.URL.String(), data, content) @@ -1332,7 +1332,7 @@ func (client *Client) GetTransitions(issueKeyOrID string) (*TransitionList, erro var message TransitionList - data, _ := ioutil.ReadAll(response.Body) + data, _ := io.ReadAll(response.Body) err = json.Unmarshal(data, &message) if err != nil { err := fmt.Errorf("Decoding response %v", err) @@ -1440,7 +1440,7 @@ func (client *Client) GetServerInfo() (*ServerInfo, error) { var message ServerInfo - data, _ := ioutil.ReadAll(response.Body) + data, _ := io.ReadAll(response.Body) err = json.Unmarshal(data, &message) if err != nil { err := fmt.Errorf("Decoding response %v", err) diff --git a/commands/input/input.go b/commands/input/input.go index 4ccfbd92..90c3cf51 100644 --- a/commands/input/input.go +++ b/commands/input/input.go @@ -8,7 +8,7 @@ import ( "bufio" "bytes" "fmt" - "io/ioutil" + "io" "os" "os/exec" "path/filepath" @@ -72,7 +72,7 @@ func LaunchEditor(repo repository.RepoCommonStorage, fileName string) (string, e return "", fmt.Errorf("Editing finished with error: %v\n", err) } - output, err := ioutil.ReadFile(path) + output, err := os.ReadFile(path) if err != nil { return "", fmt.Errorf("Error reading edited file: %v\n", err) @@ -93,7 +93,7 @@ func FromFile(fileName string) (string, error) { } if (stat.Mode() & os.ModeCharDevice) == 0 { // There is no tty. This will allow us to read piped data instead. - output, err := ioutil.ReadAll(os.Stdin) + output, err := io.ReadAll(os.Stdin) if err != nil { return "", fmt.Errorf("Error reading from stdin: %v\n", err) } @@ -110,7 +110,7 @@ func FromFile(fileName string) (string, error) { return output.String(), nil } - output, err := ioutil.ReadFile(fileName) + output, err := os.ReadFile(fileName) if err != nil { return "", fmt.Errorf("Error reading file: %v\n", err) } diff --git a/repository/gogit.go b/repository/gogit.go index 96d62665..95c5330d 100644 --- a/repository/gogit.go +++ b/repository/gogit.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "path/filepath" "sort" @@ -493,7 +492,7 @@ func (repo *GoGitRepo) ReadData(hash Hash) ([]byte, error) { } // TODO: return a io.Reader instead - return ioutil.ReadAll(r) + return io.ReadAll(r) } // StoreTree will store a mapping key-->Hash as a Git tree @@ -785,7 +784,7 @@ func (repo *GoGitRepo) AllClocks() (map[string]lamport.Clock, error) { result := make(map[string]lamport.Clock) - files, err := ioutil.ReadDir(filepath.Join(repo.localStorage.Root(), clockPath)) + files, err := os.ReadDir(filepath.Join(repo.localStorage.Root(), clockPath)) if os.IsNotExist(err) { return nil, nil } diff --git a/termui/input_popup.go b/termui/input_popup.go index a60b1c04..373d74a4 100644 --- a/termui/input_popup.go +++ b/termui/input_popup.go @@ -2,7 +2,7 @@ package termui import ( "errors" - "io/ioutil" + "io" "github.com/awesome-gocui/gocui" ) @@ -78,7 +78,7 @@ func (ip *inputPopup) close(g *gocui.Gui, v *gocui.View) error { func (ip *inputPopup) validate(g *gocui.Gui, v *gocui.View) error { ip.title = "" - content, err := ioutil.ReadAll(v) + content, err := io.ReadAll(v) if err != nil { return err } diff --git a/webui/packed_assets.go b/webui/packed_assets.go index 514cc8b8..4d3a2f44 100644 --- a/webui/packed_assets.go +++ b/webui/packed_assets.go @@ -10,7 +10,6 @@ import ( "compress/gzip" "fmt" "io" - "io/ioutil" "net/http" "os" pathpkg "path" @@ -182,7 +181,7 @@ func (f *vfsgen۰CompressedFile) Read(p []byte) (n int, err error) { } if f.grPos < f.seekPos { // Fast-forward. - _, err = io.CopyN(ioutil.Discard, f.gr, f.seekPos-f.grPos) + _, err = io.CopyN(io.Discard, f.gr, f.seekPos-f.grPos) if err != nil { return 0, err } |