Skip to content

Commit

Permalink
perf: fix lint ci
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeEirc committed Sep 20, 2024
1 parent 2b8b896 commit 4860e71
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func registerRouter(jmsService *service.JMService, tunnelService *tunnel.Guacamo
lionGroup.GET("/health/", func(ctx *gin.Context) {
status := make(map[string]interface{})
status["timestamp"] = time.Now().UTC()
status["uptime"] = time.Now().Sub(now).Minutes()
status["uptime"] = time.Since(now).Minutes()
ctx.JSON(http.StatusOK, status)
})
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/jms-sdk-go/httplib/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"net/url"
Expand Down Expand Up @@ -180,7 +179,7 @@ func (c *Client) Do(method, reqUrl string, data, res interface{}, params ...map[
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return resp, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/jms-sdk-go/model/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type Protocols []Protocol

func (p Protocols) GetProtocolPort(protocol string) int {
for i := range p {
if strings.ToLower(p[i].Name) == strings.ToLower(protocol) {
if strings.EqualFold(p[i].Name, protocol) {
return p[i].Port
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/session/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ func (p *Parser) ParseStream(userInChan chan *Message) {
unicode := strconv.FormatInt(int64(keyCode), 16)
bs, _ := hex.DecodeString(unicode[3:])
for i, bl, br, r := 0, len(bs), bytes.NewReader(bs), uint16(0); i < bl; i += 2 {
binary.Read(br, binary.BigEndian, &r)
to += string(r)
_ = binary.Read(br, binary.BigEndian, &r)
to += string(rune(r))
}
b = append(b, []byte(to)...)
} else {
Expand Down
3 changes: 1 addition & 2 deletions pkg/tunnel/cache_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ type GuaTunnelRedisCache struct {
redisProxyExitChan chan string
redisConExitChan chan string

roomLock sync.Mutex
remoteRooms map[string]*Room
roomLock sync.Mutex

Check failure on line 152 in pkg/tunnel/cache_remote.go

View workflow job for this annotation

GitHub Actions / lint

field `roomLock` is unused (unused)
}

func (r *GuaTunnelRedisCache) BroadcastSessionEvent(sid string, event *Event) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/tunnel/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (t *Connection) Run(ctx *gin.Context) (err error) {

switch instruction.Opcode {
case guacd.InstructionClientNop:
if time.Now().Sub(noNopTime) > maxNopTimeout {
if time.Since(noNopTime) > maxNopTimeout {
logger.Errorf("Session[%s] guacamole server nop timeout", t)
if requiredErr.Opcode != "" {
logger.Errorf("Session[%s] send guacamole server required err: %s", t,
Expand Down

0 comments on commit 4860e71

Please sign in to comment.