Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDatabaseIsEmpty = errors.New("database is empty") ErrNewOptions = errors.New("failed to create new options") )
Functions ¶
This section is empty.
Types ¶
type FilterMode ¶
type FilterMode int
const ( FilterModeInclude FilterMode = iota FilterModeExclude )
type OptionSetter ¶
type OptionSetter func(*Options)
func WithDatabase ¶
func WithDatabase(database []UserAgent) OptionSetter
WithDatabase sets your own database of user agents to randomize
func WithFilterMode ¶
func WithFilterMode(mode FilterMode) OptionSetter
WithFilterMode sets a mode to filter user agents
func WithTagFilters ¶
func WithTagFilters(tags ...UserAgentTag) OptionSetter
WithTagFilters sets tags to filter user agents
type Options ¶
type Options struct {
// Database is full list of user agents
Database []UserAgent
// TagFilters is a list of tags to filter user agents
TagFilters []UserAgentTag
// FilterMode is a mode to filter user agents
FilterMode FilterMode
}
func NewOptions ¶
func NewOptions(opts ...OptionSetter) (*Options, error)
NewOptions creates a new options with default values and user options
type UserAgentGenerator ¶
type UserAgentGenerator struct {
// contains filtered or unexported fields
}
func NewUserAgentGenerator ¶
func NewUserAgentGenerator(opts ...OptionSetter) (*UserAgentGenerator, error)
func (*UserAgentGenerator) Random ¶
func (gen *UserAgentGenerator) Random() UserAgent
type UserAgentTag ¶
type UserAgentTag string
var ( // platforms TagDesktop UserAgentTag = "desktop" TagMobile UserAgentTag = "mobile" TagTablet UserAgentTag = "tablet" // browsers TagChrome UserAgentTag = "chrome" TagChroium UserAgentTag = "chromium" TagSafari UserAgentTag = "safari" TagFirefox UserAgentTag = "firefox" TagMSEdge UserAgentTag = "msedge" TagMSIE UserAgentTag = "msie" TagBrave UserAgentTag = "brave" TagYandex UserAgentTag = "yandex" // operating systems TagWindows UserAgentTag = "windows" TagMacOS UserAgentTag = "macos" TagLinux UserAgentTag = "linux" TagAndroid UserAgentTag = "android" TagIOS UserAgentTag = "ios" TagChromeOS UserAgentTag = "chromeos" )
Click to show internal directories.
Click to hide internal directories.