diff options
| author | Shulhan <ms@kilabit.info> | 2023-05-30 22:31:33 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-05-30 23:34:53 +0700 |
| commit | 4152d59e9e092d72c45e5c7298c3ad1b95d78f3b (patch) | |
| tree | 700f68e2c695b3b0fe4718bef33fac827a489a39 | |
| parent | b2619cda05c46175dc4f2e0ae7efbd3dae8b574b (diff) | |
| download | pakakeh.go-4152d59e9e092d72c45e5c7298c3ad1b95d78f3b.tar.xz | |
lib/smtp: return pointer to the struct type instead of interface
Even if LocalHandler and LocalStorage is one of implementation of
Handler and Storage, it is be better if its return the actual type, to
minimize confusion.
| -rw-r--r-- | lib/smtp/localhandler.go | 5 | ||||
| -rw-r--r-- | lib/smtp/localstorage.go | 10 |
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/smtp/localhandler.go b/lib/smtp/localhandler.go index b9197b36..f7002509 100644 --- a/lib/smtp/localhandler.go +++ b/lib/smtp/localhandler.go @@ -12,10 +12,11 @@ type LocalHandler struct { } // NewLocalHandler create an handler using local environment. -func NewLocalHandler(env *Environment) Handler { - return &LocalHandler{ +func NewLocalHandler(env *Environment) (local *LocalHandler) { + local = &LocalHandler{ env: env, } + return local } // ServeAuth handle SMTP AUTH parameter username and password. diff --git a/lib/smtp/localstorage.go b/lib/smtp/localstorage.go index 2dea098a..86a59ba3 100644 --- a/lib/smtp/localstorage.go +++ b/lib/smtp/localstorage.go @@ -28,7 +28,7 @@ type LocalStorage struct { // NewLocalStorage create and initialize new file storage. If directory is // empty, the default storage is located at "/var/spool/smtp/". -func NewLocalStorage(dir string) (storage Storage, err error) { +func NewLocalStorage(dir string) (storage *LocalStorage, err error) { if len(dir) == 0 { dir = defDirSpool } @@ -45,14 +45,14 @@ func NewLocalStorage(dir string) (storage Storage, err error) { return nil, err } - fs := &LocalStorage{ + storage = &LocalStorage{ dir: dir, } - fs.enc = gob.NewEncoder(&fs.buff) - fs.dec = gob.NewDecoder(&fs.buff) + storage.enc = gob.NewEncoder(&storage.buff) + storage.dec = gob.NewDecoder(&storage.buff) - return fs, nil + return storage, nil } // MailBounce move the incoming mail to bounced state. In this storage |
