From 44b82bbea275e02f7dce32a7998fa513c6c19ccb Mon Sep 17 00:00:00 2001 From: kpym Date: Fri, 20 Aug 2021 07:54:01 +0200 Subject: [PATCH] remove references to ioutil --- .goreleaser.yml | 2 +- app/app.go | 12 ++++++------ builder/laton/laton.go | 4 ++-- builder/ytotech/ytotech.go | 4 ++-- main.go | 3 +-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 6d1859c..d761c49 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -15,7 +15,7 @@ builds: - windows - darwin ldflags: - - -s -w -X github.com/kpym/lol/app.Version={{.Version}} + - -s -w -X github.com/kpym/lol/app.version={{.Version}} archives: - replacements: darwin: MacOS diff --git a/app/app.go b/app/app.go index d4569b0..31ae813 100644 --- a/app/app.go +++ b/app/app.go @@ -2,7 +2,7 @@ package app import ( "fmt" - "io/ioutil" + "io" "os" "path" "path/filepath" @@ -29,12 +29,12 @@ const ( ) // The version that is set by goreleaser -var Version = "dev" +var version = "dev" // Help displays usage message if -h/--help flag is set or in case of falg error. func Help() { var out = os.Stderr - fmt.Fprintf(out, "lol (version: %s)\n", Version) + fmt.Fprintf(out, "lol (version: %s)\n", version) fmt.Fprintln(out, "LaTeX online compiler. More info at www.github.com/kpym/lol.") fmt.Fprintln(out, "\nAvailable options:") pflag.PrintDefaults() @@ -197,10 +197,10 @@ func GetFiles(params builder.Parameters) (builder.Files, error) { // get the main file if params.PipedMain { params.Log.Debug("Read the main file from stdin.") - filedata, err = ioutil.ReadAll(os.Stdin) + filedata, err = io.ReadAll(os.Stdin) } else { params.Log.Debugf("Read the main file from %s.\n", params.Main) - filedata, err = ioutil.ReadFile(params.Main) + filedata, err = os.ReadFile(params.Main) } files[params.Main] = filedata if err != nil { @@ -224,7 +224,7 @@ func GetFiles(params builder.Parameters) (builder.Files, error) { continue } // read the file, or skipt it if not readable - filedata, err = ioutil.ReadFile(fname) + filedata, err = os.ReadFile(fname) if err == nil { files[uname] = filedata params.Log.Debugf("File %s (%d bytes) added to the list.", uname, len(filedata)) diff --git a/builder/laton/laton.go b/builder/laton/laton.go index cf8d051..5926b93 100644 --- a/builder/laton/laton.go +++ b/builder/laton/laton.go @@ -14,7 +14,7 @@ import ( "bytes" "compress/gzip" "fmt" - "io/ioutil" + "io" "mime/multipart" "net/http" "net/url" @@ -125,7 +125,7 @@ func (y *laton) BuildPDF(req builder.Request) ([]byte, error) { defer resp.Body.Close() // read pdf or error from response - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("Problem reading response: %w\n", err) } diff --git a/builder/ytotech/ytotech.go b/builder/ytotech/ytotech.go index f490bf1..4a2a062 100644 --- a/builder/ytotech/ytotech.go +++ b/builder/ytotech/ytotech.go @@ -21,7 +21,7 @@ import ( "encoding/base64" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strings" @@ -84,7 +84,7 @@ func (y *ytotech) BuildPDF(req builder.Request) ([]byte, error) { defer resp.Body.Close() // read pdf or error from response - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("Problem reading response: %w\n", err) } diff --git a/main.go b/main.go index 1585e75..3a8ef18 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "io/ioutil" "os" "time" @@ -55,7 +54,7 @@ func main() { // write the pdf if params.Output != "" { params.Log.Infof("Write %s.\n", params.Output) - err = ioutil.WriteFile(params.Output, pdf, 0644) + err = os.WriteFile(params.Output, pdf, 0644) check(params.Log, err) } else { params.Log.Infof("Write to stdout.\n")