https://github.com/interaapps/pastefy-go-api
A Go Client for pastefy
https://github.com/interaapps/pastefy-go-api
Last synced: about 1 month ago
JSON representation
A Go Client for pastefy
- Host: GitHub
- URL: https://github.com/interaapps/pastefy-go-api
- Owner: interaapps
- License: mit
- Created: 2022-01-16T18:26:23.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-16T19:36:15.000Z (about 4 years ago)
- Last Synced: 2024-06-20T17:36:03.664Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pastefy Go API Client
```go
package main
import pastefy "github.com/interaapps/pastefy-go-api"
func main() {
client := pastefy.NewClient()
// Not required for just fetching pastes or folders
client.SetApiToken("...")
createPaste := pastefy.Paste{
Title: "test.js",
Content: `console.log("Hey");`,
}
createdPaste, _ := client.CreatePaste(createPaste)
println(createdPaste.RawUrl)
paste, _ := client.GetPaste("ZA8U8CCQ")
println(paste.Content)
paste.Content += `\nconsole.log("There!")`
client.SavePaste(paste)
// Getting folder
folder, _ := client.GetFolder("abcdefgh")
for _, folderPaste := range folder.Pastes {
println(folderPaste.Title)
}
// Getting current logged in user
user, _ := client.GetUser()
if user.LoggedIn {
println("Hello: " + user.Name)
}
// Edit encrypted pastes
password := "password"
paste, _ = paste.Decrypt(password)
paste.Content = "Hey"
paste, _ = paste.Encrypt(password)
_, err := client.SavePaste(paste) // (edited paste, error)
if err == nil {
println("Successful!")
}
}
```