Skip to content

Commit

Permalink
✏️ make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Dec 19, 2021
1 parent 67a493e commit 596c75e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions plugin_novel/qianbi.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/wdvxdr1123/ZeroBot/utils/helper"

"github.com/FloatTech/ZeroBot-Plugin/control"
"github.com/FloatTech/ZeroBot-Plugin/utils/encode"
ub "github.com/FloatTech/ZeroBot-Plugin/utils/binary"
)

const (
Expand Down Expand Up @@ -130,12 +130,12 @@ func login(username, password string) {
client := &http.Client{
Jar: gCurCookieJar,
}
usernameData, err := encode.Utf8ToGbk(helper.StringToBytes(username))
usernameData, err := ub.UTF82GBK(helper.StringToBytes(username))
if err != nil {
log.Errorln("[novel]", err)
}
usernameGbk := helper.BytesToString(usernameData)
passwordData, err := encode.Utf8ToGbk(helper.StringToBytes(password))
passwordData, err := ub.UTF82GBK(helper.StringToBytes(password))
if err != nil {
log.Errorln("[novel]", err)
}
Expand All @@ -154,7 +154,7 @@ func login(username, password string) {
}

func search(searchKey string) (searchHtml string) {
searchKeyData, err := encode.Utf8ToGbk(helper.StringToBytes(searchKey))
searchKeyData, err := ub.UTF82GBK(helper.StringToBytes(searchKey))
if err != nil {
log.Errorln("[novel]", err)
}
Expand All @@ -177,7 +177,7 @@ func search(searchKey string) (searchHtml string) {
if err != nil {
log.Errorf("[novel] get response for url=%s got error=%s\n", searchURL, err.Error())
}
searchData, err = encode.GbkToUtf8(searchData)
searchData, err = ub.GBK2UTF8(searchData)
if err != nil {
log.Errorln("[novel]", err)
}
Expand Down
10 changes: 5 additions & 5 deletions utils/encode/encode.go → utils/binary/encode.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package encode
package binary

import (
"bytes"
Expand All @@ -8,8 +8,8 @@ import (
"golang.org/x/text/transform"
)

// GBK 转 UTF-8
func GbkToUtf8(s []byte) ([]byte, error) {
// GBK2UTF8 GBK 转 UTF-8
func GBK2UTF8(s []byte) ([]byte, error) {
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewDecoder())
d, e := ioutil.ReadAll(reader)
if e != nil {
Expand All @@ -18,8 +18,8 @@ func GbkToUtf8(s []byte) ([]byte, error) {
return d, nil
}

// UTF-8 转 GBK
func Utf8ToGbk(s []byte) ([]byte, error) {
// UTF82GBK UTF-8 转 GBK
func UTF82GBK(s []byte) ([]byte, error) {
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewEncoder())
d, e := ioutil.ReadAll(reader)
if e != nil {
Expand Down

0 comments on commit 596c75e

Please sign in to comment.