Skip to content

Commit cf12b96

Browse files
authored
Merge pull request nsqio#1427 from mreiferson/cleanup
*: staticcheck linting cleanup
2 parents 9bd7d8b + 24a5fca commit cf12b96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+242
-953
lines changed

.github/workflows/test.yml

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,44 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
imgtag:
15-
- "golang:1.14-buster"
16-
- "golang:1.15-buster"
17-
- "golang:1.16-bullseye"
18-
- "golang:1.17-bullseye"
19-
goarch:
20-
- "amd64"
21-
- "386"
14+
go: ["1.17.x", "1.18.x", "1.19.x"]
15+
arch: ["amd64", "386"]
2216

23-
container: "${{matrix.imgtag}}"
2417
env:
25-
GOPATH: "${{github.workspace}}/go"
26-
GOARCH: "${{matrix.goarch}}"
27-
SRCDIR: "go/src/github.com/nsqio/nsq"
18+
GOARCH: "${{matrix.arch}}"
2819

2920
steps:
3021
- uses: actions/checkout@v2
22+
23+
- uses: WillAbides/[email protected]
3124
with:
32-
path: ${{env.SRCDIR}}
25+
go-version: ${{matrix.go}}
3326

3427
- name: build
35-
run: |
36-
cd $SRCDIR
37-
make all
28+
run: make all
3829

3930
- name: test
40-
run: |
41-
cd $SRCDIR
42-
./test.sh
31+
run: ./test.sh
4332

44-
send-coverage:
33+
staticcheck:
4534
runs-on: ubuntu-20.04
46-
timeout-minutes: 30
47-
container: "golang:1.16-bullseye"
48-
env:
49-
GOPATH: "${{github.workspace}}/go"
50-
SRCDIR: "go/src/github.com/nsqio/nsq"
51-
5235
steps:
5336
- uses: actions/checkout@v2
37+
38+
- uses: dominikh/[email protected]
5439
with:
55-
path: ${{env.SRCDIR}}
40+
version: "2022.1.3"
41+
install-go: false
42+
43+
code-coverage:
44+
runs-on: ubuntu-20.04
45+
steps:
46+
- uses: actions/checkout@v2
5647

57-
- name: Install goveralls
48+
- name: install goveralls
5849
run: go install github.com/mattn/goveralls@latest
5950

60-
- name: Send coverage
51+
- name: send coverage
6152
env:
6253
COVERALLS_TOKEN: ${{secrets.GITHUB_TOKEN}}
63-
run: |
64-
cd $SRCDIR
65-
./coverage.sh --coveralls
54+
run: ./coverage.sh --coveralls

apps/nsq_tail/nsq_tail.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func main() {
106106
cfg.MaxInFlight = *maxInFlight
107107

108108
consumers := []*nsq.Consumer{}
109-
for i := 0; i < len(topics); i += 1 {
109+
for i := 0; i < len(topics); i++ {
110110
log.Printf("Adding consumer for topic: %s\n", topics[i])
111111

112112
consumer, err := nsq.NewConsumer(topics[i], *channel, cfg)

apps/nsq_to_file/file_logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func computeFilenameFormat(opts *Options, topic string) (string, error) {
403403

404404
cff := opts.FilenameFormat
405405
if opts.GZIP || opts.RotateSize > 0 || opts.RotateInterval > 0 || opts.WorkDir != opts.OutputDir {
406-
if strings.Index(cff, "<REV>") == -1 {
406+
if !strings.Contains(cff, "<REV>") {
407407
return "", errors.New("missing <REV> in --filename-format when gzip, rotation, or work dir enabled")
408408
}
409409
} else {

apps/nsq_to_file/nsq_to_file.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ import (
1818
"github.com/nsqio/nsq/internal/version"
1919
)
2020

21-
func hasArg(s string) bool {
22-
argExist := false
23-
flag.Visit(func(f *flag.Flag) {
24-
if f.Name == s {
25-
argExist = true
26-
}
27-
})
28-
return argExist
29-
}
30-
3121
func flagSet() *flag.FlagSet {
3222
fs := flag.NewFlagSet("nsqd", flag.ExitOnError)
3323

apps/nsq_to_http/nsq_to_http.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"flag"
99
"fmt"
1010
"io"
11-
"io/ioutil"
1211
"log"
1312
"math/rand"
1413
"net/http"
@@ -130,7 +129,7 @@ func (p *PostPublisher) Publish(addr string, msg []byte) error {
130129
if err != nil {
131130
return err
132131
}
133-
io.Copy(ioutil.Discard, resp.Body)
132+
io.Copy(io.Discard, resp.Body)
134133
resp.Body.Close()
135134

136135
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
@@ -147,7 +146,7 @@ func (p *GetPublisher) Publish(addr string, msg []byte) error {
147146
if err != nil {
148147
return err
149148
}
150-
io.Copy(ioutil.Discard, resp.Body)
149+
io.Copy(io.Discard, resp.Body)
151150
resp.Body.Close()
152151

153152
if resp.StatusCode != 200 {
@@ -156,16 +155,6 @@ func (p *GetPublisher) Publish(addr string, msg []byte) error {
156155
return nil
157156
}
158157

159-
func hasArg(s string) bool {
160-
argExist := false
161-
flag.Visit(func(f *flag.Flag) {
162-
if f.Name == s {
163-
argExist = true
164-
}
165-
})
166-
return argExist
167-
}
168-
169158
func main() {
170159
var publisher Publisher
171160
var addresses app.StringArray
@@ -306,12 +295,12 @@ func parseCustomHeaders(strs []string) (map[string]string, error) {
306295
for _, s := range strs {
307296
sp := strings.SplitN(s, ":", 2)
308297
if len(sp) != 2 {
309-
return nil, fmt.Errorf("Invalid headers: %q", s)
298+
return nil, fmt.Errorf("invalid header: %q", s)
310299
}
311300
key := strings.TrimSpace(sp[0])
312301
val := strings.TrimSpace(sp[1])
313302
if key == "" || val == "" {
314-
return nil, fmt.Errorf("Invalid headers: %q", s)
303+
return nil, fmt.Errorf("invalid header: %q", s)
315304
}
316305
parsedHeaders[key] = val
317306

apps/nsq_to_nsq/nsq_to_nsq.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,6 @@ func (ph *PublishHandler) HandleMessage(m *nsq.Message, destinationTopic string)
254254
return nil
255255
}
256256

257-
func hasArg(s string) bool {
258-
argExist := false
259-
flag.Visit(func(f *flag.Flag) {
260-
if f.Name == s {
261-
argExist = true
262-
}
263-
})
264-
return argExist
265-
}
266-
267257
func main() {
268258
var selectedMode int
269259

apps/nsqadmin/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func nsqadminFlagSet(opts *nsqadmin.Options) *flag.FlagSet {
5151
flagSet.String("http-client-tls-key", "", "path to key file for the HTTP client")
5252

5353
flagSet.String("allow-config-from-cidr", opts.AllowConfigFromCIDR, "A CIDR from which to allow HTTP requests to the /config endpoint")
54-
flagSet.String("acl-http-header", opts.AclHttpHeader, "HTTP header to check for authenticated admin users")
54+
flagSet.String("acl-http-header", opts.ACLHTTPHeader, "HTTP header to check for authenticated admin users")
5555

5656
nsqlookupdHTTPAddresses := app.StringArray{}
5757
flagSet.Var(&nsqlookupdHTTPAddresses, "lookupd-http-address", "lookupd HTTP address (may be given multiple times)")

apps/nsqd/options.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ var tlsVersionTable = []struct {
4343
val uint16
4444
str string
4545
}{
46-
{tls.VersionSSL30, "ssl3.0"},
4746
{tls.VersionTLS10, "tls1.0"},
4847
{tls.VersionTLS11, "tls1.1"},
4948
{tls.VersionTLS12, "tls1.2"},

apps/to_nsq/to_nsq.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func main() {
7979
}
8080
log.Printf("Throttling messages rate to max:%d/second", *rate)
8181
// every tick increase the number of messages we can send
82-
for _ = range time.Tick(interval) {
82+
for range time.Tick(interval) {
8383
n := atomic.AddInt64(&balance, 1)
8484
// if we build up more than 1s of capacity just bound to that
8585
if n > int64(*rate) {

bench/bench_reader/bench_reader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func main() {
5050
if err != nil {
5151
log.Fatal(err)
5252
}
53-
d := t.Sub(time.Now())
53+
d := time.Until(t)
5454
log.Printf("sleeping until %s (%s)", t, d)
5555
time.Sleep(d)
5656
}

0 commit comments

Comments
 (0)