Skip to content

Commit

Permalink
Merge pull request #9 from dasrick/v2
Browse files Browse the repository at this point in the history
v2
  • Loading branch information
dasrick authored Mar 29, 2020
2 parents 652e2e7 + dbc00d6 commit aab6d40
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 161 deletions.
87 changes: 87 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
linters:
enable:
- dogsled
- dupl
- gocognit
- goconst
- gocritic
- gocyclo
- gofmt
- golint
- gosec
- maligned
- nakedret
- prealloc
- scopelint
- unconvert
- unparam
- whitespace

linters-settings:
funlen:
lines: 60
statements: 40

gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10

gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10

golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.3

maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true

nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 2

unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: true

unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false

whitespace:
# Enforces newlines (or comments) after every multi-line if statement
multi-if: true
# Enforces newlines (or comments) after every multi-line function signature
multi-func: true

issues:
# Not using default exclusions because we want to require comments on public
# functions and types.
exclude-use-default: false

# options for analysis running
run:
# include test files or not, default is true
tests: false

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
modules-download-mode: vendor

service:
# use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.20.x
15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# This is a weird way of telling Travis to use the fast container-based test
# runner instead of the slow VM-based runner.
sudo: false
dist: bionic

language: go

go:
- 1.12.x
- 1.13.x
- 1.14.x

before_script:
- go get -u golang.org/x/lint/golint
- go get -u github.com/golang/dep/cmd/dep
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls

script:
- make install
- make lint
- make test
- make race
- make coverage
- go test $(shell go list ./... | grep -v /vendor/) -race -coverprofile=coverage.txt -covermode=atomic

after_success:
- $GOPATH/bin/goveralls -service=travis-ci
- bash <(curl -s https://codecov.io/bash)
- if if [[ $TRAVIS_GO_VERSION == 1.14* ]]; $GOPATH/bin/goveralls -service=travis-ci ; fi
- if if [[ $TRAVIS_GO_VERSION == 1.14* ]]; bash <(curl -s https://codecov.io/bash) ; fi
64 changes: 0 additions & 64 deletions Gopkg.lock

This file was deleted.

30 changes: 0 additions & 30 deletions Gopkg.toml

This file was deleted.

41 changes: 26 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
LIST_ALL := $(shell go list ./... | grep -v /vendor/)

# Force using Go Modules and always read the dependencies from
# the `vendor` folder.
export GO111MODULE = on
#export GOFLAGS = -mod=vendor

.PHONY: all lint test race coverage report dep help
all: lint test

.PHONY: install
install: ## Install the dependencies
@go mod vendor

all: lint test
.PHONY: update
update: ## Update the dependencies
@go mod tidy

.PHONY: clean
clean: ## Remove binaries and ZIP files based on directory `./cmd/`
@rm -rf "$(go env GOCACHE)"
@rm -f coverage.out

lint: ## Lint all files
.PHONY: lint
lint: ## Lint all files (via golangci-lint)
@go fmt ${LIST_ALL}
@golint -set_exit_status ${LIST_ALL}
@golangci-lint run

test: dep ## Run unittests
@go test -short ${LIST_ALL}
.PHONY: test
test: clean ## Run unit tests (incl. race and coverprofile)
@go test -race -cover -short -timeout=90s -coverprofile=coverage.out ${LIST_ALL}

race: dep ## Run data race detector
@go test -race -short ${LIST_ALL}

coverage: dep # Generate coverage report
@go test ${LIST_ALL} -coverprofile coverage.out
.PHONY: coverage
coverage: test ## Generate coverage report
@go tool cover -func coverage.out

report: coverage # Open the coverage report in browser
.PHONY: report
report: coverage ## Open the coverage report in browser
@go tool cover -html=coverage.out


dep: ## Get the dependencies
@dep ensure
# ----------------------------------------------------------------------------------------------------------------------

help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
To get the package, execute:

```
go get gopkg.in/dasrick/go-teams-notify.v1
go get https://github.com/dasrick/go-teams-notify/v2
```

To import this package, add the following line to your code:

```
import "gopkg.in/dasrick/go-teams-notify.v1"
import "github.com/dasrick/go-teams-notify/v2"
```

And this is an example of a simple implementation ...

```
import (
"gopkg.in/dasrick/go-teams-notify.v1"
"github.com/dasrick/go-teams-notify/v2"
)
func main() {
Expand All @@ -44,18 +44,18 @@ func main() {
func sendTheMessage() error {
// init the client
mstClient, err := goteamsnotify.NewClient()
if err != nil {
return err
}
mstClient := goteamsnotify.NewClient()
// setup webhook url
webhookUrl := "https://outlook.office.com/webhook/YOUR_WEBHOOK_URL_OF_TEAMS_CHANNEL"
// setup message card
msgCard := goteamsnotify.NewMessageCard()
msgCard.Title = "Hello world"
msgCard.Text = "Here are some examples of formatted stuff like <br> * this list itself <br> * **bold** <br> * *italic* <br> * ***bolditalic***"
msgCard.ThemeColor = "#DF813D"
// firestarter
// send
return mstClient.Send(webhookUrl, msgCard)
}
```
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/dasrick/go-teams-notify/v2

go 1.14

require github.com/stretchr/testify v1.5.1
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
27 changes: 0 additions & 27 deletions mocks/API.go

This file was deleted.

Loading

0 comments on commit aab6d40

Please sign in to comment.