randomwordgenerator

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

README

Random Word Generator

Random Word Generator
==========================
Wrapper client for RandomWordGenerator.com

It allows easy access to the website's interface, enabling efficient random word generation for various applications.

Author: @z3ntl3
License: GNU
Install module

go get github.com/Z3NTL3/randomwordgenerator

Features
  • Proxy tunneling
  • Rapid scraping
  • Easy to adapt
  • Extendable
  • Object oriented API

Quickstart

Look below for 2 examples

package main

import (
	"github.com/Z3NTL3/randomwordgenerator"
	"fmt"
	"log"
)


func main() {
	client := randomwordgenerator.NewClient()
	err := client.SetQuantity(50); if err != nil {
		log.Fatal(err)
	}

	err = client.SetProxy("http://2.56.119.93:5074"); if err != nil {
		log.Fatal(err)
	}

	client.Initialize()

	words, err := client.GenerateWords(); if err != nil {
		log.Fatal(err)
	}
	for _, word := range words {
		fmt.Println(word)
	}
}

/*
OUTPUTL:
    extensiva
    desmajolariais
    dolarizaban
    funambulesco
    aglomeres
    chichinguastes
    envergabais
    jimar
    ensebare
    revalidaban
    gayad
    asentaban
    confiscara
    caricaturaramos
    arqueajes

    ...[30+ rows remaining]
*/
package main

import (
	"github.com/Z3NTL3/randomwordgenerator"
	"context"
	"fmt"
	"log"
	"time"
)


func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 5 * time.Second)
	defer cancel()

	client := randomwordgenerator.WithContext(ctx)
	err := client.SetQuantity(50); if err != nil {
		log.Fatal(err)
	}

	client.Initialize()

	words, err := client.GenerateWords(); if err != nil {
		log.Fatal(err)
	}
	for _, word := range words {
		fmt.Println(word)
	}
}

/*
OUTPUT:
    contrastasen
    palmilla
    beborrotearemos
    recesariais
    saraveadas
    embarcarais
    desagraviara
    obsesionaran
    enjabonariamos
    curucutee

    ...[30+ rows remaining]
*/

Documentation

Index

Constants

View Source
const (
	Version string = "v1.0.0" // exports the current wrapper version

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v1.0.2

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

func NewClient

func NewClient() *Client

Initializes a new client with zero values and a dummy context

Use “WithContext“ instead to use your own context

func WithContext

func WithContext(ctx context.Context) *Client

This function can be used to initialize a new client with a given context

func (*Client) GenerateWords added in v1.0.2

func (c *Client) GenerateWords() (words, error)

This method can be used to generate random words

If a context with a timeout or cancellation is provided, when the cancellation or timeout occurs, it will immediately cancel and return.

func (*Client) GetQuantity added in v1.0.2

func (c *Client) GetQuantity() (quantity int)

Gets the current set quantity

func (*Client) Initialize added in v1.0.2

func (c *Client) Initialize()

Initialize, must be called before starting fetching words

func (*Client) ModifyProxy added in v1.0.2

func (c *Client) ModifyProxy(proxy string) error

Modifies the proxy, if this is called after Initialize it has no effect

func (*Client) SetContext added in v1.0.2

func (c *Client) SetContext(ctx context.Context)

Sets the given context to the client, it can be used to modify but that is not recommended

func (*Client) SetProxy added in v1.0.2

func (c *Client) SetProxy(proxy string) error

Sets the proxy to use while connecting and gathering data from the script utility hosted on randomwordgenerator.com

This method needs to be called before the initialize method

func (*Client) SetQuantity added in v1.0.2

func (c *Client) SetQuantity(quantity int) error

Sets the quantity which determines how many words will be generated at once at a time “quantity“ can not be more than 50.

func (*Client) UseProxy added in v1.0.2

func (c *Client) UseProxy() bool

This method is meant to check if proxy use is active

Jump to

Keyboard shortcuts

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