fix: use of ioutil package (#5261)
* fix ioutil.NopCloser * fix ioutil.ReadAll * fix ioutil.ReadFile * fix ioutil.WriteFile * run goimports -w -format-only ./ * update CHANGELOG.md
This commit is contained in:
parent
a04bf251c7
commit
6f803ec9a9
@ -4,6 +4,7 @@
|
|||||||
- [feat: add write-delete cache mode](https://github.com/beego/beego/pull/5242)
|
- [feat: add write-delete cache mode](https://github.com/beego/beego/pull/5242)
|
||||||
- [fix 5255: Check the rows.Err() if rows.Next() is false](https://github.com/beego/beego/pull/5256)
|
- [fix 5255: Check the rows.Err() if rows.Next() is false](https://github.com/beego/beego/pull/5256)
|
||||||
- [orm: missing handling %COL% placeholder](https://github.com/beego/beego/pull/5257)
|
- [orm: missing handling %COL% placeholder](https://github.com/beego/beego/pull/5257)
|
||||||
|
- [fix: use of ioutil package](https://github.com/beego/beego/pull/5261)
|
||||||
|
|
||||||
## ORM refactoring
|
## ORM refactoring
|
||||||
- [introducing internal/models pkg](https://github.com/beego/beego/pull/5238)
|
- [introducing internal/models pkg](https://github.com/beego/beego/pull/5238)
|
||||||
|
|||||||
5
client/cache/file.go
vendored
5
client/cache/file.go
vendored
@ -23,7 +23,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -295,7 +294,7 @@ func exists(path string) (bool, error) {
|
|||||||
// FileGetContents Reads bytes from a file.
|
// FileGetContents Reads bytes from a file.
|
||||||
// if non-existent, create this file.
|
// if non-existent, create this file.
|
||||||
func FileGetContents(filename string) ([]byte, error) {
|
func FileGetContents(filename string) ([]byte, error) {
|
||||||
data, err := ioutil.ReadFile(filename)
|
data, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, berror.Wrapf(err, ReadFileCacheContentFailed,
|
return nil, berror.Wrapf(err, ReadFileCacheContentFailed,
|
||||||
"could not read the data from the file: %s, "+
|
"could not read the data from the file: %s, "+
|
||||||
@ -307,7 +306,7 @@ func FileGetContents(filename string) ([]byte, error) {
|
|||||||
// FilePutContents puts bytes into a file.
|
// FilePutContents puts bytes into a file.
|
||||||
// if non-existent, create this file.
|
// if non-existent, create this file.
|
||||||
func FilePutContents(filename string, content []byte) error {
|
func FilePutContents(filename string, content []byte) error {
|
||||||
return ioutil.WriteFile(filename, content, os.ModePerm)
|
return os.WriteFile(filename, content, os.ModePerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GobEncode Gob encodes a file cache item.
|
// GobEncode Gob encodes a file cache item.
|
||||||
|
|||||||
1
client/cache/write_delete.go
vendored
1
client/cache/write_delete.go
vendored
@ -18,6 +18,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/core/berror"
|
"github.com/beego/beego/v2/core/berror"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
3
client/cache/write_delete_test.go
vendored
3
client/cache/write_delete_test.go
vendored
@ -19,10 +19,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/core/berror"
|
"github.com/beego/beego/v2/core/berror"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ package httplib
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,6 +34,6 @@ func NewHttpResponseWithJsonBody(data interface{}) *http.Response {
|
|||||||
}
|
}
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
ContentLength: int64(len(body)),
|
ContentLength: int64(len(body)),
|
||||||
Body: ioutil.NopCloser(bytes.NewReader(body)),
|
Body: io.NopCloser(bytes.NewReader(body)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -283,16 +282,16 @@ func (b *BeegoHTTPRequest) Body(data interface{}) *BeegoHTTPRequest {
|
|||||||
switch t := data.(type) {
|
switch t := data.(type) {
|
||||||
case string:
|
case string:
|
||||||
bf := bytes.NewBufferString(t)
|
bf := bytes.NewBufferString(t)
|
||||||
b.req.Body = ioutil.NopCloser(bf)
|
b.req.Body = io.NopCloser(bf)
|
||||||
b.req.GetBody = func() (io.ReadCloser, error) {
|
b.req.GetBody = func() (io.ReadCloser, error) {
|
||||||
return ioutil.NopCloser(bf), nil
|
return io.NopCloser(bf), nil
|
||||||
}
|
}
|
||||||
b.req.ContentLength = int64(len(t))
|
b.req.ContentLength = int64(len(t))
|
||||||
case []byte:
|
case []byte:
|
||||||
bf := bytes.NewBuffer(t)
|
bf := bytes.NewBuffer(t)
|
||||||
b.req.Body = ioutil.NopCloser(bf)
|
b.req.Body = io.NopCloser(bf)
|
||||||
b.req.GetBody = func() (io.ReadCloser, error) {
|
b.req.GetBody = func() (io.ReadCloser, error) {
|
||||||
return ioutil.NopCloser(bf), nil
|
return io.NopCloser(bf), nil
|
||||||
}
|
}
|
||||||
b.req.ContentLength = int64(len(t))
|
b.req.ContentLength = int64(len(t))
|
||||||
default:
|
default:
|
||||||
@ -308,9 +307,9 @@ func (b *BeegoHTTPRequest) XMLBody(obj interface{}) (*BeegoHTTPRequest, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return b, berror.Wrap(err, InvalidXMLBody, "obj could not be converted to XML data")
|
return b, berror.Wrap(err, InvalidXMLBody, "obj could not be converted to XML data")
|
||||||
}
|
}
|
||||||
b.req.Body = ioutil.NopCloser(bytes.NewReader(byts))
|
b.req.Body = io.NopCloser(bytes.NewReader(byts))
|
||||||
b.req.GetBody = func() (io.ReadCloser, error) {
|
b.req.GetBody = func() (io.ReadCloser, error) {
|
||||||
return ioutil.NopCloser(bytes.NewReader(byts)), nil
|
return io.NopCloser(bytes.NewReader(byts)), nil
|
||||||
}
|
}
|
||||||
b.req.ContentLength = int64(len(byts))
|
b.req.ContentLength = int64(len(byts))
|
||||||
b.req.Header.Set(contentTypeKey, "application/xml")
|
b.req.Header.Set(contentTypeKey, "application/xml")
|
||||||
@ -325,7 +324,7 @@ func (b *BeegoHTTPRequest) YAMLBody(obj interface{}) (*BeegoHTTPRequest, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return b, berror.Wrap(err, InvalidYAMLBody, "obj could not be converted to YAML data")
|
return b, berror.Wrap(err, InvalidYAMLBody, "obj could not be converted to YAML data")
|
||||||
}
|
}
|
||||||
b.req.Body = ioutil.NopCloser(bytes.NewReader(byts))
|
b.req.Body = io.NopCloser(bytes.NewReader(byts))
|
||||||
b.req.ContentLength = int64(len(byts))
|
b.req.ContentLength = int64(len(byts))
|
||||||
b.req.Header.Set(contentTypeKey, "application/x+yaml")
|
b.req.Header.Set(contentTypeKey, "application/x+yaml")
|
||||||
}
|
}
|
||||||
@ -339,7 +338,7 @@ func (b *BeegoHTTPRequest) JSONBody(obj interface{}) (*BeegoHTTPRequest, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return b, berror.Wrap(err, InvalidJSONBody, "obj could not be converted to JSON body")
|
return b, berror.Wrap(err, InvalidJSONBody, "obj could not be converted to JSON body")
|
||||||
}
|
}
|
||||||
b.req.Body = ioutil.NopCloser(bytes.NewReader(byts))
|
b.req.Body = io.NopCloser(bytes.NewReader(byts))
|
||||||
b.req.ContentLength = int64(len(byts))
|
b.req.ContentLength = int64(len(byts))
|
||||||
b.req.Header.Set(contentTypeKey, "application/json")
|
b.req.Header.Set(contentTypeKey, "application/json")
|
||||||
}
|
}
|
||||||
@ -400,7 +399,7 @@ func (b *BeegoHTTPRequest) handleFiles() {
|
|||||||
_ = pw.Close()
|
_ = pw.Close()
|
||||||
}()
|
}()
|
||||||
b.Header(contentTypeKey, bodyWriter.FormDataContentType())
|
b.Header(contentTypeKey, bodyWriter.FormDataContentType())
|
||||||
b.req.Body = ioutil.NopCloser(pr)
|
b.req.Body = io.NopCloser(pr)
|
||||||
b.Header("Transfer-Encoding", "chunked")
|
b.Header("Transfer-Encoding", "chunked")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
package orm
|
package orm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/client/orm/internal/models"
|
"github.com/beego/beego/v2/client/orm/internal/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_getColumnTyp(t *testing.T) {
|
func Test_getColumnTyp(t *testing.T) {
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -118,7 +117,7 @@ func getCaller(skip int) string {
|
|||||||
pc, file, line, _ := runtime.Caller(skip)
|
pc, file, line, _ := runtime.Caller(skip)
|
||||||
fun := runtime.FuncForPC(pc)
|
fun := runtime.FuncForPC(pc)
|
||||||
_, fn := filepath.Split(file)
|
_, fn := filepath.Split(file)
|
||||||
data, err := ioutil.ReadFile(file)
|
data, err := os.ReadFile(file)
|
||||||
var codes []string
|
var codes []string
|
||||||
if err == nil {
|
if err == nil {
|
||||||
lines := bytes.Split(data, []byte{'\n'})
|
lines := bytes.Split(data, []byte{'\n'})
|
||||||
|
|||||||
3
core/config/env/env.go
vendored
3
core/config/env/env.go
vendored
@ -19,7 +19,6 @@ package env
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/build"
|
"go/build"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -119,7 +118,7 @@ func GetRuntimeEnv(key string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var runtimeEnv string
|
var runtimeEnv string
|
||||||
data, err := ioutil.ReadFile(file)
|
data, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -54,7 +53,7 @@ func (ini *IniConfig) Parse(name string) (Configer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ini *IniConfig) parseFile(name string) (*IniConfigContainer, error) {
|
func (ini *IniConfig) parseFile(name string) (*IniConfigContainer, error) {
|
||||||
data, err := ioutil.ReadFile(name)
|
data, err := os.ReadFile(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -173,7 +172,7 @@ name=mysql
|
|||||||
}
|
}
|
||||||
defer os.Remove(name)
|
defer os.Remove(name)
|
||||||
|
|
||||||
if data, err := ioutil.ReadFile(name); err != nil {
|
if data, err := os.ReadFile(name); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
cfgData := string(data)
|
cfgData := string(data)
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -40,7 +40,7 @@ func (js *JSONConfig) Parse(filename string) (config.Configer, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
content, err := ioutil.ReadAll(file)
|
content, err := io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
package toml
|
package toml
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ type Config struct {
|
|||||||
|
|
||||||
// Parse accepts filename as the parameter
|
// Parse accepts filename as the parameter
|
||||||
func (c *Config) Parse(filename string) (config.Configer, error) {
|
func (c *Config) Parse(filename string) (config.Configer, error) {
|
||||||
ctx, err := ioutil.ReadFile(filename)
|
ctx, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,6 @@ import (
|
|||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -53,7 +52,7 @@ type Config struct{}
|
|||||||
|
|
||||||
// Parse returns a ConfigContainer with parsed xml config map.
|
// Parse returns a ConfigContainer with parsed xml config map.
|
||||||
func (xc *Config) Parse(filename string) (config.Configer, error) {
|
func (xc *Config) Parse(filename string) (config.Configer, error) {
|
||||||
context, err := ioutil.ReadFile(filename)
|
context, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,6 @@ package yaml
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -66,7 +65,7 @@ func (*Config) ParseData(data []byte) (config.Configer, error) {
|
|||||||
|
|
||||||
// ReadYmlReader Read yaml file to map.
|
// ReadYmlReader Read yaml file to map.
|
||||||
func ReadYmlReader(path string) (cnf map[string]interface{}, err error) {
|
func ReadYmlReader(path string) (cnf map[string]interface{}, err error) {
|
||||||
buf, err := ioutil.ReadFile(path)
|
buf, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ package alils
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
)
|
)
|
||||||
@ -51,7 +51,7 @@ func (p *LogProject) ListLogStore() (storeNames []string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ func (p *LogProject) GetLogStore(name string) (s *LogStore, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ func (p *LogProject) CreateLogStore(name string, ttl, shardCnt int) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err = ioutil.ReadAll(r.Body)
|
body, err = io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ func (p *LogProject) DeleteLogStore(name string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ func (p *LogProject) UpdateLogStore(name string, ttl, shardCnt int) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err = ioutil.ReadAll(r.Body)
|
body, err = io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ func (p *LogProject) ListMachineGroup(offset, size int) (m []string, total int,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ func (p *LogProject) GetMachineGroup(name string) (m *MachineGroup, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -369,7 +369,7 @@ func (p *LogProject) CreateMachineGroup(m *MachineGroup) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err = ioutil.ReadAll(r.Body)
|
body, err = io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ func (p *LogProject) UpdateMachineGroup(m *MachineGroup) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err = ioutil.ReadAll(r.Body)
|
body, err = io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -440,7 +440,7 @@ func (p *LogProject) DeleteMachineGroup(name string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -477,7 +477,7 @@ func (p *LogProject) ListConfig(offset, size int) (cfgNames []string, total int,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -522,7 +522,7 @@ func (p *LogProject) GetConfig(name string) (c *LogConfig, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -567,7 +567,7 @@ func (p *LogProject) UpdateConfig(c *LogConfig) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err = ioutil.ReadAll(r.Body)
|
body, err = io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -606,7 +606,7 @@ func (p *LogProject) CreateConfig(c *LogConfig) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err = ioutil.ReadAll(r.Body)
|
body, err = io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -638,7 +638,7 @@ func (p *LogProject) DeleteConfig(name string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -670,7 +670,7 @@ func (p *LogProject) GetAppliedMachineGroups(confName string) (groupNames []stri
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -715,7 +715,7 @@ func (p *LogProject) GetAppliedConfigs(groupName string) (confNames []string, er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -760,7 +760,7 @@ func (p *LogProject) ApplyConfigToMachineGroup(confName, groupName string) (err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -792,7 +792,7 @@ func (p *LogProject) RemoveConfigFromMachineGroup(confName, groupName string) (e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package alils
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -41,7 +41,7 @@ func (s *LogStore) ListShards() (shardIDs []int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ func (s *LogStore) PutLogs(lg *LogGroup) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ func (s *LogStore) GetCursor(shardID int, from string) (cursor string, err error
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ func (s *LogStore) GetLogsBytes(shardID int, cursor string,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package alils
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
)
|
)
|
||||||
@ -54,7 +54,7 @@ func (m *MachineGroup) ListMachines() (ms []*Machine, total int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(r.Body)
|
buf, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,6 @@ package logs
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
@ -378,7 +377,7 @@ func testFileDailyRotate(t *testing.T, fn1, fn2 string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
content, err := ioutil.ReadFile(file)
|
content, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
@ -413,7 +412,7 @@ func testFileHourlyRotate(t *testing.T, fn1, fn2 string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
content, err := ioutil.ReadFile(file)
|
content, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import (
|
|||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -377,14 +376,14 @@ func (input *BeegoInput) CopyBody(MaxMemory int64) []byte {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
requestbody, _ = ioutil.ReadAll(reader)
|
requestbody, _ = io.ReadAll(reader)
|
||||||
} else {
|
} else {
|
||||||
requestbody, _ = ioutil.ReadAll(safe)
|
requestbody, _ = io.ReadAll(safe)
|
||||||
}
|
}
|
||||||
|
|
||||||
input.Context.Request.Body.Close()
|
input.Context.Request.Body.Close()
|
||||||
bf := bytes.NewBuffer(requestbody)
|
bf := bytes.NewBuffer(requestbody)
|
||||||
input.Context.Request.Body = http.MaxBytesReader(input.Context.ResponseWriter, ioutil.NopCloser(bf), MaxMemory)
|
input.Context.Request.Body = http.MaxBytesReader(input.Context.ResponseWriter, io.NopCloser(bf), MaxMemory)
|
||||||
input.RequestBody = requestbody
|
input.RequestBody = requestbody
|
||||||
return requestbody
|
return requestbody
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,6 @@ package web
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -321,7 +320,7 @@ func testControllerRespTestCases(t *testing.T, tc respTestCase) {
|
|||||||
t.Errorf("TestResponse() failed to validate response code for %s", tc.Accept)
|
t.Errorf("TestResponse() failed to validate response code for %s", tc.Accept)
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyBytes, err := ioutil.ReadAll(response.Body)
|
bodyBytes, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("TestResponse() failed to parse response body for %s", tc.Accept)
|
t.Errorf("TestResponse() failed to parse response body for %s", tc.Accept)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -194,7 +193,7 @@ func (srv *Server) ListenMutualTLS(certFile string, keyFile string, trustFile st
|
|||||||
srv.TLSConfig.Certificates[0] = cert
|
srv.TLSConfig.Certificates[0] = cert
|
||||||
srv.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert
|
srv.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert
|
||||||
pool := x509.NewCertPool()
|
pool := x509.NewCertPool()
|
||||||
data, err := ioutil.ReadFile(trustFile)
|
data, err := os.ReadFile(trustFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/fcgi"
|
"net/http/fcgi"
|
||||||
@ -257,7 +256,7 @@ func (app *HttpServer) Run(addr string, mws ...MiddleWare) {
|
|||||||
app.Cfg.Listen.HTTPSCertFile, app.Cfg.Listen.HTTPSKeyFile = "", ""
|
app.Cfg.Listen.HTTPSCertFile, app.Cfg.Listen.HTTPSKeyFile = "", ""
|
||||||
} else if app.Cfg.Listen.EnableMutualHTTPS {
|
} else if app.Cfg.Listen.EnableMutualHTTPS {
|
||||||
pool := x509.NewCertPool()
|
pool := x509.NewCertPool()
|
||||||
data, err := ioutil.ReadFile(app.Cfg.Listen.TrustCaFile)
|
data, err := os.ReadFile(app.Cfg.Listen.TrustCaFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Info("MutualHTTPS should provide TrustCaFile")
|
logs.Info("MutualHTTPS should provide TrustCaFile")
|
||||||
return
|
return
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -167,7 +167,7 @@ func (fp *FileProvider) SessionRead(ctx context.Context, sid string) (Store, err
|
|||||||
|
|
||||||
os.Chtimes(sidPath, time.Now(), time.Now())
|
os.Chtimes(sidPath, time.Now(), time.Now())
|
||||||
var kv map[interface{}]interface{}
|
var kv map[interface{}]interface{}
|
||||||
b, err := ioutil.ReadAll(f)
|
b, err := io.ReadAll(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -257,7 +257,7 @@ func (fp *FileProvider) SessionRegenerate(ctx context.Context, oldsid, sid strin
|
|||||||
// 4.return FileSessionStore
|
// 4.return FileSessionStore
|
||||||
_, err = os.Stat(oldSidFile)
|
_, err = os.Stat(oldSidFile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
b, err := ioutil.ReadFile(oldSidFile)
|
b, err := os.ReadFile(oldSidFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ func (fp *FileProvider) SessionRegenerate(ctx context.Context, oldsid, sid strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ioutil.WriteFile(newSidFile, b, 0o777)
|
os.WriteFile(newSidFile, b, 0o777)
|
||||||
os.Remove(oldSidFile)
|
os.Remove(oldSidFile)
|
||||||
os.Chtimes(newSidFile, time.Now(), time.Now())
|
os.Chtimes(newSidFile, time.Now(), time.Now())
|
||||||
ss := &FileSessionStore{sid: sid, values: kv}
|
ss := &FileSessionStore{sid: sid, values: kv}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import (
|
|||||||
"compress/zlib"
|
"compress/zlib"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
@ -32,7 +31,7 @@ func testOpenFile(encoding string, content []byte, t *testing.T) {
|
|||||||
|
|
||||||
func TestOpenStaticFile_1(t *testing.T) {
|
func TestOpenStaticFile_1(t *testing.T) {
|
||||||
file, _ := os.Open(licenseFile)
|
file, _ := os.Open(licenseFile)
|
||||||
content, _ := ioutil.ReadAll(file)
|
content, _ := io.ReadAll(file)
|
||||||
testOpenFile("", content, t)
|
testOpenFile("", content, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +41,7 @@ func TestOpenStaticFileGzip_1(t *testing.T) {
|
|||||||
fileWriter, _ := gzip.NewWriterLevel(&zipBuf, gzip.BestCompression)
|
fileWriter, _ := gzip.NewWriterLevel(&zipBuf, gzip.BestCompression)
|
||||||
io.Copy(fileWriter, file)
|
io.Copy(fileWriter, file)
|
||||||
fileWriter.Close()
|
fileWriter.Close()
|
||||||
content, _ := ioutil.ReadAll(&zipBuf)
|
content, _ := io.ReadAll(&zipBuf)
|
||||||
|
|
||||||
testOpenFile("gzip", content, t)
|
testOpenFile("gzip", content, t)
|
||||||
}
|
}
|
||||||
@ -53,7 +52,7 @@ func TestOpenStaticFileDeflate_1(t *testing.T) {
|
|||||||
fileWriter, _ := zlib.NewWriterLevel(&zipBuf, zlib.BestCompression)
|
fileWriter, _ := zlib.NewWriterLevel(&zipBuf, zlib.BestCompression)
|
||||||
io.Copy(fileWriter, file)
|
io.Copy(fileWriter, file)
|
||||||
fileWriter.Close()
|
fileWriter.Close()
|
||||||
content, _ := ioutil.ReadAll(&zipBuf)
|
content, _ := io.ReadAll(&zipBuf)
|
||||||
|
|
||||||
testOpenFile("deflate", content, t)
|
testOpenFile("deflate", content, t)
|
||||||
}
|
}
|
||||||
@ -89,7 +88,7 @@ func assetOpenFileAndContent(sch *serveContentHolder, reader *serveContentReader
|
|||||||
t.Log("static content file size not same")
|
t.Log("static content file size not same")
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
bs, _ := ioutil.ReadAll(reader)
|
bs, _ := io.ReadAll(reader)
|
||||||
for i, v := range content {
|
for i, v := range content {
|
||||||
if v != bs[i] {
|
if v != bs[i] {
|
||||||
t.Log("content not same")
|
t.Log("content not same")
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -250,7 +249,7 @@ func getTplDeep(root string, fs http.FileSystem, file string, parent string, t *
|
|||||||
panic("can't find template file:" + file)
|
panic("can't find template file:" + file)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
data, err := ioutil.ReadAll(f)
|
data, err := io.ReadAll(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, [][]string{}, err
|
return nil, [][]string{}, err
|
||||||
}
|
}
|
||||||
@ -324,7 +323,7 @@ func _getTemplate(t0 *template.Template, root string, fs http.FileSystem, subMod
|
|||||||
logs.Trace("template file parse error, not success open file:", err)
|
logs.Trace("template file parse error, not success open file:", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
data, err = ioutil.ReadAll(f)
|
data, err = io.ReadAll(f)
|
||||||
f.Close()
|
f.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Trace("template file parse error, not success read file:", err)
|
logs.Trace("template file parse error, not success read file:", err)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user