From 629ece947e1d04f388a19d64ba85b2e1a3ba3960 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 17 Nov 2021 23:12:19 +0000 Subject: [PATCH] minor cleanup Signed-off-by: Michael --- Makefile | 28 ++++++++++++++++++++++++++++ go.mod | 2 -- mail/mail.go | 5 +++-- main.go | 4 +--- 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..de98ca6 --- /dev/null +++ b/Makefile @@ -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 \ No newline at end of file diff --git a/go.mod b/go.mod index b6cd3d9..bc00964 100644 --- a/go.mod +++ b/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 ) diff --git a/mail/mail.go b/mail/mail.go index 40bf2d1..36e6c1b 100644 --- a/mail/mail.go +++ b/mail/mail.go @@ -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 diff --git a/main.go b/main.go index 92e4db4..40fecb2 100644 --- a/main.go +++ b/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++ }