pastebin-go is a Go library to interact with Pastebin
- 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
To start using pastebin-go run:
go get -u https://github.com/mfvitale/pastebin-go
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)
}
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)
}
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:
https://pastebin.com/<paste_code>
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:
[{5xM0VBj1 1651314995 Untitled 7 0 0 Bash bash https://pastebin.com/5xM0VBj1 17}]