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(command): remove ioutil #41

Merged
merged 2 commits into from Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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