Skip to content

Go library for common network request utilities

Notifications You must be signed in to change notification settings

rivernews/GoTools

Repository files navigation

GoTools

Go library for common utilities used by cloud applications.

How to install

go get -u github.com/rivernews/GoTools

What's included

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

How to test

  1. Create file with name convention <...>_test.go
  2. Import "testing", then writing the function as func TestFetch(t *testing.T) ...
  3. 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.

How to publish

// 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}

About

Go library for common network request utilities

Resources

Stars

Watchers

Forks

Packages

No packages published