user_agent: github.com/mssola/user_agent Index | Files

package user_agent

import "github.com/mssola/user_agent"

Package user_agent implements an HTTP User Agent string parser. It defines the type UserAgent that contains all the information from the parsed string. It also implements the Parse function and getters for all the relevant information that has been extracted from a parsed User Agent string.

Index

Package Files

bot.go browser.go operating_systems.go user_agent.go

type Browser Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (p *UserAgent) Bot() bool

Bot returns true if it's a bot, false otherwise.

func (*UserAgent) Browser Uses

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

Browser 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 Uses

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

Engine 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 Uses

func (p *UserAgent) Localization() string

Localization returns a string containing the localization.

func (*UserAgent) Mobile Uses

func (p *UserAgent) Mobile() bool

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

func (*UserAgent) Mozilla Uses

func (p *UserAgent) Mozilla() string

Mozilla 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 Uses

func (p *UserAgent) OS() string

OS returns a string containing the name of the Operating System.

func (*UserAgent) OSInfo Uses

func (p *UserAgent) OSInfo() OSInfo

OSInfo returns combined information for the operating system.

func (*UserAgent) Parse Uses

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 Uses

func (p *UserAgent) Platform() string

Platform returns a string containing the platform..

func (*UserAgent) UA Uses

func (p *UserAgent) UA() string

UA returns the original given user agent.

Package user_agent imports 2 packages (graph) and is imported by 160 packages. Updated 2019-04-12. Refresh now. Tools for package owners.