fakenews

package module
v0.0.0-...-3ce526a Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 12 Imported by: 0

README

fakenews

fakenews is a fork of the example from https://github.com/mb-14/gomarkov. The goal of the fork was to make fakenews reusable and extendable.

Documentation

Overview

Example
package main

import (
	"context"
	"log"

	"github.com/mikluko/fakenews"
)

func main() {
	fn := fakenews.NewGenerator(&fakenews.HackernewsSource{Limit: 100, Concurrency: 4})
	if err := fn.Init(context.TODO()); err != nil {
		log.Fatalln(err)
	}
	for i := 0; i < 10; i++ {
		item, err := fn.Generate()
		if err != nil {
			log.Fatalln(err)
		}
		log.Println(item)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Do(*http.Request) (*http.Response, error)
}

type Generator

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

func NewGenerator

func NewGenerator(s Source) *Generator

func (*Generator) Generate

func (fn *Generator) Generate() (string, error)

func (*Generator) Init

func (fn *Generator) Init(ctx context.Context) error

type HackernewsSource

type HackernewsSource struct {
	Client      Client
	Limit       int
	Concurrency int
	// contains filtered or unexported fields
}

func (*HackernewsSource) Fetch

func (s *HackernewsSource) Fetch(ctx context.Context) error

func (*HackernewsSource) Items

func (s *HackernewsSource) Items() []string

type Source

type Source interface {
	Fetch(context.Context) error
	Items() []string
}

Jump to

Keyboard shortcuts

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