1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

fix: golangci-lint staticcheck

This commit is contained in:
Ink-33 2021-01-17 02:46:25 +08:00
parent 1d9f719d13
commit 1001cefb6f
No known key found for this signature in database
GPG Key ID: 5D8B1D036EFB0D2E
2 changed files with 14 additions and 6 deletions

View File

@ -16,6 +16,7 @@ import (
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
"syscall"
"time" "time"
"github.com/Mrs4s/go-cqhttp/server" "github.com/Mrs4s/go-cqhttp/server"
@ -97,6 +98,7 @@ func init() {
} }
func main() { func main() {
var byteKey []byte var byteKey []byte
var isFastStart = false var isFastStart = false
arg := os.Args arg := os.Args
@ -327,7 +329,7 @@ func main() {
c := server.Console c := server.Console
r := server.Restart r := server.Restart
go checkUpdate() go checkUpdate()
signal.Notify(c, os.Interrupt, os.Kill) signal.Notify(c, os.Interrupt, syscall.SIGTERM)
select { select {
case <-c: case <-c:
b.Release() b.Release()
@ -458,7 +460,7 @@ func selfUpdate(imageUrl string) {
} }
func restart(Args []string) { func restart(Args []string) {
cmd := &exec.Cmd{} var cmd *exec.Cmd
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
file, err := exec.LookPath(Args[0]) file, err := exec.LookPath(Args[0])
if err != nil { if err != nil {

View File

@ -5,8 +5,6 @@ import (
"bytes" "bytes"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"github.com/Mrs4s/MiraiGo/utils"
"github.com/gin-contrib/pprof"
"image" "image"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -14,8 +12,12 @@ import (
"os/signal" "os/signal"
"strconv" "strconv"
"strings" "strings"
"syscall"
"time" "time"
"github.com/Mrs4s/MiraiGo/utils"
"github.com/gin-contrib/pprof"
"github.com/Mrs4s/MiraiGo/client" "github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/go-cqhttp/coolq" "github.com/Mrs4s/go-cqhttp/coolq"
"github.com/Mrs4s/go-cqhttp/global" "github.com/Mrs4s/go-cqhttp/global"
@ -91,14 +93,14 @@ func (s *webServer) Run(addr string, cli *client.QQClient) *coolq.CQBot {
log.Error(err) log.Error(err)
log.Infof("请检查端口是否被占用.") log.Infof("请检查端口是否被占用.")
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill) signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c <-c
os.Exit(1) os.Exit(1)
} }
} else { } else {
//关闭端口监听 //关闭端口监听
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill) signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c <-c
os.Exit(1) os.Exit(1)
} }
@ -155,6 +157,10 @@ func (s *webServer) Dologin() {
os.Exit(0) os.Exit(0)
} }
rsp, err = cli.SubmitTicket(ticket) rsp, err = cli.SubmitTicket(ticket)
if err != nil {
log.Warnf("错误: " + err.Error())
os.Exit(0)
}
continue continue
case client.NeedCaptcha: case client.NeedCaptcha:
_ = ioutil.WriteFile("captcha.jpg", rsp.CaptchaImage, 0644) _ = ioutil.WriteFile("captcha.jpg", rsp.CaptchaImage, 0644)