Skip to content

Commit

Permalink
remove references to ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
kpym committed Aug 20, 2021
1 parent ef51b5f commit 44b82bb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app

import (
"fmt"
"io/ioutil"
"io"
"os"
"path"
"path/filepath"
Expand All @@ -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()
Expand Down Expand Up @@ -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 {
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions builder/laton/laton.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"bytes"
"compress/gzip"
"fmt"
"io/ioutil"
"io"
"mime/multipart"
"net/http"
"net/url"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions builder/ytotech/ytotech.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"io/ioutil"
"os"
"time"

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 44b82bb

Please sign in to comment.