Go library for common utilities used by cloud applications.
go get -u github.com/rivernews/GoTools
Send a slack message:
// Remember to set environment variable `SLACK_WEBHOOK_URL`
SendSlackMessage("Send a slack message")
Make HTTP request:
Fetch(FetchOption{
URL: "https://example.com",
Method: "POST",
PostData: map[string]string{
"text": message
},
})
Logger with emoji icons:
// Below prints `ℹ️ INFO: This is a info log`
Logger("INFO", "This", "is", "a", "info log")
// For Logger("ERROR", ...) it will also send a slack message to you
- Create file with name convention
<...>_test.go
- Import
"testing"
, then writing the function asfunc TestFetch(t *testing.T) ...
- Run:
export SLACK_WEBHOOK_URL=...
DEBUG=true go test
Do not change package name to main
and run go run fetch_test.go
, use go test
instead.
// commit and push to main first
VERSION=v0.1.6
git tag ${VERSION}
git push origin ${VERSION}
GOPROXY=proxy.golang.org go list -m github.com/rivernews/GoTools@${VERSION}