Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ShuheiKubota committed Aug 26, 2022
1 parent 3f9bf93 commit 8c16bb1
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 13 deletions.
12 changes: 12 additions & 0 deletions .golangci.yml
@@ -0,0 +1,12 @@
linters:
enable:
- gci
- revive
- exportloopref
- errorlint
- dupl
- dupl
- misspell
- tagliatelle
- unparam
- wastedassign
3 changes: 2 additions & 1 deletion cmd_auth.go
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -133,7 +134,7 @@ func slackFetchAccessToken(clientID, clientSecret, authCode, redirectURI string)
dec := json.NewDecoder(resp.Body)
t := slackOAuth2AuthedTokens{}
err = dec.Decode(&t)
if err == io.EOF {
if errors.Is(err, io.EOF) {
return "", fmt.Errorf("auth response from the server is empty")
} else if err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion cmd_delete.go
Expand Up @@ -48,7 +48,7 @@ func (c *deleteCmd) Before(global globalCmd) error {
}

for _, ch := range chans {
if strings.ToLower(c.Chan) == strings.ToLower(ch.Name) {
if strings.EqualFold(c.Chan, ch.Name) {
c.innerChan = ch.ID
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd_download.go
Expand Up @@ -54,7 +54,7 @@ func (c *downloadCmd) Before(global globalCmd) error {
}

for _, ch := range chans {
if strings.ToLower(c.Chan) == strings.ToLower(ch.Name) {
if strings.EqualFold(c.Chan, ch.Name) {
c.innerChan = ch.ID
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd_list.go
Expand Up @@ -49,7 +49,7 @@ func (c *listCmd) Before(global globalCmd) error {
}

for _, ch := range chans {
if strings.ToLower(c.Chan) == strings.ToLower(ch.Name) {
if strings.EqualFold(c.Chan, ch.Name) {
c.innerChan = ch.ID
}
}
Expand Down
3 changes: 1 addition & 2 deletions config.go
Expand Up @@ -3,7 +3,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -65,5 +64,5 @@ func saveConfig(config *config, filePath string) error {
if err := toml.NewEncoder(buf).Encode(config); err != nil {
return err
}
return ioutil.WriteFile(filePath, buf.Bytes(), 0700)
return os.WriteFile(filePath, buf.Bytes(), 0700)
}
6 changes: 1 addition & 5 deletions file.go
Expand Up @@ -56,10 +56,7 @@ func testProp(f slack.File, prop string) bool {
}

func fileProp(f slack.File, prop string) string {
p := strings.ToLower(prop)
if strings.HasPrefix(p, "-") {
p = p[1:]
}
p := strings.TrimPrefix(strings.ToLower(prop), "-")

switch p {
case "id":
Expand Down Expand Up @@ -135,7 +132,6 @@ func fileProp(f slack.File, prop string) string {
default:
return ""
}
return ""
}

func bool2NumStr(b bool) string {
Expand Down
4 changes: 2 additions & 2 deletions minredir/minredir.go
Expand Up @@ -11,7 +11,7 @@ import (
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"io/ioutil"
"io"
"log"
"math/big"
"net"
Expand Down Expand Up @@ -114,7 +114,7 @@ func LaunchMinServerTLS(port int, extractor func(r *http.Request, resultChan cha
defer ln.Close()

// OMAJINAI: call srv.setupHTTP2_ServeTLS()
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)
server.ServeTLS(nil, "", "")
defer log.SetOutput(os.Stderr)

Expand Down

0 comments on commit 8c16bb1

Please sign in to comment.