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

chore: clean up ioutil deprecated methods. #118

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions pkg/cmds/kcl-openapi.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmds

import (
"io/ioutil"
"io"
"log"
"os"

Expand Down Expand Up @@ -66,7 +66,7 @@ func Main() {
os.Exit(0)
}
opts.Quiet = func() {
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)
}
opts.LogFile = func(logfile string) {
f, err := os.OpenFile(logfile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
Expand Down
4 changes: 2 additions & 2 deletions pkg/kube_resource/generator/assets/static/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"bytes"
"fmt"
"go/format"
"io/ioutil"
"os"
"strings"
"unicode"
)
Expand All @@ -26,7 +26,7 @@ func Generate() ([]byte, error) {
fmt.Fprintf(buf, "%v\n\n%v\n\npackage static\n\n", license, warning)
fmt.Fprintf(buf, "var Files = map[string]string{\n")
for _, fn := range files {
b, err := ioutil.ReadFile(fn)
b, err := os.ReadFile(fn)
if err != nil {
return b, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/kube_resource/generator/assets/static/makestatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package main

import (
"fmt"
"io/ioutil"
"os"

"kcl-lang.io/kcl-openapi/pkg/kube_resource/generator/assets/static"
Expand All @@ -29,7 +28,7 @@ func makestatic() error {
if err != nil {
return fmt.Errorf("error while generating static.go: %v\n", err)
}
err = ioutil.WriteFile("static.go", buf, 0666)
err = os.WriteFile("static.go", buf, 0666)
if err != nil {
return fmt.Errorf("error while writing static.go: %v\n", err)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/swagger/generator/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path"
Expand Down Expand Up @@ -292,7 +291,7 @@ func (g *GenOpts) write(t *TemplateOpts, data interface{}) error {
formatted, err = g.LanguageOpts.FormatContent(filepath.Join(dir, fname), content)
if err != nil {
log.Printf("source formatting failed on template-generated source (%q for %s). Check that your template produces valid code", filepath.Join(dir, fname), t.Name)
writeerr = ioutil.WriteFile(filepath.Join(dir, fname), content, 0644)
writeerr = os.WriteFile(filepath.Join(dir, fname), content, 0644)
if writeerr != nil {
return fmt.Errorf("failed to write (unformatted) file %q in %q: %v", fname, dir, writeerr)
}
Expand All @@ -301,7 +300,7 @@ func (g *GenOpts) write(t *TemplateOpts, data interface{}) error {
}
}

writeerr = ioutil.WriteFile(filepath.Join(dir, fname), formatted, 0644)
writeerr = os.WriteFile(filepath.Join(dir, fname), formatted, 0644)
if writeerr != nil {
return fmt.Errorf("failed to write file %q in %q: %v", fname, dir, writeerr)
}
Expand Down
Loading