Skip to content

Commit

Permalink
Fix a few linter warnings + gofmt + goimports
Browse files Browse the repository at this point in the history
  • Loading branch information
foxcpp committed Jun 23, 2022
1 parent 75ac2a6 commit 80328b8
Show file tree
Hide file tree
Showing 61 changed files with 132 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ nav:
- internals/specifications.md
- internals/unicode.md
- internals/quirks.md
- internals/sqlite.md
- internals/sqlite.md
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ daemon with uniform configuration and minimal maintenance cost.
feature-packed implementation you may want to use Dovecot instead. maddy still
can handle message delivery business.

[![builds.sr.ht status](https://builds.sr.ht/~emersion/maddy.svg)](https://builds.sr.ht/~emersion/maddy?)
[![CI status](https://img.shields.io/github/workflow/status/foxcpp/maddy/Testing%20and%20release%20preparation?style=flat-square)](https://github.com/foxcpp/maddy/actions/workflows/cicd.yml)
[![Issues tracker](https://img.shields.io/github/issues/foxcpp/maddy)](https://github.com/foxcpp/maddy)

* [Setup tutorial](https://maddy.email/tutorials/setting-up/)
Expand Down
2 changes: 1 addition & 1 deletion cmd/maddy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package main

import (
_ "github.com/foxcpp/maddy"
"github.com/foxcpp/maddy/internal/cli"
maddycli "github.com/foxcpp/maddy/internal/cli"
_ "github.com/foxcpp/maddy/internal/cli/ctl"
)

Expand Down
13 changes: 13 additions & 0 deletions cmd/maddy/test.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
state_dir /tmp
runtime_dir /tmp

imap tcp://127.0.0.1:2222 {
tls off
auth pam
storage imapsql {
driver sqlite3
dsn /tmp/hello.db
delivery_map email_localpart
auth_normalize precis_casefold
}
}
3 changes: 2 additions & 1 deletion directories.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !docker
//go:build !docker
// +build !docker

package maddy

Expand Down
3 changes: 2 additions & 1 deletion directories_docker.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build docker
//go:build docker
// +build docker

package maddy

Expand Down
3 changes: 2 additions & 1 deletion framework/dns/debugflags.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build debugflags
//go:build debugflags
// +build debugflags

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion framework/log/syslog.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !windows,!plan9
//go:build !windows && !plan9
// +build !windows,!plan9

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion framework/log/syslog_stub.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build windows plan9
//go:build windows || plan9
// +build windows plan9

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion internal/auth/pam/pam.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build cgo,libpam
//go:build cgo && libpam
// +build cgo,libpam

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion internal/auth/pam/pam_stub.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !cgo !libpam
//go:build !cgo || !libpam
// +build !cgo !libpam

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion internal/auth/shadow/module.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !windows
//go:build !windows
// +build !windows

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
1 change: 0 additions & 1 deletion internal/check/dns/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,3 @@ func TestRequireMXRecord(t *testing.T) {
test("", "", nil, false) // Permit <> for bounces.
test("[email protected]", "example.org", []net.MX{{Host: "."}}, true)
}

3 changes: 2 additions & 1 deletion internal/check/skeleton.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build ignore
//go:build ignore
// +build ignore

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
10 changes: 7 additions & 3 deletions internal/cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ func Run() {
// Actual entry point is registered in maddy.go.

// Print help when called via maddyctl executable. To be removed
// once backward compatbility hack for 'maddy run' is removed too.
// once backward compatibility hack for 'maddy run' is removed too.
if strings.Contains(os.Args[0], "maddyctl") && len(os.Args) == 1 {
app.Run([]string{os.Args[0], "help"})
if err := app.Run([]string{os.Args[0], "help"}); err != nil {
log.DefaultLogger.Error("app.Run failed", err)
}
return
}

app.Run(os.Args)
if err := app.Run(os.Args); err != nil {
log.DefaultLogger.Error("app.Run failed", err)
}
}
3 changes: 2 additions & 1 deletion internal/cli/clitools/termios.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build linux
//go:build linux
// +build linux

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/clitools/termios_stub.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !linux
//go:build !linux
// +build !linux

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/ctl/imap.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ func mboxesCreate(be module.Storage, ctx *cli.Context) error {
}

if ctx.IsSet("special") {
attr := "\\" + strings.Title(ctx.String("special"))
attr := "\\" + strings.Title(ctx.String("special")) //nolint:staticcheck
// (nolint) strings.Title is perfectly fine there since special mailbox tags will never use Unicode.

suu, ok := u.(SpecialUseUser)
if !ok {
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/ctl/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ func usersCreate(be module.PlainUserDB, ctx *cli.Context) error {
}
}

if be, ok := be.(*pass_table.Auth); ok {
return be.CreateUserHash(username, pass, ctx.String("hash"), pass_table.HashOpts{
if beHash, ok := be.(*pass_table.Auth); ok {
return beHash.CreateUserHash(username, pass, ctx.String("hash"), pass_table.HashOpts{
BcryptCost: ctx.Int("bcrypt-cost"),
})
} else if ctx.IsSet("hash") || ctx.IsSet("bcrypt-cost") {
Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/alidns.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_alidns libdns_all
//go:build libdns_alidns || libdns_all
// +build libdns_alidns libdns_all

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/cloudflare.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_cloudflare !libdns_separate
//go:build libdns_cloudflare || !libdns_separate
// +build libdns_cloudflare !libdns_separate

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/digitalocean.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_digitalocean !libdns_separate
//go:build libdns_digitalocean || !libdns_separate
// +build libdns_digitalocean !libdns_separate

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/gandi.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_gandi !libdns_separate
//go:build libdns_gandi || !libdns_separate
// +build libdns_gandi !libdns_separate

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/googleclouddns.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_googleclouddns libdns_all
//go:build libdns_googleclouddns || libdns_all
// +build libdns_googleclouddns libdns_all

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/hetzner.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_hetzner !libdns_separate
//go:build libdns_hetzner || !libdns_separate
// +build libdns_hetzner !libdns_separate

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/leaseweb.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_leaseweb libdns_all
//go:build libdns_leaseweb || libdns_all
// +build libdns_leaseweb libdns_all

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/metaname.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_metaname libdns_all
//go:build libdns_metaname || libdns_all
// +build libdns_metaname libdns_all

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/namecheap.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build go1.16
//go:build go1.16
// +build go1.16

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/namedotcom.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_namedotdom libdns_all
//go:build libdns_namedotdom || libdns_all
// +build libdns_namedotdom libdns_all

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/route53.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_route53 libdns_all
//go:build libdns_route53 || libdns_all
// +build libdns_route53 libdns_all

package libdns

Expand Down
3 changes: 2 additions & 1 deletion internal/libdns/vultr.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build libdns_vultr !libdns_separate
//go:build libdns_vultr || !libdns_separate
// +build libdns_vultr !libdns_separate

package libdns

Expand Down
1 change: 0 additions & 1 deletion internal/modify/replace_addr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func testReplaceAddr(t *testing.T, modName string) {
test("[email protected]", []string{"[email protected]", "[email protected]", "[email protected]"},
map[string][]string{"[email protected]": []string{"[email protected]", "[email protected]", "[email protected]"}})
}

}

func TestReplaceAddr_RewriteSender(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/msgpipeline/msgpipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ func (dd *msgpipelineDelivery) AddRcpt(ctx context.Context, to string) error {
dd.log.Debugln("per-rcpt modifiers:", to, "=>", newTo)

for _, to = range newTo {

wrapErr = func(err error) error {
return exterrors.WithFields(err, map[string]interface{}{
"effective_rcpt": to,
Expand Down
7 changes: 4 additions & 3 deletions internal/storage/blob/test_blob.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build cgo,!no_sqlite3
//go:build cgo && !no_sqlite3
// +build cgo,!no_sqlite3

package blob

Expand Down Expand Up @@ -40,8 +41,8 @@ func TestStore(t *testing.T, newStore func() module.BlobStore, cleanStore func(m

b, err := imapsql.New("sqlite3", ":memory:",
imapsql2.ExtBlobStore{Base: store}, imapsql.Opts{
PRNG: prng,
Log: testutils.Logger(t, "imapsql"),
PRNG: prng,
Log: testutils.Logger(t, "imapsql"),
},
)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/storage/blob/test_blob_nosqlite.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !cgo no_sqlite3
//go:build !cgo || no_sqlite3
// +build !cgo no_sqlite3

package blob

Expand Down
2 changes: 1 addition & 1 deletion internal/storage/imapsql/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func createTestDB(tb testing.TB, compAlgo string) *Storage {
}

db, err := imapsql.New(testDB, testDSN, &imapsql.FSStore{Root: testFsstore}, imapsql.Opts{
CompressAlgo: compAlgo,
CompressAlgo: compAlgo,
})
if err != nil {
tb.Fatal(err)
Expand Down
3 changes: 2 additions & 1 deletion internal/storage/imapsql/sqlite3.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !nosqlite3,cgo
//go:build !nosqlite3 && cgo
// +build !nosqlite3,cgo

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
8 changes: 4 additions & 4 deletions internal/table/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ func (f *File) reloader() {
}()

t := time.NewTicker(reloadInterval)
defer t.Stop()

for {
select {
case <-t.C:
var latestStamp time.Time
info, err := os.Stat(f.file)
if err != nil {
if os.IsNotExist(err) {
Expand All @@ -133,10 +133,10 @@ func (f *File) reloader() {
f.mLck.Unlock()
continue
}
f.log.Printf("%v", err)
f.log.Error("os stat", err)
}
if info.ModTime().After(latestStamp) {
latestStamp = info.ModTime()
if info.ModTime().Before(f.mStamp) {
continue // reload not necessary
}
case <-f.forceReload:
case <-f.stopReloader:
Expand Down
3 changes: 2 additions & 1 deletion internal/table/sql_query_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !nosqlite3,cgo
//go:build !nosqlite3 && cgo
// +build !nosqlite3,cgo

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion internal/table/sqlite3.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !nosqlite3,cgo
//go:build !nosqlite3 && cgo
// +build !nosqlite3,cgo

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion internal/target/remote/debugflags.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build debugflags
//go:build debugflags
// +build debugflags

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion internal/target/skeleton.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build ignore
//go:build ignore
// +build ignore

// Copy that file into target/ subdirectory.

Expand Down
3 changes: 2 additions & 1 deletion maddy_debug.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build debugflags
//go:build debugflags
// +build debugflags

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion signal.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build darwin dragonfly freebsd linux netbsd openbsd solaris
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
// +build darwin dragonfly freebsd linux netbsd openbsd solaris

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion signal_nonposix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build windows plan9
//go:build windows || plan9
// +build windows plan9

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion systemd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build linux
//go:build linux
// +build linux

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion systemd_nonlinux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !linux
//go:build !linux
// +build !linux

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
3 changes: 2 additions & 1 deletion tests/basic_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build integration
//go:build integration
// +build integration

/*
Maddy Mail Server - Composable all-in-one email server.
Expand Down
Loading

0 comments on commit 80328b8

Please sign in to comment.