device

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 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) IsDesktop

func (d *Device) IsDesktop() bool

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

func (*Device) IsEReader

func (d *Device) IsEReader() bool

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

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.

Jump to

Keyboard shortcuts

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