aocget

package module
v0.0.0-...-1a85700 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2021 License: MIT Imports: 5 Imported by: 1

README

Advent of Code Get (aocget) Go Reference

A small lib to download your puzzle input for a given day.

Uses your session token to authenticate to obtain your personalized input.

Getting your Session Token

  1. Login to Advent of Code
  2. Open your browser's DevTools (usually F12)
  3. Head over to your cookies
  4. Copy the value of the session cookie

Example

package main

import (
	"fmt"
	"github.com/Zyian/aocget"
	"os"
)

func main() {
	aoc := aocget.NewClient(os.Getenv("SESSION_TOKEN"))
	i, err := aoc.DownloadInputString(2021, 1)
	if err != nil {
        fmt.Printf("unable to download input: %v\n", err)
		os.Exit(1)
	}

	fmt.Println(i)
}

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AoCClient

type AoCClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(sessionToken string) *AoCClient

NewClient creates a new http client and saves the session cookie on a struct for reuse

func (*AoCClient) DownloadInputBytes

func (acc *AoCClient) DownloadInputBytes(year, day int) ([]byte, error)

DownloadInputBytes downloads the personalized input for a given year and day combination the result is returned as a raw []byte for more complicated operations

func (*AoCClient) DownloadInputBytesContext

func (acc *AoCClient) DownloadInputBytesContext(ctx context.Context, year, day int) ([]byte, error)

DownloadInputBytesContext downloads the personalized input for a given year and day combination the result is returned as a raw []byte for more complicated operations

func (*AoCClient) DownloadInputString

func (acc *AoCClient) DownloadInputString(year, day int) (string, error)

DownloadInputString downloads the personalized input for a given year and day combination the result is returned as a string

Example
aoc := NewClient(os.Getenv("SESSION_TOKEN"))
i, err := aoc.DownloadInputString(2021, 1)
if err != nil {
	fmt.Printf("unable to download input: %v\n", err)
	os.Exit(1)
}
fmt.Println(i)
Output:

func (*AoCClient) DownloadInputStringContext

func (acc *AoCClient) DownloadInputStringContext(ctx context.Context, year, day int) (string, error)

DownloadInputStringContext downloads the personalized input for a given year and day combination the result is returned as a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL