-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.go
More file actions
47 lines (34 loc) · 1.17 KB
/
example.go
File metadata and controls
47 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
)
func main() {
developerKey := "Your Pastebin Developer Key" // or use os.Getenv("PASTEBIN_DEVELOPER_KEY") if you set your env variables up
p := &Paste{
apiKey: developerKey,
title: "Title", // Paste title
text: "echo 'Hello World';", // Paste body
expirationDate: "N", // Expiration date (N: Never)
format: "PHP", // Syntax Highlighting
}
u := &User{
apiKey: developerKey,
username: "USERNAME", // Set your username here
password: "PASSWORD", // Set your password here
}
u.GenerateKey() // Generate Key: Generates User API Key (Which is used to delete a paste, or to create a private paste)
newPrivate, err := p.PrivatePaste(u.userKey) // Create a Private paste : PrivatePaste takes userKey(The Generated Key)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(newPrivate)
}
list, err := u.List(10) // List 10 Pastes Maximum
if err != nil {
fmt.Println(err)
} else {
fmt.Println(list)
}
p.pasteID = "xA5DG0" // Set paste id in the Paste struct
p.Delete(u.userKey) // Delete a paste: Delete takes userKey(The generated key)
}