Skip to content

Commit

Permalink
fix more linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
equinox0815 committed Jan 19, 2025
1 parent 3a344bf commit 907e955
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cmd/whawty-nginx-sso/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
package main

import (
"io/ioutil"
"io"
"log"
"os"

Expand All @@ -42,7 +42,7 @@ import (

var (
wl = log.New(os.Stdout, "[whawty.nginx-sso]\t", log.LstdFlags)
wdl = log.New(ioutil.Discard, "[whawty.nginx-sso dbg]\t", log.LstdFlags)
wdl = log.New(io.Discard, "[whawty.nginx-sso dbg]\t", log.LstdFlags)
)

func init() {
Expand Down
1 change: 0 additions & 1 deletion cmd/whawty-nginx-sso/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ func (h *HandlerContext) handleLoginGet(c *gin.Context) {
tmplCtx["redirect"], _ = c.GetQuery("redir")
c.HTML(http.StatusOK, "login.htmpl", tmplCtx)
logTemplateErrors(c)
return
}

func (h *HandlerContext) handleLoginPost(c *gin.Context) {
Expand Down
8 changes: 4 additions & 4 deletions cookie/ed25519_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ MC4CAQAwBQYDK2VwBCIEIG2TybpzwnGPXRU7ekqjCSR3OfIHfv2l4SSvzY0Zw01M

func TestLoadEd25519PublicKey(t *testing.T) {
conf := &Ed25519Config{}
pub, err := loadEd25519PublicKey(conf)
_, err := loadEd25519PublicKey(conf)
if err == nil {
t.Fatal("loading public key from empty config should fail")
}
Expand All @@ -121,7 +121,7 @@ func TestLoadEd25519PublicKey(t *testing.T) {
}

conf.PubKeyData = &testPubKeyEd25519Pem
pub, err = loadEd25519PublicKey(conf)
pub, err := loadEd25519PublicKey(conf)
if err != nil {
t.Fatal("unexpected error:", err)
}
Expand All @@ -144,7 +144,7 @@ func TestLoadEd25519PublicKeyFile(t *testing.T) {

func TestLoadEd25519Keys(t *testing.T) {
conf := &Ed25519Config{}
priv, pub, err := loadEd25519Keys(conf)
_, _, err := loadEd25519Keys(conf)
if err == nil {
t.Fatal("loading private/public key from empty config should fail")
}
Expand All @@ -159,7 +159,7 @@ func TestLoadEd25519Keys(t *testing.T) {
}

conf.PrivKeyData = &testPrivKeyEd25519Pem
priv, pub, err = loadEd25519Keys(conf)
priv, pub, err := loadEd25519Keys(conf)
if err != nil {
t.Fatal("unexpected error:", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cookie/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func TestNew(t *testing.T) {
if s.Username != testUser {
t.Fatalf("the username is wrong, expected: %s, got %s", testUser, s.Username)
}
expire := time.Unix(s.Expires, 0).Sub(time.Now())
expire := time.Until(time.Unix(s.Expires, 0))
expiresDiff := DefaultExpire - expire
if expiresDiff < 0 || expiresDiff > 5*time.Second {
t.Fatalf("expires: expected %v, got %v (diff: %v)", DefaultExpire, expire, expiresDiff)
Expand Down
4 changes: 2 additions & 2 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ func fontAwesomeIconFromAgentInfo(ai cookie.AgentInfo, attribute string) (*pongo

func filterFontAwesomeIcon(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {
obj := in.Interface()
switch obj.(type) {
switch obj := obj.(type) {
case cookie.AgentInfo:
return fontAwesomeIconFromAgentInfo(obj.(cookie.AgentInfo), param.String())
return fontAwesomeIconFromAgentInfo(obj, param.String())
}
err := fmt.Errorf("object type '%T' is not supported", obj)
return nil, &pongo2.Error{Sender: "filter:fa_icon", OrigError: err}
Expand Down

0 comments on commit 907e955

Please sign in to comment.