Skip to content

Commit

Permalink
fix(command): remove ioutil (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianccm committed Aug 25, 2022
1 parent 4586516 commit a253cb9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions command.go
Expand Up @@ -4,7 +4,6 @@ import (
// enable go:embed
_ "embed"
"fmt"
"io/ioutil"
"log"
"os"
"path"
Expand Down Expand Up @@ -68,15 +67,15 @@ func Generate(services []Service, basePath string, schemaBasePath string) error
return fmt.Errorf("mkdir %q failed: %w", schemaBasePath, err)
}

if err := ioutil.WriteFile(schemaPath, schema, 0644); err != nil {
if err := os.WriteFile(schemaPath, schema, 0644); err != nil {
return fmt.Errorf("writefile %q failed: %w", schemaPath, err)
}

if err := ioutil.WriteFile(path.Join(basePath, "module.go"), module, 0644); err != nil {
if err := os.WriteFile(path.Join(basePath, "module.go"), module, 0644); err != nil {
return fmt.Errorf("writefile %q/module.go failed: %w", basePath, err)
}

if err := ioutil.WriteFile(path.Join(basePath, "emptymodule.go"), emptyModule, 0644); err != nil {
if err := os.WriteFile(path.Join(basePath, "emptymodule.go"), emptyModule, 0644); err != nil {
return fmt.Errorf("writefile %q/emptymodule.go failed: %w", basePath, err)
}

Expand All @@ -91,7 +90,7 @@ func Generate(services []Service, basePath string, schemaBasePath string) error
fpath := path.Join(schemaBasePath, fname)

log.Printf("Writing %s", fname)
if err := ioutil.WriteFile(fpath, service.Schema(), 0644); err != nil {
if err := os.WriteFile(fpath, service.Schema(), 0644); err != nil {
return fmt.Errorf("writefile %q failed: %w", fpath, err)
}
cfg.SchemaFilename = append(cfg.SchemaFilename, fpath)
Expand Down Expand Up @@ -139,7 +138,7 @@ func Generate(services []Service, basePath string, schemaBasePath string) error
cfg.SkipModTidy = skipGoModTidy

for _, filename := range cfg.SchemaFilename {
schemaRaw, err := ioutil.ReadFile(filename)
schemaRaw, err := os.ReadFile(filename)
if err != nil {
return fmt.Errorf("unable to open schema: %w", err)
}
Expand Down

0 comments on commit a253cb9

Please sign in to comment.