The official SMTPD Go client library.
The current version is v0.1
Please use go modules and import via github.com/smtpd-dev/go-smtpd/v0.1
.
Make sure your project is using Go Modules (it will have a go.mod
file in its
root if it already is):
go mod init
Then, reference stripe-go in a Go program with import
:
import (
"github.com/smtpd-dev/smtpd-go/v0.1"
)
Run any of the normal go
commands (build
/install
/test
). The Go
toolchain will resolve and fetch the stripe-go module automatically.
Alternatively, you can also explicitly go get
the package into a project:
go get -u github.com/smtpd-dev/smtpd-go/v0.1
package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/joho/godotenv"
smtpd "github.com/smtpd-dev/smtpd-go/v0.1"
"log"
"os"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
key := os.Getenv("API_KEY")
secret := os.Getenv("API_SECRET")
client := smtpd.New(key, secret)
p, err := client.GetAllProfiles()
if err != nil {
log.Fatal(err)
}
fmt.Println(PrettyJSON(p))
}
func PrettyJSON(input interface{}) string {
b, err := json.Marshal(input)
if err != nil {
log.Fatal(err)
}
var prettyJSON bytes.Buffer
err = json.Indent(&prettyJSON, b, "", "\t")
if err != nil {
log.Fatal(err)
}
return string(prettyJSON.Bytes())
}
- None
Pull requests from the community are welcome. If you submit one, please keep the following guidelines in mind:
- Code must be
go fmt
compliant. - All types, structs and funcs should be documented.
- Ensure that
make lint ** make test
succeeds.
Before running the tests, make sure to grab all of the package's dependencies:
go get -t -v
Run all tests:
make test
For any requests, bug or comments, please [open an issue][issues] or [submit a pull request][pulls].