user_agent

package
v0.0.0-...-0747d37 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Browser

type Browser struct {
	// The name of the browser's engine.
	Engine string

	// The version of the browser's engine.
	EngineVersion string

	// The name of the browser.
	Name string

	// The version of the browser.
	Version string
}

A struct containing all the information that we might be interested from the browser.

type OSInfo

type OSInfo struct {
	// Full name of the operating system. This is identical to the output of ua.OS()
	FullName string

	// Name of the operating system. This is sometimes a shorter version of the
	// operating system name, e.g. "Mac OS X" instead of "Intel Mac OS X"
	Name string

	// Operating system version, e.g. 7 for Windows 7 or 10.8 for Max OS X Mountain Lion
	Version string
}

Represents full information on the operating system extracted from the user agent.

type UserAgent

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

The UserAgent struct contains all the info that can be extracted from the User-Agent string.

func New

func New(ua string) *UserAgent

Parse the given User-Agent string and get the resulting UserAgent object.

Returns an UserAgent object that has been initialized after parsing the given User-Agent string.

func (*UserAgent) Bot

func (p *UserAgent) Bot() bool

Returns true if it's a bot, false otherwise.

func (*UserAgent) Browser

func (p *UserAgent) Browser() (string, string)

Returns two strings. The first string is the name of the browser and the second one is the version of the browser.

func (*UserAgent) Engine

func (p *UserAgent) Engine() (string, string)

Returns two strings. The first string is the name of the engine and the second one is the version of the engine.

func (*UserAgent) Localization

func (p *UserAgent) Localization() string

Returns a string containing the localization.

func (*UserAgent) Mobile

func (p *UserAgent) Mobile() bool

Returns true if it's a mobile device, false otherwise.

func (*UserAgent) Mozilla

func (p *UserAgent) Mozilla() string

Returns the mozilla version (it's how the User Agent string begins: "Mozilla/5.0 ...", unless we're dealing with Opera, of course).

func (*UserAgent) OS

func (p *UserAgent) OS() string

Returns a string containing the name of the Operating System.

func (*UserAgent) OSInfo

func (p *UserAgent) OSInfo() OSInfo

Returns combined information for the operating system.

func (*UserAgent) Parse

func (p *UserAgent) Parse(ua string)

Parse the given User-Agent string. After calling this function, the receiver will be setted up with all the information that we've extracted.

func (*UserAgent) Platform

func (p *UserAgent) Platform() string

Returns a string containing the platform..

func (*UserAgent) UA

func (p *UserAgent) UA() string

Returns the original given user agent.

Jump to

Keyboard shortcuts

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