mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-23 18:49:21 +08:00
fix: 解决 go 版本升级导致的代码警告 (#527)
This commit is contained in:
parent
0eb25d8413
commit
e45ef455ef
@ -1,7 +1,6 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||||
@ -35,7 +34,7 @@ func (b *BaseApi) LoadDaemonJsonFile(c *gin.Context) {
|
||||
helper.SuccessWithData(c, "daemon.json is not find in path")
|
||||
return
|
||||
}
|
||||
content, err := ioutil.ReadFile(constant.DaemonJsonPath)
|
||||
content, err := os.ReadFile(constant.DaemonJsonPath)
|
||||
if err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
|
@ -3,7 +3,7 @@ package v1
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
@ -510,7 +510,7 @@ func (b *BaseApi) LoadFromFile(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadFile(req.Path)
|
||||
content, err := os.ReadFile(req.Path)
|
||||
if err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
@ -533,7 +533,7 @@ func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int)
|
||||
|
||||
for i := 0; i < chunkCount; i++ {
|
||||
chunkPath := filepath.Join(fileDir, fmt.Sprintf("%s.%d", fileName, i))
|
||||
chunkData, err := ioutil.ReadFile(chunkPath)
|
||||
chunkData, err := os.ReadFile(chunkPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -599,14 +599,14 @@ func (b *BaseApi) UploadChunkFiles(c *gin.Context) {
|
||||
}
|
||||
defer emptyFile.Close()
|
||||
|
||||
chunkData, err := ioutil.ReadAll(uploadFile)
|
||||
chunkData, err := io.ReadAll(uploadFile)
|
||||
if err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrFileUpload, err)
|
||||
return
|
||||
}
|
||||
|
||||
chunkPath := filepath.Join(fileDir, fmt.Sprintf("%s.%d", filename, chunkIndex))
|
||||
err = ioutil.WriteFile(chunkPath, chunkData, 0644)
|
||||
err = os.WriteFile(chunkPath, chunkData, 0644)
|
||||
if err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrFileUpload, err)
|
||||
return
|
||||
|
@ -5,14 +5,15 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/docker"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/docker"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
||||
@ -321,7 +322,9 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) (
|
||||
if appInstall.HttpsPort > 0 {
|
||||
ports = append(ports, appInstall.HttpsPort)
|
||||
}
|
||||
go OperateFirewallPort(nil, ports)
|
||||
go func() {
|
||||
_ = OperateFirewallPort(nil, ports)
|
||||
}()
|
||||
return &appInstall, nil
|
||||
}
|
||||
|
||||
@ -340,7 +343,7 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) {
|
||||
return nil, err
|
||||
}
|
||||
defer versionRes.Body.Close()
|
||||
body, err := ioutil.ReadAll(versionRes.Body)
|
||||
body, err := io.ReadAll(versionRes.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"path"
|
||||
@ -612,7 +611,7 @@ func updateInstallInfoInDB(appKey, appName, param string, isRestart bool, value
|
||||
return nil
|
||||
}
|
||||
envPath := fmt.Sprintf("%s/%s/%s/.env", constant.AppInstallDir, appKey, appInstall.Name)
|
||||
lineBytes, err := ioutil.ReadFile(envPath)
|
||||
lineBytes, err := os.ReadFile(envPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@ -176,11 +175,11 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback
|
||||
if appendonly == "yes" && redisInfo.Version == "6.0.16" {
|
||||
itemName = "appendonly.aof"
|
||||
}
|
||||
input, err := ioutil.ReadFile(recoverFile)
|
||||
input, err := os.ReadFile(recoverFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = ioutil.WriteFile(composeDir+"/data/"+itemName, input, 0640); err != nil {
|
||||
if err = os.WriteFile(composeDir+"/data/"+itemName, input, 0640); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
"sort"
|
||||
"strconv"
|
||||
@ -267,7 +266,7 @@ func (u *ContainerService) ContainerStats(id string) (*dto.ContainterStats, erro
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -339,7 +338,7 @@ func pullImages(ctx context.Context, client *client.Client, image string) error
|
||||
return err
|
||||
}
|
||||
defer out.Close()
|
||||
_, err = io.Copy(ioutil.Discard, out)
|
||||
_, err = io.Copy(io.Discard, out)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/docker"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
)
|
||||
@ -37,14 +36,14 @@ func (u *ContainerService) PageVolume(req dto.SearchWithPage) (int64, interface{
|
||||
}
|
||||
var (
|
||||
data []dto.Volume
|
||||
records []*types.Volume
|
||||
records []*volume.Volume
|
||||
)
|
||||
sort.Slice(list.Volumes, func(i, j int) bool {
|
||||
return list.Volumes[i].CreatedAt > list.Volumes[j].CreatedAt
|
||||
})
|
||||
total, start, end := len(list.Volumes), (req.Page-1)*req.PageSize, req.Page*req.PageSize
|
||||
if start > total {
|
||||
records = make([]*types.Volume, 0)
|
||||
records = make([]*volume.Volume, 0)
|
||||
} else {
|
||||
if end >= total {
|
||||
end = total
|
||||
@ -119,7 +118,7 @@ func (u *ContainerService) CreateVolume(req dto.VolumeCreat) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
options := volume.VolumeCreateBody{
|
||||
options := volume.CreateOptions{
|
||||
Name: req.Name,
|
||||
Driver: req.Driver,
|
||||
DriverOpts: stringsToMap(req.Options),
|
||||
|
@ -3,7 +3,6 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@ -170,7 +169,7 @@ func (u *CronjobService) HandleRmExpired(backType, backupDir string, cronjob *mo
|
||||
}
|
||||
return
|
||||
}
|
||||
files, err := ioutil.ReadDir(backupDir)
|
||||
files, err := os.ReadDir(backupDir)
|
||||
if err != nil {
|
||||
global.LOG.Errorf("read dir %s failed, err: %v", backupDir, err)
|
||||
return
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
@ -339,7 +338,7 @@ func (u *MysqlService) UpdateVariables(updatas []dto.MysqlVariablesUpdate) error
|
||||
var files []string
|
||||
|
||||
path := fmt.Sprintf("%s/mysql/%s/conf/my.cnf", constant.AppInstallDir, app.Name)
|
||||
lineBytes, err := ioutil.ReadFile(path)
|
||||
lineBytes, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -215,7 +214,7 @@ type redisConfig struct {
|
||||
|
||||
func confSet(redisName string, changeConf []redisConfig) error {
|
||||
path := fmt.Sprintf("%s/redis/%s/conf/redis.conf", constant.AppInstallDir, redisName)
|
||||
lineBytes, err := ioutil.ReadFile(path)
|
||||
lineBytes, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@ -66,7 +65,7 @@ func (u *DockerService) LoadDockerConf() *dto.DaemonJsonConf {
|
||||
if _, err := os.Stat(constant.DaemonJsonPath); err != nil {
|
||||
return &dto.DaemonJsonConf{Status: status, Version: version}
|
||||
}
|
||||
file, err := ioutil.ReadFile(constant.DaemonJsonPath)
|
||||
file, err := os.ReadFile(constant.DaemonJsonPath)
|
||||
if err != nil {
|
||||
return &dto.DaemonJsonConf{Status: status, Version: version}
|
||||
}
|
||||
@ -109,7 +108,7 @@ func (u *DockerService) UpdateConf(req dto.DaemonJsonConf) error {
|
||||
_, _ = os.Create(constant.DaemonJsonPath)
|
||||
}
|
||||
|
||||
file, err := ioutil.ReadFile(constant.DaemonJsonPath)
|
||||
file, err := os.ReadFile(constant.DaemonJsonPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -151,7 +150,7 @@ func (u *DockerService) UpdateConf(req dto.DaemonJsonConf) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil {
|
||||
if err := os.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@ -174,7 +173,7 @@ func (u *ImageService) ImageBuild(req dto.ImageBuild) (string, error) {
|
||||
return
|
||||
}
|
||||
defer res.Body.Close()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
global.LOG.Errorf("build image %s failed, err: %v", req.Name, err)
|
||||
_, _ = file.WriteString(fmt.Sprintf("build image %s failed, err: %v", req.Name, err))
|
||||
@ -275,7 +274,7 @@ func (u *ImageService) ImageLoad(req dto.ImageLoad) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
content, err := ioutil.ReadAll(res.Body)
|
||||
content, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@ -190,7 +189,7 @@ func (u *ImageRepoService) handleRegistries(newHost, delHost, handle string) err
|
||||
}
|
||||
|
||||
deamonMap := make(map[string]interface{})
|
||||
file, err := ioutil.ReadFile(constant.DaemonJsonPath)
|
||||
file, err := os.ReadFile(constant.DaemonJsonPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -226,7 +225,7 @@ func (u *ImageRepoService) handleRegistries(newHost, delHost, handle string) err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil {
|
||||
if err := os.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -1,15 +1,16 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||
@ -67,7 +68,7 @@ func (n NginxService) GetStatus() (response.NginxStatus, error) {
|
||||
if err != nil {
|
||||
return response.NginxStatus{}, err
|
||||
}
|
||||
content, err := ioutil.ReadAll(res.Body)
|
||||
content, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return response.NginxStatus{}, err
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@ -484,7 +483,7 @@ func (u *SnapshotService) SnapshotRollback(req dto.SnapshotRecover) error {
|
||||
|
||||
func (u *SnapshotService) saveJson(snapJson SnapshotJson, path string) error {
|
||||
remarkInfo, _ := json.MarshalIndent(snapJson, "", "\t")
|
||||
if err := ioutil.WriteFile(fmt.Sprintf("%s/snapshot.json", path), remarkInfo, 0640); err != nil {
|
||||
if err := os.WriteFile(fmt.Sprintf("%s/snapshot.json", path), remarkInfo, 0640); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@ -793,7 +792,7 @@ func (u *SnapshotService) updateLiveRestore(enabled bool) error {
|
||||
if _, err := os.Stat(constant.DaemonJsonPath); err != nil {
|
||||
return fmt.Errorf("load docker daemon.json conf failed, err: %v", err)
|
||||
}
|
||||
file, err := ioutil.ReadFile(constant.DaemonJsonPath)
|
||||
file, err := os.ReadFile(constant.DaemonJsonPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -809,7 +808,7 @@ func (u *SnapshotService) updateLiveRestore(enabled bool) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil {
|
||||
if err := os.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
@ -203,7 +203,7 @@ func (u *UpgradeService) loadVersion(isLatest bool, currentVersion string) (stri
|
||||
return "", err
|
||||
}
|
||||
defer latestVersionRes.Body.Close()
|
||||
version, err := ioutil.ReadAll(latestVersionRes.Body)
|
||||
version, err := io.ReadAll(latestVersionRes.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -231,7 +231,7 @@ func (u *UpgradeService) loadReleaseNotes(path string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
defer releaseNotes.Body.Close()
|
||||
release, err := ioutil.ReadAll(releaseNotes.Body)
|
||||
release, err := io.ReadAll(releaseNotes.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
@ -108,7 +107,7 @@ func NewWriterFromConfig(c *Config) (RollingWriter, error) {
|
||||
}
|
||||
if c.MaxRemain > 0 {
|
||||
writer.rollingfilech = make(chan string, c.MaxRemain)
|
||||
dir, err := ioutil.ReadDir(c.LogPath)
|
||||
dir, err := os.ReadDir(c.LogPath)
|
||||
if err != nil {
|
||||
mng.Close()
|
||||
return nil, err
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@ -77,9 +77,9 @@ func OperationLog() gin.HandlerFunc {
|
||||
|
||||
formatMap := make(map[string]interface{})
|
||||
if len(operationDic.BodyKeys) != 0 {
|
||||
body, err := ioutil.ReadAll(c.Request.Body)
|
||||
body, err := io.ReadAll(c.Request.Body)
|
||||
if err == nil {
|
||||
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(body))
|
||||
c.Request.Body = io.NopCloser(bytes.NewBuffer(body))
|
||||
}
|
||||
bodyMap := make(map[string]interface{})
|
||||
_ = json.Unmarshal(body, &bodyMap)
|
||||
|
@ -2,7 +2,7 @@ package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
@ -75,7 +75,7 @@ func (s sftpClient) Upload(src, target string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
defer dstFile.Close()
|
||||
ff, err := ioutil.ReadAll(srcFile)
|
||||
ff, err := io.ReadAll(srcFile)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -62,7 +61,7 @@ func (f *Ufw) PingStatus() (string, error) {
|
||||
}
|
||||
|
||||
func (f *Ufw) UpdatePingStatus(enabel string) error {
|
||||
lineBytes, err := ioutil.ReadFile(confPath)
|
||||
lineBytes, err := os.ReadFile(confPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ package nginx
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/nginx/components"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/nginx/components"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -96,5 +97,5 @@ func DumpConfig(c *components.Config, style *Style) string {
|
||||
}
|
||||
|
||||
func WriteConfig(c *components.Config, style *Style) error {
|
||||
return ioutil.WriteFile(c.FilePath, []byte(DumpConfig(c, style)), 0644)
|
||||
return os.WriteFile(c.FilePath, []byte(DumpConfig(c, style)), 0644)
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
@ -68,7 +67,7 @@ func TestSSL(t *testing.T) {
|
||||
// return
|
||||
//}
|
||||
|
||||
key, err := ioutil.ReadFile("private.key")
|
||||
key, err := os.ReadFile("private.key")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
},
|
||||
// 跳过库检查,解决打包失败
|
||||
"skipLibCheck": true,
|
||||
"ignoreDeprecations": "5.0",
|
||||
"suppressImplicitAnyIndexErrors": true
|
||||
},
|
||||
// "include": ["./src/views"],
|
||||
|
Loading…
Reference in New Issue
Block a user