Skip to content

Commit 3b9527d

Browse files
authored
Init version (#1)
1 parent e93f872 commit 3b9527d

24 files changed

+999
-10
lines changed

.github/workflows/pre-commit.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ main ]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
- uses: pre-commit/[email protected]

.github/workflows/test.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
11
name: CI
22

33
on:
4-
push:
5-
branches: ["main"]
64
pull_request:
5+
push:
76
branches: ["main"]
87

98
jobs:
109
build-and-test:
1110
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
go-version: ["1.21", "1.22", "1.23"]
14+
include:
15+
- go-version: "1.23"
16+
upload-coverage: true
17+
- go-version: "1.21"
18+
upload-coverage: false
19+
- go-version: "1.22"
20+
upload-coverage: false
1221
steps:
1322
- uses: actions/checkout@v4
1423

1524
- name: Set up Go
1625
uses: actions/setup-go@v5
1726
with:
18-
go-version: "1.23"
27+
go-version: "${{ matrix.go-version }}"
1928

20-
- name: Tests
29+
- name: Run Tests
2130
run: go test ./... -v -race -coverprofile=coverage.txt
2231

2332
- name: Upload coverage to Codecov
33+
if: ${{ matrix.upload-coverage == true }}
2434
uses: codecov/codecov-action@v5
2535
with:
2636
files: coverage.txt
27-
flags: unittests
37+
flags: ${{ matrix.go-version }}
2838
name: CI Test Coverage
39+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,7 @@ Temporary Items
160160
# iCloud generated files
161161
*.icloud
162162

163-
# End of https://www.toptal.com/developers/gitignore/api/macos,go,goland+all,linux
163+
# End of https://www.toptal.com/developers/gitignore/api/macos,go,goland+all,linux
164+
165+
# Coverage
166+
coverage.txt

.idea/vcs.xml

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-added-large-files
10+
11+
- repo: https://github.com/golangci/golangci-lint
12+
rev: v1.63.4
13+
hooks:
14+
- id: golangci-lint
15+
entry: golangci-lint run --fix
16+
pass_filenames: false

CONTRIBUTING.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Contributing to Temp Mail Go Client
2+
3+
First off, thank you for taking the time to contribute! The following guidelines will help you make useful contributions that align with our project goals and standards.
4+
5+
## Table of Contents
6+
- [Project Overview](#project-overview)
7+
- [Getting Started](#getting-started)
8+
- [Reporting Issues](#reporting-issues)
9+
- [Suggesting Enhancements](#suggesting-enhancements)
10+
- [Pull Requests](#pull-requests)
11+
- [Code Style](#code-style)
12+
- [Testing](#testing)
13+
- [Community and Code of Conduct](#community-and-code-of-conduct)
14+
15+
## Project Overview
16+
The **Temp Mail Go Client** provides developers a reliable way to interact with the [Temp Mail API](https://docs.temp-mail.io). We welcome contributions that improve features, fix bugs, add documentation, or enhance test coverage.
17+
18+
## Getting Started
19+
1. **Fork the Repository**: Click the "Fork" button at the top-right corner of the [main repo](https://github.com/temp-mail-io/temp-mail-go).
20+
2. **Clone Your Fork**:
21+
```bash
22+
git clone https://github.com/<your-username>/temp-mail-go.git
23+
```
24+
3. **Create a Branch** for your contribution:
25+
```bash
26+
git checkout -b feature/your-feature-name
27+
```
28+
4. **Install Dependencies**:
29+
```bash
30+
go mod download
31+
```
32+
5. **Make Your Changes** in the new branch.
33+
34+
## Reporting Issues
35+
If you find a bug or run into an issue, please check [existing issues](https://github.com/temp-mail-io/temp-mail-go/issues) first. If it’s not already reported:
36+
1. Click on **New issue**.
37+
2. Provide a clear, descriptive title.
38+
3. Describe the steps to reproduce, the expected behavior, and the actual behavior.
39+
4. Provide any relevant logs, error messages, or screenshots.
40+
41+
## Suggesting Enhancements
42+
We’re open to new features and improvements. When creating an issue for a feature request:
43+
1. Clearly explain the proposed feature.
44+
2. Describe why it would be useful.
45+
3. Include any relevant examples or mockups.
46+
47+
## Pull Requests
48+
1. **Ensure your work is up to date**: Rebase your branch onto the latest `main` branch before opening a PR:
49+
```bash
50+
git checkout main
51+
git pull upstream main
52+
git checkout feature/your-feature-name
53+
git rebase main
54+
```
55+
2. **Commit Messages**: Use descriptive commit messages that explain _what_ changes you made and _why_.
56+
3. **Open a Pull Request**:
57+
- Ensure you have meaningful title and description.
58+
- Reference any related issues or pull requests.
59+
- Provide testing steps or instructions for how reviewers can verify your work.
60+
4. **Code Review**: Maintainers will review your PR and may suggest changes. Please be open to feedback and update your PR accordingly.
61+
62+
## Code Style
63+
- **Go Version**: We aim to support the latest stable Go release.
64+
- **Linting**: We recommend using [golangci-lint](https://golangci-lint.run/) for consistency. The project’s CI runs lint checks automatically.
65+
- **Formatting**: Run `go fmt ./...` before committing.
66+
67+
## Testing
68+
- We rely on the [Testify](https://github.com/stretchr/testify) framework to simplify and improve readability of our tests.
69+
- Unit Tests: Include thorough coverage where possible, testing with mocks or test servers to avoid external dependencies.
70+
- Run the tests locally:
71+
```bash
72+
go test ./... -v
73+
```
74+
- The CI (GitHub Actions) will also run tests automatically on each pull request.
75+
76+
## Community and Code of Conduct
77+
78+
We adhere to the standard [Contributor Covenant](https://www.contributor-covenant.org/) to foster a welcoming and inclusive community. Please be respectful and constructive when discussing or reviewing code.
79+
80+
---
81+
82+
Thank you again for your interest in contributing to the Temp Mail Go Client. We look forward to working with you!

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Bump Team Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Temp Mail Go Client
2+
[![Go Reference](https://pkg.go.dev/badge/github.com/temp-mail-io/temp-mail-go.svg)](https://pkg.go.dev/github.com/temp-mail-io/temp-mail-go)
3+
[![Go](https://github.com/temp-mail-io/temp-mail-go/actions/workflows/test.yml/badge.svg)](https://github.com/temp-mail-io/temp-mail-go/actions)
4+
5+
The **official Go Client** for [Temp Mail](https://temp-mail.io). This library provides developers a straightforward way to create and manage temporary email addresses, retrieve and delete messages, all via the Temp Mail API.
6+
7+
## Table of Contents
8+
- [Features](#features)
9+
- [Installation](#installation)
10+
- [Quick Start](#quick-start)
11+
- [Usage Examples](#usage-examples)
12+
- [Listing Domains](#listing-domains)
13+
- [Getting Rate Limits](#getting-rate-limits)
14+
- [Creating Temporary Email](#creating-temporary-email)
15+
- [Fetching and Deleting Messages](#fetching-and-deleting-messages)
16+
- [Testing](#testing)
17+
- [Contributing](#contributing)
18+
- [License](#license)
19+
- [Support](#support)
20+
21+
## Features
22+
- **Create** temporary email addresses with optional domain specifications
23+
- **Get** current rate limits after API request
24+
- **Delete** a temporary email along with all its messages
25+
- **Retrieve** all messages for a specified email
26+
- **Get** a specific message or download its attachment
27+
28+
## Installation
29+
To install this Go package, run:
30+
```bash
31+
go get github.com/temp-mail-io/temp-mail-go
32+
```
33+
34+
## Quick Start
35+
Below is a simple example to get started:
36+
```go
37+
package main
38+
39+
import (
40+
"context"
41+
"fmt"
42+
"log"
43+
44+
"github.com/temp-mail-io/temp-mail-go"
45+
)
46+
47+
func main() {
48+
// Replace with your real API key
49+
client := tempmail.NewClient("YOUR_API_KEY", nil)
50+
51+
domains, _, err := client.ListDomains(context.Background())
52+
if err != nil {
53+
log.Fatalf("Error listing domains: %v", err)
54+
}
55+
56+
fmt.Println("Available domains:", domains)
57+
}
58+
```
59+
60+
## Usage Examples
61+
### Listing Domains
62+
```go
63+
domains, _, err := client.ListDomains(context.Background())
64+
if err != nil {
65+
// handle error
66+
}
67+
for _, d := range domains.Domains {
68+
fmt.Printf("Domain: %s, Type: %s\n", d.Name, d.Type)
69+
}
70+
```
71+
72+
### Getting Rate Limits
73+
```go
74+
rate, _, err := client.RateLimit(context.Background())
75+
if err != nil {
76+
// handle error
77+
}
78+
fmt.Printf("limit: %d, used: %d, remaining: %d, reset: %s\n", resp.Limit, resp.Used, resp.Remaining, resp.Reset)
79+
// Output: limit: 1000, used: 0, remaining: 1000, reset: 2025-01-31 23:59:59 +0000 UTC
80+
```
81+
82+
You can also get the rate limits from the response headers:
83+
```go
84+
email, resp, err := client.CreateEmail(context.Background(), tempmail.CreateEmailOptions{})
85+
if err != nil {
86+
// handle error
87+
}
88+
fmt.Printf("Rate limit: %d\n", resp.Rate.Limit)
89+
```
90+
91+
### Creating Temporary Email
92+
```go
93+
email, _, err := client.CreateEmail(context.Background(), tempmail.CreateEmailOptions{
94+
Domain: "example.com",
95+
})
96+
if err != nil {
97+
// handle error
98+
}
99+
fmt.Printf("Created temporary email: %s (TTL: %s)\n", email.Email, email.TTL)
100+
```
101+
102+
### Fetching and Deleting Messages
103+
```go
104+
messages, _, err := client.ListEmailMessages(context.Background(), "[email protected]")
105+
if err != nil {
106+
// handle error
107+
}
108+
fmt.Printf("Fetched %d messages.\n", len(messages))
109+
110+
// Deleting a specific message
111+
_, err = client.DeleteMessage(context.Background(), messages[0].ID)
112+
if err != nil {
113+
// handle error
114+
}
115+
```
116+
117+
## Testing
118+
We use the Go testing framework with both unit tests and optional integration tests.
119+
120+
Run tests locally:
121+
```bash
122+
go test ./... -v
123+
```
124+
125+
In CI, the tests are automatically executed via [GitHub Actions](https://github.com/temp-mail-io/temp-mail-go/actions).
126+
127+
## Contributing
128+
We welcome and appreciate contributions! Please see our CONTRIBUTING.md for guidelines on how to open issues, submit pull requests, and follow our coding standards.
129+
130+
## License
131+
This project is licensed under the MIT License.
132+
133+
## Support
134+
If you encounter any issues, please open [an issue](https://github.com/temp-mail-io/temp-mail-go/issues) on GitHub. We are happy to help you!

0 commit comments

Comments
 (0)