Skip to content

Commit

Permalink
lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
paultyng committed Oct 23, 2022
1 parent 0552712 commit e7f16ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions fields/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path"
Expand Down Expand Up @@ -128,7 +127,7 @@ func extractJSON(jarFile, fieldsDir string) error {
}
}

settingsData, err := ioutil.ReadFile(filepath.Join(fieldsDir, "Setting.json"))
settingsData, err := os.ReadFile(filepath.Join(fieldsDir, "Setting.json"))
if errors.Is(err, os.ErrNotExist) {
return nil
}
Expand All @@ -150,7 +149,7 @@ func extractJSON(jarFile, fieldsDir string) error {
return fmt.Errorf("unable to marshal setting %q: %w", k, err)
}

err = ioutil.WriteFile(filepath.Join(fieldsDir, fileName), data, 0755)
err = os.WriteFile(filepath.Join(fieldsDir, fileName), data, 0755)
if err != nil {
return fmt.Errorf("unable to write new settings file: %w", err)
}
Expand Down
13 changes: 6 additions & 7 deletions fields/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fmt"
"go/format"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -274,7 +273,7 @@ func main() {
os.Exit(0)
}

fieldsFiles, err := ioutil.ReadDir(fieldsDir)
fieldsFiles, err := os.ReadDir(fieldsDir)
if err != nil {
panic(err)
}
Expand All @@ -299,7 +298,7 @@ func main() {

goFile := strcase.ToSnake(structName) + ".generated.go"
fieldsFilePath := filepath.Join(fieldsDir, fieldsFile.Name())
b, err := ioutil.ReadFile(fieldsFilePath)
b, err := os.ReadFile(fieldsFilePath)
if err != nil {
fmt.Printf("skipping file %s: %s", fieldsFile.Name(), err)
continue
Expand Down Expand Up @@ -426,7 +425,7 @@ func main() {
}

_ = os.Remove(filepath.Join(outDir, goFile))
if err := ioutil.WriteFile(filepath.Join(outDir, goFile), ([]byte)(code), 0644); err != nil {
if err := os.WriteFile(filepath.Join(outDir, goFile), ([]byte)(code), 0644); err != nil {
panic(err)
}
}
Expand All @@ -445,7 +444,7 @@ const UnifiVersion = %q
panic(err)
}

if err := ioutil.WriteFile(filepath.Join(outDir, "version.generated.go"), versionGo, 0644); err != nil {
if err := os.WriteFile(filepath.Join(outDir, "version.generated.go"), versionGo, 0644); err != nil {
panic(err)
}

Expand Down Expand Up @@ -586,12 +585,12 @@ func (r *Resource) generateCode() (string, error) {

err = tpl.Execute(writer, r)
if err != nil {
return "", fmt.Errorf("Failed to render template: %w", err)
return "", fmt.Errorf("failed to render template: %w", err)
}

src, err := format.Source(buf.Bytes())
if err != nil {
return "", fmt.Errorf("Failed to format source: %w", err)
return "", fmt.Errorf("failed to format source: %w", err)
}

return string(src), err
Expand Down

0 comments on commit e7f16ff

Please sign in to comment.