mirror of
https://github.com/datarhei/core.git
synced 2025-10-14 04:03:40 +08:00
Stop using deprecated functions
This commit is contained in:
@@ -6,7 +6,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
gojson "encoding/json"
|
gojson "encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@@ -503,7 +502,7 @@ func importV1(path string, cfg importConfig) (store.StoreData, error) {
|
|||||||
|
|
||||||
r := store.NewStoreData()
|
r := store.NewStoreData()
|
||||||
|
|
||||||
jsondata, err := ioutil.ReadFile(path)
|
jsondata, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r, fmt.Errorf("failed to read data from %s: %w", path, err)
|
return r, fmt.Errorf("failed to read data from %s: %w", path, err)
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
gojson "encoding/json"
|
gojson "encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -51,7 +50,7 @@ func testV1Import(t *testing.T, v1Fixture, v4Fixture string, config importConfig
|
|||||||
require.Equal(t, nil, err)
|
require.Equal(t, nil, err)
|
||||||
|
|
||||||
// Read the wanted result
|
// Read the wanted result
|
||||||
wantdatav4, err := ioutil.ReadFile(v4Fixture)
|
wantdatav4, err := os.ReadFile(v4Fixture)
|
||||||
require.Equal(t, nil, err)
|
require.Equal(t, nil, err)
|
||||||
|
|
||||||
var wantv4 store.StoreData
|
var wantv4 store.StoreData
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -58,7 +58,7 @@ func doRequest(url string) string {
|
|||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,7 @@ package skills
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,14 +16,14 @@ type alsaCard struct {
|
|||||||
func DevicesALSA() ([]HWDevice, error) {
|
func DevicesALSA() ([]HWDevice, error) {
|
||||||
devices := []HWDevice{}
|
devices := []HWDevice{}
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("/proc/asound/cards")
|
content, err := os.ReadFile("/proc/asound/cards")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, err
|
return devices, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cards := parseALSACards(content)
|
cards := parseALSACards(content)
|
||||||
|
|
||||||
content, err = ioutil.ReadFile("/proc/asound/devices")
|
content, err = os.ReadFile("/proc/asound/devices")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, err
|
return devices, err
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@ package resolver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ func (r *queryResolver) playoutRequest(method, addr, path, contentType string, d
|
|||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
// Read the whole response
|
// Read the whole response
|
||||||
data, err = ioutil.ReadAll(response.Body)
|
data, err = io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -96,7 +96,7 @@ func (h *MemFSHandler) PatchFile(c echo.Context) error {
|
|||||||
|
|
||||||
req := c.Request()
|
req := c.Request()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(req.Body)
|
body, err := io.ReadAll(req.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Err(http.StatusBadRequest, "Failed reading request body", "%s", err)
|
return api.Err(http.StatusBadRequest, "Failed reading request body", "%s", err)
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -59,7 +59,7 @@ func (h *PlayoutHandler) Status(c echo.Context) error {
|
|||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
// Read the whole response
|
// Read the whole response
|
||||||
data, err := ioutil.ReadAll(response.Body)
|
data, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ func (h *PlayoutHandler) Keyframe(c echo.Context) error {
|
|||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
// Read the whole response
|
// Read the whole response
|
||||||
data, err := ioutil.ReadAll(response.Body)
|
data, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ func (h *PlayoutHandler) EncodeErrorframe(c echo.Context) error {
|
|||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
// Read the whole response
|
// Read the whole response
|
||||||
data, err := ioutil.ReadAll(response.Body)
|
data, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ func (h *PlayoutHandler) SetErrorframe(c echo.Context) error {
|
|||||||
return api.Err(http.StatusNotFound, "Unknown process or input", "%s", err)
|
return api.Err(http.StatusNotFound, "Unknown process or input", "%s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ioutil.ReadAll(c.Request().Body)
|
data, err := io.ReadAll(c.Request().Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Err(http.StatusBadRequest, "Failed to read request body", "%s", err)
|
return api.Err(http.StatusBadRequest, "Failed to read request body", "%s", err)
|
||||||
}
|
}
|
||||||
@@ -210,7 +210,7 @@ func (h *PlayoutHandler) SetErrorframe(c echo.Context) error {
|
|||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
// Read the whole response
|
// Read the whole response
|
||||||
data, err = ioutil.ReadAll(response.Body)
|
data, err = io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,7 @@ func (h *PlayoutHandler) ReopenInput(c echo.Context) error {
|
|||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
// Read the whole response
|
// Read the whole response
|
||||||
data, err := ioutil.ReadAll(response.Body)
|
data, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ func (h *PlayoutHandler) SetStream(c echo.Context) error {
|
|||||||
return api.Err(http.StatusNotFound, "Unknown process or input", "%s", err)
|
return api.Err(http.StatusNotFound, "Unknown process or input", "%s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ioutil.ReadAll(c.Request().Body)
|
data, err := io.ReadAll(c.Request().Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Err(http.StatusBadRequest, "Failed to read request body", "%s", err)
|
return api.Err(http.StatusBadRequest, "Failed to read request body", "%s", err)
|
||||||
}
|
}
|
||||||
@@ -296,7 +296,7 @@ func (h *PlayoutHandler) SetStream(c echo.Context) error {
|
|||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
// Read the whole response
|
// Read the whole response
|
||||||
data, err = ioutil.ReadAll(response.Body)
|
data, err = io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
return api.Err(http.StatusInternalServerError, "", "%s", err)
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@ package util
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ func ShouldBindJSONValidation(c echo.Context, obj interface{}, validate bool) er
|
|||||||
return fmt.Errorf("request doesn't contain JSON content")
|
return fmt.Errorf("request doesn't contain JSON content")
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(req.Body)
|
body, err := io.ReadAll(req.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ import (
|
|||||||
"crypto"
|
"crypto"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -324,7 +324,7 @@ func (j *jwksImpl) refresh() (err error) {
|
|||||||
|
|
||||||
// Read the raw JWKs from the body of the response.
|
// Read the raw JWKs from the body of the response.
|
||||||
var jwksBytes []byte
|
var jwksBytes []byte
|
||||||
if jwksBytes, err = ioutil.ReadAll(resp.Body); err != nil {
|
if jwksBytes, err = io.ReadAll(resp.Body); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,7 +4,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -108,7 +107,7 @@ func NewWithConfig(config Config) echo.MiddlewareFunc {
|
|||||||
// nothing is written to body or error is returned.
|
// nothing is written to body or error is returned.
|
||||||
// See issue #424, #407.
|
// See issue #424, #407.
|
||||||
res.Writer = rw
|
res.Writer = rw
|
||||||
w.Reset(ioutil.Discard)
|
w.Reset(io.Discard)
|
||||||
}
|
}
|
||||||
w.Close()
|
w.Close()
|
||||||
pool.Put(w)
|
pool.Put(w)
|
||||||
@@ -183,7 +182,7 @@ func (w *gzipResponseWriter) Push(target string, opts *http.PushOptions) error {
|
|||||||
func gzipPool(config Config) sync.Pool {
|
func gzipPool(config Config) sync.Pool {
|
||||||
return sync.Pool{
|
return sync.Pool{
|
||||||
New: func() interface{} {
|
New: func() interface{} {
|
||||||
w, err := gzip.NewWriterLevel(ioutil.Discard, config.Level)
|
w, err := gzip.NewWriterLevel(io.Discard, config.Level)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -5,9 +5,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -57,7 +57,7 @@ func DummyEcho() *echo.Echo {
|
|||||||
router.HideBanner = true
|
router.HideBanner = true
|
||||||
router.HidePort = true
|
router.HidePort = true
|
||||||
router.HTTPErrorHandler = errorhandler.HTTPErrorHandler
|
router.HTTPErrorHandler = errorhandler.HTTPErrorHandler
|
||||||
router.Logger.SetOutput(ioutil.Discard)
|
router.Logger.SetOutput(io.Discard)
|
||||||
router.Validator = validator.New()
|
router.Validator = validator.New()
|
||||||
|
|
||||||
return router
|
return router
|
||||||
@@ -89,7 +89,7 @@ func CheckResponse(t *testing.T, res *http.Response) *Response {
|
|||||||
Code: res.StatusCode,
|
Code: res.StatusCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
require.Equal(t, nil, err)
|
require.Equal(t, nil, err)
|
||||||
|
|
||||||
if strings.Contains(res.Header.Get("Content-Type"), "application/json") {
|
if strings.Contains(res.Header.Get("Content-Type"), "application/json") {
|
||||||
@@ -122,7 +122,7 @@ func Validate(t *testing.T, datatype, data interface{}) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Read(t *testing.T, path string) io.Reader {
|
func Read(t *testing.T, path string) io.Reader {
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
require.Equal(t, nil, err)
|
require.Equal(t, nil, err)
|
||||||
|
|
||||||
return bytes.NewReader(data)
|
return bytes.NewReader(data)
|
||||||
|
@@ -88,31 +88,37 @@ type Status struct {
|
|||||||
// States
|
// States
|
||||||
//
|
//
|
||||||
// finished - Process has been stopped
|
// finished - Process has been stopped
|
||||||
// starting - if process has been actively started or has been waiting for reconnect (order=start, reconnect=any)
|
//
|
||||||
// finished - if process shall not reconnect (order=stop, reconnect=any)
|
// starting - if process has been actively started or has been waiting for reconnect (order=start, reconnect=any)
|
||||||
|
// finished - if process shall not reconnect (order=stop, reconnect=any)
|
||||||
//
|
//
|
||||||
// starting - Process is about to start
|
// starting - Process is about to start
|
||||||
// finishing - if process should be immediately stopped (order=stop, reconnect=any)
|
//
|
||||||
// running - if process could be started (order=start, reconnect=any)
|
// finishing - if process should be immediately stopped (order=stop, reconnect=any)
|
||||||
// failed - if process couldn't be started (e.g. binary not found) (order=start, reconnect=any)
|
// running - if process could be started (order=start, reconnect=any)
|
||||||
|
// failed - if process couldn't be started (e.g. binary not found) (order=start, reconnect=any)
|
||||||
//
|
//
|
||||||
// running - Process is running
|
// running - Process is running
|
||||||
// finished - if process exited normally (order=any, reconnect=any)
|
//
|
||||||
// finishing - if process has been actively stopped (order=stop, reconnect=any)
|
// finished - if process exited normally (order=any, reconnect=any)
|
||||||
// failed - if process exited abnormally (order=any, reconnect=any)
|
// finishing - if process has been actively stopped (order=stop, reconnect=any)
|
||||||
// killed - if process has been actively killed with SIGKILL (order=any, reconnect=any)
|
// failed - if process exited abnormally (order=any, reconnect=any)
|
||||||
|
// killed - if process has been actively killed with SIGKILL (order=any, reconnect=any)
|
||||||
//
|
//
|
||||||
// finishing - Process has been actively stopped and will be killed
|
// finishing - Process has been actively stopped and will be killed
|
||||||
// finished - if process has been actively killed with SIGINT and ffmpeg exited normally (order=stop, reconnect=any)
|
//
|
||||||
// killed - if process has been actively killed with SIGKILL (order=stop, reconnect=any)
|
// finished - if process has been actively killed with SIGINT and ffmpeg exited normally (order=stop, reconnect=any)
|
||||||
|
// killed - if process has been actively killed with SIGKILL (order=stop, reconnect=any)
|
||||||
//
|
//
|
||||||
// failed - Process has been failed either by starting or during running
|
// failed - Process has been failed either by starting or during running
|
||||||
// starting - if process has been waiting for reconnect (order=start, reconnect=true)
|
//
|
||||||
// failed - if process shall not reconnect (order=any, reconnect=false)
|
// starting - if process has been waiting for reconnect (order=start, reconnect=true)
|
||||||
|
// failed - if process shall not reconnect (order=any, reconnect=false)
|
||||||
//
|
//
|
||||||
// killed - Process has been stopped
|
// killed - Process has been stopped
|
||||||
// starting - if process has been waiting for reconnect (order=start, reconnect=true)
|
//
|
||||||
// killed - if process shall not reconnect (order=start, reconnect=false)
|
// starting - if process has been waiting for reconnect (order=start, reconnect=true)
|
||||||
|
// killed - if process shall not reconnect (order=start, reconnect=false)
|
||||||
type stateType string
|
type stateType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@@ -98,7 +98,8 @@ func (p *process) cpuTimes() (*cpuTimesStat, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := &cpuTimesStat{
|
s := &cpuTimesStat{
|
||||||
total: times.Total(),
|
total: times.User + times.System + times.Idle + times.Nice + times.Iowait + times.Irq +
|
||||||
|
times.Softirq + times.Steal + times.Guest + times.GuestNice,
|
||||||
system: times.System,
|
system: times.System,
|
||||||
user: times.User,
|
user: times.User,
|
||||||
}
|
}
|
||||||
|
@@ -285,7 +285,8 @@ func (u *util) cpuTimes() (*cpuTimesStat, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := &cpuTimesStat{
|
s := &cpuTimesStat{
|
||||||
total: times[0].Total(),
|
total: times[0].User + times[0].System + times[0].Idle + times[0].Nice + times[0].Iowait + times[0].Irq +
|
||||||
|
times[0].Softirq + times[0].Steal + times[0].Guest + times[0].GuestNice,
|
||||||
system: times[0].System,
|
system: times[0].System,
|
||||||
user: times[0].User,
|
user: times[0].User,
|
||||||
idle: times[0].Idle,
|
idle: times[0].Idle,
|
||||||
|
@@ -3,7 +3,6 @@ package store
|
|||||||
import (
|
import (
|
||||||
gojson "encoding/json"
|
gojson "encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@@ -78,7 +77,7 @@ func (s *jsonStore) store(data StoreData) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpfile, err := ioutil.TempFile(s.dir, s.filename)
|
tmpfile, err := os.CreateTemp(s.dir, s.filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -122,7 +121,7 @@ func (s *jsonStore) load(version uint64) (StoreData, error) {
|
|||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
|
|
||||||
jsondata, err := ioutil.ReadFile(filename)
|
jsondata, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -149,14 +148,14 @@ func (a *api) refreshAccessToken(refreshToken string) error {
|
|||||||
return errStatusAuthorization
|
return errStatusAuthorization
|
||||||
}
|
}
|
||||||
|
|
||||||
data, _ := ioutil.ReadAll(res.Body)
|
data, _ := io.ReadAll(res.Body)
|
||||||
return statusError{
|
return statusError{
|
||||||
code: res.StatusCode,
|
code: res.StatusCode,
|
||||||
response: data,
|
response: data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ioutil.ReadAll(res.Body)
|
data, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return statusError{
|
return statusError{
|
||||||
code: res.StatusCode,
|
code: res.StatusCode,
|
||||||
@@ -199,14 +198,14 @@ func (a *api) call(method, path string, body io.Reader) ([]byte, error) {
|
|||||||
return nil, errStatusAuthorization
|
return nil, errStatusAuthorization
|
||||||
}
|
}
|
||||||
|
|
||||||
data, _ := ioutil.ReadAll(res.Body)
|
data, _ := io.ReadAll(res.Body)
|
||||||
return nil, statusError{
|
return nil, statusError{
|
||||||
code: res.StatusCode,
|
code: res.StatusCode,
|
||||||
response: data,
|
response: data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ioutil.ReadAll(res.Body)
|
data, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error reading response: %w", statusError{
|
return nil, fmt.Errorf("error reading response: %w", statusError{
|
||||||
code: res.StatusCode,
|
code: res.StatusCode,
|
||||||
|
@@ -3,7 +3,6 @@ package session
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -461,7 +460,7 @@ func (c *collector) loadHistory(path string, data *history) {
|
|||||||
c.lock.persist.Lock()
|
c.lock.persist.Lock()
|
||||||
defer c.lock.persist.Unlock()
|
defer c.lock.persist.Unlock()
|
||||||
|
|
||||||
jsondata, err := ioutil.ReadFile(path)
|
jsondata, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -489,7 +488,7 @@ func (c *collector) saveHistory(path string, data *history) {
|
|||||||
dir := filepath.Dir(path)
|
dir := filepath.Dir(path)
|
||||||
filename := filepath.Base(path)
|
filename := filepath.Base(path)
|
||||||
|
|
||||||
tmpfile, err := ioutil.TempFile(dir, filename)
|
tmpfile, err := os.CreateTemp(dir, filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -179,7 +179,7 @@ func (s *checker) check() error {
|
|||||||
return fmt.Errorf("request failed: %s", http.StatusText(res.StatusCode))
|
return fmt.Errorf("request failed: %s", http.StatusText(res.StatusCode))
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error reading response: %w", err)
|
return fmt.Errorf("error reading response: %w", err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user