Move away from deprecated go funcs (#1123)

This commit is contained in:
6543 2022-08-25 08:39:19 +02:00 committed by GitHub
parent d3eea72663
commit f21d854114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 11 deletions

View file

@ -18,7 +18,6 @@ import (
"context"
"encoding/json"
"io"
"io/ioutil"
"runtime"
"strconv"
"sync"
@ -211,7 +210,7 @@ func (r *Runner) Run(ctx context.Context) error {
}
// TODO should be configurable
limitedPart = io.LimitReader(part, maxFileUpload)
data, err = ioutil.ReadAll(limitedPart)
data, err = io.ReadAll(limitedPart)
if err != nil {
loglogger.Err(err).Msg("could not read limited part")
}

View file

@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
@ -72,7 +71,7 @@ func execFile(c *cli.Context, file string) error {
}
func runExec(c *cli.Context, file, repoPath string) error {
dat, err := ioutil.ReadFile(file)
dat, err := os.ReadFile(file)
if err != nil {
return err
}

View file

@ -4,7 +4,6 @@ import (
"context"
"encoding/base64"
"io"
"io/ioutil"
"os"
"os/exec"
"strings"
@ -36,7 +35,7 @@ func (e *local) IsAvailable() bool {
}
func (e *local) Load() error {
dir, err := ioutil.TempDir("", "woodpecker-local-*")
dir, err := os.MkdirTemp("", "woodpecker-local-*")
e.workingdir = dir
return err
}

View file

@ -16,7 +16,7 @@ package datastore
import (
"bytes"
"io/ioutil"
"io"
"testing"
"github.com/stretchr/testify/assert"
@ -71,7 +71,7 @@ func TestFileFind(t *testing.T) {
t.Error(err)
return
}
out, _ := ioutil.ReadAll(rc)
out, _ := io.ReadAll(rc)
if got, want := string(out), "hello world"; got != want {
t.Errorf("Want file data %s, got %s", want, got)
}

View file

@ -17,7 +17,6 @@ package datastore
import (
"bytes"
"io"
"io/ioutil"
"github.com/woodpecker-ci/woodpecker/server/model"
)
@ -30,11 +29,11 @@ func (s storage) LogFind(proc *model.Proc) (io.ReadCloser, error) {
return nil, err
}
buf := bytes.NewBuffer(logs.Data)
return ioutil.NopCloser(buf), nil
return io.NopCloser(buf), nil
}
func (s storage) LogSave(proc *model.Proc, reader io.Reader) error {
data, _ := ioutil.ReadAll(reader)
data, _ := io.ReadAll(reader)
sess := s.engine.NewSession()
defer sess.Close()