feat(pull): pull info from github and decode then encode to file to test

This commit is contained in:
DarthMooMancer committed 2026-11-11 12:58:36 -05:00
1 parent d5802790a1
commit 5e4ab8c36a
3 files changed
+699 -2

No files matched your search

BIN
View File
Binary file not shown.
+127 -2
View File
@@ -1,7 +1,132 @@
package main
import ("fmt")
/*
{
"id": "26550475315",
"type": "CreateEvent",
need struct for actor
"actor": {
"id": 4458174,
"login": "ThePrimeagen",
"display_login": "ThePrimeagen",
"gravatar_id": "",
"url": "https://api.github.com/users/ThePrimeagen",
"avatar_url": "https://avatars.githubusercontent.com/u/4458174?"
},
need struct for repo
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
need struct for payload
"payload": {
"ref": "fix/keybindings-to-menu",
"ref_type": "branch",
"full_ref": "refs/heads/fix/keybindings-to-menu",
"master_branch": "quattro",
"description": "Beautiful, Modern & Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:10:52Z"
}
*/
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
/*
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url
*/
type Repo struct {
Id int `json:"id"`
Name string `json:"name"`
Url string `json:"url"`
}
/*
"ref": "fix/keybindings-to-menu",
"ref_type": "branch",
"full_ref": "refs/heads/fix/keybindings-to-menu",
"master_branch": "quattro",
"description": "Beautiful, Modern & Opinionated Linux",
"pusher_type": "user"
*/
type Payload struct {
Ref string `json:"ref"`
RefType string `json:"ref_type"`
FullRef string `json:"full_ref"`
MasterBranch string `json:"master_branch"`
Desc string `json:"description"`
PusherType string `json:"pusher_type"`
}
/*
"public": true,
"created_at": "2026-11-06T22:10:52Z"
*/
type Todo struct {
UserId string `json:"id"`
Type string `json:"type"`
Repo Repo `json:"repo"`
Payload Payload `json:"payload"`
Public bool `json:"public"`
CreatedAt string `json:"created_at"`
}
func main() {
fmt.Println("Hello World")
var user string
args := os.Args[1:]
if len(args) > 0 {
user = args[0]
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Get("https://api.github.com/users/" + user + "/events")
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
panic(fmt.Errorf("%s", "err: statuscode failure: "+resp.Status))
}
var todo []Todo
if err := json.NewDecoder(resp.Body).Decode(&todo); err != nil {
log.Fatalf("Failed to decode json: %v", err)
}
for _, events := range todo {
fmt.Printf("%s, type: %s\n", events.UserId, events.Type)
}
var fileName string = "test.json"
file, err := os.Create(fileName)
if err != nil {
panic(err)
}
encoder := json.NewEncoder(file)
encoder.SetIndent("", " ")
encoder.Encode(todo)
}
+572
View File
@@ -0,0 +1,572 @@
[
{
"id": "26550475315",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/keybindings-to-menu",
"ref_type": "branch",
"full_ref": "refs/heads/fix/keybindings-to-menu",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:10:52Z"
},
{
"id": "26503871722",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/debug-print-unknown",
"ref_type": "branch",
"full_ref": "refs/heads/fix/debug-print-unknown",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:20:16Z"
},
{
"id": "26460806093",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "pr-assets/install-cancel-menus",
"ref_type": "branch",
"full_ref": "refs/heads/pr-assets/install-cancel-menus",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T15:14:22Z"
},
{
"id": "26460750728",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "pr-assets/install-cancel-defaults",
"ref_type": "branch",
"full_ref": "refs/heads/pr-assets/install-cancel-defaults",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T15:13:56Z"
},
{
"id": "26448996618",
"type": "PushEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "refs/heads/fix/transcode-path",
"ref_type": "",
"full_ref": "",
"master_branch": "",
"description": "",
"pusher_type": ""
},
"public": true,
"created_at": "2026-11-06T22:16:44Z"
},
{
"id": "26442852817",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/screenrecord-force-kill",
"ref_type": "branch",
"full_ref": "refs/heads/fix/screenrecord-force-kill",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:22:05Z"
},
{
"id": "26442239550",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/idle-lock",
"ref_type": "branch",
"full_ref": "refs/heads/fix/idle-lock",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:14:58Z"
},
{
"id": "26442015657",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/update-unknown-subcommand",
"ref_type": "branch",
"full_ref": "refs/heads/fix/update-unknown-subcommand",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:12:36Z"
},
{
"id": "26428172393",
"type": "PushEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "refs/heads/fix/audio-input-mute-no-mic",
"ref_type": "",
"full_ref": "",
"master_branch": "",
"description": "",
"pusher_type": ""
},
"public": true,
"created_at": "2026-11-06T22:54:39Z"
},
{
"id": "26425191133",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/agent-empty-prompt",
"ref_type": "branch",
"full_ref": "refs/heads/fix/agent-empty-prompt",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:17:26Z"
},
{
"id": "26424967537",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/copy-code-truncated",
"ref_type": "branch",
"full_ref": "refs/heads/fix/copy-code-truncated",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:17:10Z"
},
{
"id": "26424855026",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/tdlm-quote-folder",
"ref_type": "branch",
"full_ref": "refs/heads/fix/tdlm-quote-folder",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:15:43Z"
},
{
"id": "26421291827",
"type": "PushEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "refs/heads/fix/menu-hover-highlight",
"ref_type": "",
"full_ref": "",
"master_branch": "",
"description": "",
"pusher_type": ""
},
"public": true,
"created_at": "2026-11-06T23:27:25Z"
},
{
"id": "26420856839",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/done-window-enter",
"ref_type": "branch",
"full_ref": "refs/heads/fix/done-window-enter",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:44:15Z"
},
{
"id": "26418211921",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/transcode-path",
"ref_type": "branch",
"full_ref": "refs/heads/fix/transcode-path",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:12:22Z"
},
{
"id": "26418079555",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/audio-input-mute-no-mic",
"ref_type": "branch",
"full_ref": "refs/heads/fix/audio-input-mute-no-mic",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:10:55Z"
},
{
"id": "26417965089",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/menu-hover-highlight",
"ref_type": "branch",
"full_ref": "refs/heads/fix/menu-hover-highlight",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:47:20Z"
},
{
"id": "26417717229",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/tds-opencode-offline",
"ref_type": "branch",
"full_ref": "refs/heads/fix/tds-opencode-offline",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:44:06Z"
},
{
"id": "26415650339",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/theme-set-by-name",
"ref_type": "branch",
"full_ref": "refs/heads/fix/theme-set-by-name",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:20:20Z"
},
{
"id": "26409704060",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/remove-service-descriptions",
"ref_type": "branch",
"full_ref": "refs/heads/fix/remove-service-descriptions",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:21:07Z"
},
{
"id": "26409324615",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/copy-code-false-positive",
"ref_type": "branch",
"full_ref": "refs/heads/fix/copy-code-false-positive",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:17:07Z"
},
{
"id": "26408580671",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/weather-invalid-coords",
"ref_type": "branch",
"full_ref": "refs/heads/fix/weather-invalid-coords",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:08:39Z"
},
{
"id": "26408511672",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/tsl-zero-count",
"ref_type": "branch",
"full_ref": "refs/heads/fix/tsl-zero-count",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:07:54Z"
},
{
"id": "26400269775",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/eff-escape-opens-nvim",
"ref_type": "branch",
"full_ref": "refs/heads/fix/eff-escape-opens-nvim",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:18:52Z"
},
{
"id": "26399290452",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/docker-dbs-cancel",
"ref_type": "branch",
"full_ref": "refs/heads/fix/docker-dbs-cancel",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T22:08:21Z"
},
{
"id": "26397683018",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/install-cancel-defaults",
"ref_type": "branch",
"full_ref": "refs/heads/fix/install-cancel-defaults",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T15:13:46Z"
},
{
"id": "26384992913",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "pr-assets/bar-panel-slot-one",
"ref_type": "branch",
"full_ref": "refs/heads/pr-assets/bar-panel-slot-one",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T17:13:39Z"
},
{
"id": "26370844087",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/bar-panel-slot-one",
"ref_type": "branch",
"full_ref": "refs/heads/fix/bar-panel-slot-one",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T17:13:36Z"
},
{
"id": "26358289348",
"type": "CreateEvent",
"repo": {
"id": 1437301516,
"name": "ThePrimeagen/omarchy",
"url": "https://api.github.com/repos/ThePrimeagen/omarchy"
},
"payload": {
"ref": "fix/install-cancel-menus",
"ref_type": "branch",
"full_ref": "refs/heads/fix/install-cancel-menus",
"master_branch": "quattro",
"description": "Beautiful, Modern \u0026 Opinionated Linux",
"pusher_type": "user"
},
"public": true,
"created_at": "2026-11-06T15:13:48Z"
},
{
"id": "19357305231",
"type": "PullRequestEvent",
"repo": {
"id": 994093166,
"name": "omacom/omarchy",
"url": "https://api.github.com/repos/omacom/omarchy"
},
"payload": {
"ref": "",
"ref_type": "",
"full_ref": "",
"master_branch": "",
"description": "",
"pusher_type": ""
},
"public": true,
"created_at": "2026-11-06T17:13:53Z"
}
]