Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint errors #52

Merged
merged 12 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -39,12 +39,12 @@ func ExtractPostmortems(loc string, dir string) error {
}
defer resp.Body.Close()

data, err = ioutil.ReadAll(resp.Body)
data, err = io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("could not read response body: %w", err)
}
} else if isFile(loc) {
data, err = ioutil.ReadFile(loc)
data, err = os.ReadFile(loc)
if err != nil {
return fmt.Errorf("error opening file %q: %w", loc, err)
}
Expand Down
7 changes: 3 additions & 4 deletions postmortem.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"text/template"
Expand Down Expand Up @@ -118,7 +117,7 @@ func GenerateJSON(d string) error {
return err
}

err = ioutil.WriteFile(fp, j, 0644)
err = os.WriteFile(fp, j, 0644)
if err != nil {
return err
}
Expand Down Expand Up @@ -149,7 +148,7 @@ func GenerateJSON(d string) error {
if err != nil {
return err
}
err = ioutil.WriteFile(fp, j, 0644)
err = os.WriteFile(fp, j, 0644)
if err != nil {
return err
}
Expand Down Expand Up @@ -189,7 +188,7 @@ func (pm *Postmortem) Save(dir string) error {
}

// Write postmortem data from memory to file.
if err := ioutil.WriteFile(filepath.Join(dir, pm.UUID+".md"), data.Bytes(), 0644); err != nil {
if err := os.WriteFile(filepath.Join(dir, pm.UUID+".md"), data.Bytes(), 0644); err != nil {
return fmt.Errorf("error writing file: %w", err)
}

Expand Down
5 changes: 2 additions & 3 deletions server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import (
"compress/flate"
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -76,7 +75,7 @@
// LoadPostmortems parses the postmortem files
// and returns a slice with their content.
func LoadPostmortems(dir string) ([]*postmortems.Postmortem, error) {
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return nil, fmt.Errorf("error opening data folder: %w", err)
}
Expand Down Expand Up @@ -205,7 +204,7 @@

jsonPM := pmID + ".json"

data, err := ioutil.ReadFile(filepath.Join("output/", jsonPM))
data, err := os.ReadFile(filepath.Join("output/", jsonPM))
Fixed Show fixed Hide fixed
if err != nil {
log.Errorw("load postmortem json", "pmid", pmID, zap.Error(err))
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
Expand Down
3 changes: 1 addition & 2 deletions tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ func IsURL() survey.Validator {
return fmt.Errorf("could not decode string")
}

_, err := url.Parse(str)
if err != nil {
if _, err := url.Parse(str); err != nil {
return fmt.Errorf("value is not a valid URL: %w", err)
}

Expand Down
Loading