Help us shape the future of Go! Take the 2026 Go Developer Survey

uarand

package module
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: MIT Imports: 2 Imported by: 0

README

uarand

Build Status

Random user-agent producer for go.

Example

package main

import (
	"fmt"

	"github.com/corpix/uarand"
)

func main() {
	fmt.Println(uarand.GetRandom())
}

Save it to snippet.go and run:

go run snippet.go

Which should produce something similar to:

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Default is the UARand with default settings.
	Default = New(
		rand.New(
			rand.NewSource(time.Now().UnixNano()),
		),
	)
)
View Source
var (
	// UserAgents is a list of browser and bots user agents.
	UserAgents = []string{}/* 822 elements not displayed */

)

Functions

func GetRandom

func GetRandom() string

GetRandom returns a random user agent from UserAgents slice. This version is driven by Default configuration.

Types

type Randomizer

type Randomizer interface {
	Seed(n int64)
	Intn(n int) int
}

Randomizer represents some entity which could provide us an entropy.

type UARand

type UARand struct {
	Randomizer
	UserAgents []string
}

UARand describes the user agent randomizer settings.

func New

func New(r Randomizer) *UARand

New return UserAgent randomizer settings with default user-agents list

func NewWithCustomList

func NewWithCustomList(userAgents []string) *UARand

NewWithCustomList return UserAgent randomizer settings with custom user-agents list

func (*UARand) GetRandom

func (u *UARand) GetRandom() string

GetRandom returns a random user agent from UserAgents slice.

Jump to

Keyboard shortcuts

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