device

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: Apache-2.0, BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package device provides device dection based on the User-Agent header.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDeviceNotFound is returned when the device is not found.
	ErrDeviceNotFound = errors.New("device not found")

	// ErrUnexpected indicates that an unexpected error occurred.
	ErrUnexpected = errors.New("unexpected error")
)

Functions

This section is empty.

Types

type Device

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

func Lookup

func Lookup(userAgent string) (Device, error)

func (*Device) Brand

func (d *Device) Brand() string

Brand returns the brand of the client device, possibly different from the manufacturer of that device.

func (*Device) HWType

func (d *Device) HWType() string

HWType returns a string representation of the primary client platform hardware. The most commonly used device types are also identified via boolean variables. Because a device may have multiple device types and this variable only has the primary type, we recommend using the boolean variables for logic and using this string representation for logging.

func (*Device) Identified added in v1.6.0

func (d *Device) Identified() bool

UserAgentIdentified returns true if the client device was successfully identified

func (*Device) IsDesktop

func (d *Device) IsDesktop() bool

IsDesktop returns true if the client device is a desktop web browser.

func (*Device) IsDownloader added in v1.6.0

func (d *Device) IsDownloader() bool

UserAgentIsDownloader returns true if the client device is a downloader

func (*Device) IsEReader

func (d *Device) IsEReader() bool

IsEReader returns true if the client device is a reading device (like a Kindle).

func (*Device) IsFeedreader added in v1.6.0

func (d *Device) IsFeedreader() bool

UserAgentIsFeedreader returns true if the client device is a feed reader

func (*Device) IsGameConsole

func (d *Device) IsGameConsole() bool

IsGameConsole returns true if the client device is a video game console (like a PlayStation or Xbox).

func (*Device) IsMediaPlayer

func (d *Device) IsMediaPlayer() bool

IsMediaPlayer returns true if the client device is a media player (like Blu-ray players, iPod devices, and smart speakers such as Amazon Echo).

func (*Device) IsMobile

func (d *Device) IsMobile() bool

IsMobile returns true if the client device is a mobile phone.

func (*Device) IsSmartTV

func (d *Device) IsSmartTV() bool

IsSmartTV returns true if the client device is a smart TV.

func (*Device) IsTVPlayer

func (d *Device) IsTVPlayer() bool

IsTVPlayer returns true if the client device is a set-top box or other TV player (like a Roku or Apple TV).

func (*Device) IsTablet

func (d *Device) IsTablet() bool

IsTablet returns true if the client device is a tablet (like an iPad).

func (*Device) IsTouchscreen

func (d *Device) IsTouchscreen() bool

IsTouchscreen returns true if the client device's screen is touch sensitive.

func (*Device) Model

func (d *Device) Model() string

Model returns the model of the client device.

func (*Device) Name

func (d *Device) Name() string

Name returns the name of the client device.

func (*Device) UserAgentBotName added in v1.6.0

func (d *Device) UserAgentBotName() string

UserAgentBotName returns the bot name (if the user agent is a bot)

func (*Device) UserAgentIsBot added in v1.6.0

func (d *Device) UserAgentIsBot() bool

UserAgentIsBot returns true if the client device is a bot

func (*Device) UserAgentMajor added in v1.6.0

func (d *Device) UserAgentMajor() string

UserAgentMajor returns the major version of the user agent

func (*Device) UserAgentMinor added in v1.6.0

func (d *Device) UserAgentMinor() string

UserAgentMinor returns the minor version of the user agent

func (*Device) UserAgentName added in v1.6.0

func (d *Device) UserAgentName() string

UserAgentName returns the name of the user agent

func (*Device) UserAgentPatch added in v1.6.0

func (d *Device) UserAgentPatch() string

UserAgentPatch returns the patch level version of the user agent

Jump to

Keyboard shortcuts

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