dawum

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 8 Imported by: 0

README

dawum - a dawum.de Go client

This is a small utility for fetching German election poll data from the https://dawum.de api.

Reference: https://dawum.de/API/

import dependency

go get github.com/jxsl13/dawum@latest

example usage

package main

import (
    "fmt"
    "github.com/jxsl13/dawum"
)

func main() {
    ExampleGetLastUpdate()
    ExampleGetData()
}

func ExampleGetData() {
	data, err := dawum.GetData(context.Background())
	if err != nil {
		panic(err)
	}

	fmt.Println(data)
	// {"Database":{"License":{"Name":"ODC Open Database License","Shortcut":"ODC-ODbL","Link":"https........
}

func ExampleGetLastUpdate() {
	datetime, err := dawum.GetLastUpdate(context.Background())
	if err != nil {
		panic(err)
	}

	fmt.Println(datetime)
	// 2023-09-29T09:41:59+02:00
}

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetData

func GetData(ctx context.Context, os ...Option) (*dto.Data, error)
Example
package main

import (
	"context"
	"fmt"

	"github.com/jxsl13/dawum"
)

func main() {
	data, err := dawum.GetData(context.Background())
	if err != nil {
		panic(err)
	}

	fmt.Println(data)
	// {"Database":{"License":{"Name":"ODC Open Database License","Shortcut":"ODC-ODbL","Link":"https........
}
Output:

func GetLastUpdate

func GetLastUpdate(ctx context.Context, os ...Option) (time.Time, error)
Example
package main

import (
	"context"
	"fmt"

	"github.com/jxsl13/dawum"
)

func main() {
	datetime, err := dawum.GetLastUpdate(context.Background())
	if err != nil {
		panic(err)
	}

	fmt.Println(datetime)
	// 2023-09-29T09:41:59+02:00
}
Output:

Types

type Option

type Option func(*options) error

func WithClient

func WithClient(client *http.Client) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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