diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5ada25c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ +name: build +on: [push, pull_request] +jobs: + test: + strategy: + matrix: + go-version: ["1.19","1.20"] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + + - name: Set up Golang ${{ matrix.go-version }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Test + env: + TZ: Asia/Shanghai + run: | + make test + bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN}} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..78f591a --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +### Go template +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 48915e7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: go - -go: - - 1.2 - - 1.3 - - 1.4 - - 1.5 - - 1.6 - - tip diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e282a75 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +GO ?= go +GOFMT ?= gofmt "-s" +GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*") +VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/ | grep -v /examples/) + +.PHONY: build +build: fmt-check + $(GO) build -o app main.go + +.PHONY: test +test: + $(GO) test -v -coverprofile=cover.out ./... + +.PHONY: cover +cover: + $(GO) tool cover -func=cover.out -o cover_total.out + $(GO) tool cover -html=cover.out -o cover.html + +.PHONY: fmt +fmt: + $(GOFMT) -w $(GOFILES) + +.PHONY: fmt-check +fmt-check: + @diff=$$($(GOFMT) -d $(GOFILES)); \ + if [ -n "$$diff" ]; then \ + echo "Please run 'make fmt' and commit the result:"; \ + echo "$${diff}"; \ + exit 1; \ + fi; \ + echo "\033[34m[Code] format perfect!\033[0m"; + +vet: + $(GO) vet $(VETPACKAGES) + +.PHONY: lint +lint: + golangci-lint run diff --git a/README.md b/README.md index b3be9e1..f49966c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Gomail -[![Build Status](https://travis-ci.org/go-gomail/gomail.svg?branch=v2)](https://travis-ci.org/go-gomail/gomail) [![Code Coverage](http://gocover.io/_badge/gopkg.in/gomail.v2)](http://gocover.io/gopkg.in/gomail.v2) [![Documentation](https://godoc.org/gopkg.in/gomail.v2?status.svg)](https://godoc.org/gopkg.in/gomail.v2) +[![build](https://github.com/verystar/gomail/actions/workflows/build.yml/badge.svg)](https://github.com/verystar/gomail/actions/workflows/build.yml) + +Fork https://github.com/go-gomail/gomail ## Introduction diff --git a/example_test.go b/example_test.go index 90008ab..da5d652 100644 --- a/example_test.go +++ b/example_test.go @@ -7,7 +7,7 @@ import ( "log" "time" - "gopkg.in/gomail.v2" + "github.com/verystar/gomail" ) func Example() { diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..dccfc34 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/verystar/gomail + +go 1.17 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/mime.go b/mime.go index 194d4a7..cdaa349 100644 --- a/mime.go +++ b/mime.go @@ -1,5 +1,3 @@ -// +build go1.5 - package gomail import ( diff --git a/mime_go14.go b/mime_go14.go deleted file mode 100644 index 3dc26aa..0000000 --- a/mime_go14.go +++ /dev/null @@ -1,25 +0,0 @@ -// +build !go1.5 - -package gomail - -import "gopkg.in/alexcesaro/quotedprintable.v3" - -var newQPWriter = quotedprintable.NewWriter - -type mimeEncoder struct { - quotedprintable.WordEncoder -} - -var ( - bEncoding = mimeEncoder{quotedprintable.BEncoding} - qEncoding = mimeEncoder{quotedprintable.QEncoding} - lastIndexByte = func(s string, c byte) int { - for i := len(s) - 1; i >= 0; i-- { - - if s[i] == c { - return i - } - } - return -1 - } -)