minor cleanup
Signed-off-by: Michael <michael.lindman@gmail.com>
This commit is contained in:
parent
172b18f962
commit
629ece947e
28
Makefile
Normal file
28
Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
APP=gomail
|
||||
PREFIX=/usr/local
|
||||
|
||||
run: build
|
||||
./$(APP)
|
||||
|
||||
doc:
|
||||
godoc -http=:6090 -index
|
||||
|
||||
build:
|
||||
go build
|
||||
|
||||
install:
|
||||
install -m755 -- $(APP) $(PREFIX)/bin/
|
||||
|
||||
debs:
|
||||
go get ./...
|
||||
|
||||
update-debs:
|
||||
go get -u ./...
|
||||
|
||||
fmt:
|
||||
gofmt -l -s .
|
||||
|
||||
clean:
|
||||
go clean
|
||||
|
||||
.PHONY: run doc build install debs update-debs fmt clean
|
2
go.mod
2
go.mod
@ -3,8 +3,6 @@ module git.0cd.xyz/michael/gomail
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
git.0cd.xyz/michael/gtools v0.1.5
|
||||
github.com/emersion/go-imap v1.1.0
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
)
|
||||
|
@ -2,12 +2,13 @@ package mail
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.0cd.xyz/michael/gtools/colour"
|
||||
"github.com/emersion/go-imap"
|
||||
"github.com/emersion/go-imap/client"
|
||||
)
|
||||
@ -30,7 +31,7 @@ type Messages struct {
|
||||
}
|
||||
|
||||
func Login(addr, username, password string) (mail *Mail, err error) {
|
||||
colour.Green("Connecting to %s\n", addr)
|
||||
fmt.Fprintf(os.Stdout, "\x1b[32mConnecting to %s\n\x1b[0m", addr)
|
||||
client, err := client.DialTLS(addr, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
4
main.go
4
main.go
@ -8,13 +8,11 @@ import (
|
||||
"time"
|
||||
|
||||
"git.0cd.xyz/michael/gomail/mail"
|
||||
"git.0cd.xyz/michael/gtools/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfgFile, mailbox, msgs := ui()
|
||||
cfg := NewConfig(*cfgFile)
|
||||
logger := logger.New(cfg.Logger.Path, cfg.Logger.Mode, cfg.Logger.Level)
|
||||
chErr, chDone := make(chan error), make(chan bool)
|
||||
for _, account := range cfg.Account {
|
||||
go func(addr, username, password string, chErr chan<- error, chDone chan<- bool) {
|
||||
@ -44,7 +42,7 @@ func main() {
|
||||
for c := 0; c < len(cfg.Account); {
|
||||
select {
|
||||
case err := <-chErr:
|
||||
logger.Error.Error(err)
|
||||
log.Println(err)
|
||||
case <-chDone:
|
||||
c++
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user