Documentation
¶
Index ¶
- Variables
- func GetInitError() error
- func GetRandomDesktopUA() (string, error)
- func GetRandomMobileUA() (string, error)
- func GetRandomUA() (string, error)
- type Config
- type Manager
- func (m *Manager) GetAllDesktop() []UserAgent
- func (m *Manager) GetAllMobile() []UserAgent
- func (m *Manager) GetRandomDesktop() (UserAgent, error)
- func (m *Manager) GetRandomDesktopUA() (string, error)
- func (m *Manager) GetRandomMobile() (UserAgent, error)
- func (m *Manager) GetRandomMobileUA() (string, error)
- func (m *Manager) GetRandomUA() (string, error)
- type UserAgent
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyAgentList is returned when trying to get a random agent from an empty list ErrEmptyAgentList = errors.New("agent list is empty") // ErrInvalidData is returned when user agent data is invalid ErrInvalidData = errors.New("invalid user agent data") // ErrFileNotFound is returned when the embedded file cannot be found ErrFileNotFound = errors.New("embedded file not found") )
Functions ¶
func GetInitError ¶ added in v0.1.5
func GetInitError() error
GetInitError returns any error that occurred during initialization
func GetRandomDesktopUA ¶
GetRandomDesktopUA returns just the UA string of a random desktop user agent using the default manager
func GetRandomMobileUA ¶
GetRandomMobileUA returns just the UA string of a random mobile user agent using the default manager
func GetRandomUA ¶
GetRandomUA returns a random user agent string from either desktop or mobile using the default manager
Types ¶
type Config ¶ added in v0.1.5
Config holds runtime configuration for the user agent library
func DefaultConfig ¶ added in v0.1.5
func DefaultConfig() Config
DefaultConfig returns the default configuration
type Manager ¶ added in v0.1.5
type Manager struct {
// contains filtered or unexported fields
}
Manager handles user agent data with thread-safe operations
func NewManager ¶ added in v0.1.5
NewManager creates a new Manager with the given configuration
func (*Manager) GetAllDesktop ¶ added in v0.1.5
GetAllDesktop returns a copy of all desktop user agents
func (*Manager) GetAllMobile ¶ added in v0.1.5
GetAllMobile returns a copy of all mobile user agents
func (*Manager) GetRandomDesktop ¶ added in v0.1.5
GetRandomDesktop returns a random desktop UserAgent using weighted random selection
func (*Manager) GetRandomDesktopUA ¶ added in v0.1.5
GetRandomDesktopUA returns just the UA string of a random desktop user agent
func (*Manager) GetRandomMobile ¶ added in v0.1.5
GetRandomMobile returns a random mobile UserAgent using weighted random selection
func (*Manager) GetRandomMobileUA ¶ added in v0.1.5
GetRandomMobileUA returns just the UA string of a random mobile user agent
func (*Manager) GetRandomUA ¶ added in v0.1.5
GetRandomUA returns a random user agent string from either desktop or mobile
type UserAgent ¶
UserAgent represents a user agent string with its usage percentage
func GetAllDesktop ¶
GetAllDesktop returns all desktop user agents using the default manager
func GetAllMobile ¶
GetAllMobile returns all mobile user agents using the default manager
func GetRandomDesktop ¶
GetRandomDesktop returns a random desktop UserAgent using the default manager
func GetRandomMobile ¶
GetRandomMobile returns a random mobile UserAgent using the default manager