https://github.com/mfvitale/pastebin-go
A simple Go module to interact with Pastebin
https://github.com/mfvitale/pastebin-go
golang lib library pastebin
Last synced: over 1 year ago
JSON representation
A simple Go module to interact with Pastebin
- Host: GitHub
- URL: https://github.com/mfvitale/pastebin-go
- Owner: mfvitale
- License: mit
- Created: 2022-04-30T09:32:04.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-07T19:36:34.000Z (about 4 years ago)
- Last Synced: 2025-01-26T01:13:44.556Z (over 1 year ago)
- Topics: golang, lib, library, pastebin
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://github.com/mfvitale/pastebin-go/actions/workflows/go.yml)
[](https://pkg.go.dev/github.com/mfvitale/pastebin-go)



# What is pastebin-go?
pastebin-go is a Go library to interact with [Pastebin](https://pastebin.com/)
## Functions
* Create a paste (guest, logged user)
* List Pastes Created By A User
* Delete A Paste Created By A User
* Get raw paste output of users' pastes including 'private' pastes
* Get raw paste output of any 'public' & 'unlisted' pastes
# Getting Started
## Installing
To start using pastebin-go run:
```shell
go get -u https://github.com/mfvitale/pastebin-go
```
## Instantiate anonymous client
With this client you need only the API_DEV_KEY but you can only create 'Guest' paste.
```
package main
import "https://github.com/mfvitale/pastebin-go"
func main() {
client := pastebin.AnonymousClient(API_DEV_KEY)
}
```
## User client
With this client you need:
* API_DEV_KEY
* username
* password
but in this case you have full functions.
```
package main
import "github.com/mfvitale/pastebin-go"
func main() {
client := pastebin.Client(API_DEV_KEY, USERNAME, PASSWORD)
}
```
## Create a Paste
If you instantiate an anonymous client the 'CreatePaste' function will create a 'Guest' paste otherwise it will create a past for the logged user.
```
package main
import (
"fmt"
"github.com/mfvitale/pastebin-go"
)
func main() {
client := pastebin.Client(API_DEV_KEY, USERNAME, PASSWORD)
paste := model.FullPaste("Test paste bin", model.Public, "npm run", "10M", "bash")
pasteLink := client.CreatePaste(paste)
fmt.Println(pasteLink)
}
```
output:
```shell
https://pastebin.com/
```
## List pastes of logged user
This will return a list of paste of the logged user.
```
package main
import (
"fmt"
"github.com/mfvitale/pastebin-go"
)
func main() {
client := pastebin.Client(API_DEV_KEY, USERNAME, PASSWORD)
fmt.Println(client.GetPastes())
}
```
output:
```shell
[{5xM0VBj1 1651314995 Untitled 7 0 0 Bash bash https://pastebin.com/5xM0VBj1 17}]
```