mirror of
https://github.com/eiblog/eiblog.git
synced 2025-12-19 17:32:24 +08:00
chore: replace ioutil -> io
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -147,7 +146,7 @@ func init() {
|
||||
WorkDir = workDir()
|
||||
path := filepath.Join(WorkDir, "conf", "app.yml")
|
||||
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
htemplate "html/template"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -370,7 +370,7 @@ func handleBeaconPage(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
defer res.Body.Close()
|
||||
data, err := ioutil.ReadAll(res.Body)
|
||||
data, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
logrus.Error("HandleBeaconPage.ReadAll: ", err)
|
||||
return
|
||||
|
||||
@@ -18,7 +18,7 @@ var htmlTmpl *template.Template
|
||||
func init() {
|
||||
htmlTmpl = template.New("eiblog").Funcs(tools.TplFuncMap)
|
||||
root := filepath.Join(config.WorkDir, "website")
|
||||
files := tools.ReadDirFiles(root, func(fi fs.FileInfo) bool {
|
||||
files := tools.ReadDirFiles(root, func(fi fs.DirEntry) bool {
|
||||
name := fi.Name()
|
||||
if name == ".DS_Store" {
|
||||
return true
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -71,7 +71,7 @@ func PostsCount(articles map[string]*model.Article) error {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -91,7 +91,9 @@ func PostsCount(articles map[string]*model.Article) error {
|
||||
|
||||
if article := articles[slug]; article != nil {
|
||||
article.Count = v.Posts
|
||||
article.Thread = v.ID
|
||||
if article.Thread == "" && v.ID != "" {
|
||||
article.Thread = v.ID
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,7 +146,7 @@ func PostsList(article *model.Article, cursor string) (*PostsListResp, error) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -198,7 +200,7 @@ func PostCreate(pc *PostComment) (*PostCreateResp, error) {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -240,7 +242,7 @@ func PostApprove(post string) error {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -282,7 +284,7 @@ func ThreadCreate(article *model.Article, btitle string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -325,7 +327,7 @@ func ThreadDetails(article *model.Article) error {
|
||||
return err
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -160,7 +160,7 @@ func createIndexAndMappings(index, typ string, mappings []byte) error {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -183,7 +183,7 @@ func indexOrUpdateDocument(index, typ string, id int, doc []byte) (err error) {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -220,7 +220,7 @@ func deleteIndexDocument(index, typ string, ids []string) error {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -272,7 +272,7 @@ func indexQueryDSL(index, typ string, size, from int, dsl []byte) (*SearchIndexR
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
@@ -30,7 +30,7 @@ var feedrPingFunc = func(btitle, slug string) error {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -88,7 +88,7 @@ var rpcPingFunc = func(btitle, slug string) error {
|
||||
continue
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
logrus.Error("rpcPingFunc.ReadAll: ", err)
|
||||
continue
|
||||
|
||||
@@ -4,7 +4,7 @@ package tools
|
||||
import (
|
||||
"encoding/base64"
|
||||
htmpl "html/template"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -62,7 +62,7 @@ func GetAvatar(domain string) string {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return ""
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"time"
|
||||
@@ -23,8 +23,8 @@ func EncryptPasswd(name, pass string) string {
|
||||
}
|
||||
|
||||
// ReadDirFiles 读取目录
|
||||
func ReadDirFiles(dir string, filter func(fi fs.FileInfo) bool) (files []string) {
|
||||
fileInfos, err := ioutil.ReadDir(dir)
|
||||
func ReadDirFiles(dir string, filter func(fi fs.DirEntry) bool) (files []string) {
|
||||
fileInfos, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user