diff --git a/fields/extract.go b/fields/extract.go index 5f926d0..3c5a9f2 100644 --- a/fields/extract.go +++ b/fields/extract.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "os" "path" @@ -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 } @@ -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) } diff --git a/fields/main.go b/fields/main.go index 81ce793..5844592 100644 --- a/fields/main.go +++ b/fields/main.go @@ -9,7 +9,6 @@ import ( "fmt" "go/format" "io" - "io/ioutil" "os" "path" "path/filepath" @@ -274,7 +273,7 @@ func main() { os.Exit(0) } - fieldsFiles, err := ioutil.ReadDir(fieldsDir) + fieldsFiles, err := os.ReadDir(fieldsDir) if err != nil { panic(err) } @@ -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 @@ -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) } } @@ -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) } @@ -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