verhist

package module
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 8 Imported by: 2

README

verhist

Package verhist provides a simple client to retrieve the latest release versions of Chrome using the version history API.

Can also be used to build the latest user agent for Chrome.

Example

package verhist_test

import (
	"context"
	"fmt"

	"github.com/chromedp/verhist"
)

func Example() {
	userAgent, err := verhist.UserAgent(context.Background(), "linux", "stable")
	if err != nil {
		panic(err)
	}
	fmt.Println(userAgent)
}

Documentation

Overview

Package verhist provides a client and utilities for working with the Chrome version history API.

See: https://developer.chrome.com/docs/web-platform/versionhistory/guide

Example
package main

import (
	"context"
	"fmt"

	"github.com/chromedp/verhist"
)

func main() {
	userAgent, err := verhist.UserAgent(context.Background(), "linux", "stable")
	if err != nil {
		panic(err)
	}
	fmt.Println(userAgent != "")
}
Output:
true

Index

Examples

Constants

This section is empty.

Variables

View Source
var BaseURL = "https://versionhistory.googleapis.com"

BaseURL is the base URL.

View Source
var DefaultTransport = http.DefaultTransport

DefaultTransport is the default transport.

Functions

func PlatformString added in v0.3.11

func PlatformString() string

PlatformString returns the Chromium platform string for runtime.GOOS.

func UserAgent

func UserAgent(ctx context.Context, platform, channel string, opts ...Option) (string, error)

UserAgent builds the user agent for the platform, channel.

Types

type Channel added in v0.3.0

type Channel struct {
	Name        string      `json:"name,omitempty"`
	ChannelType ChannelType `json:"channelType,omitempty"`
}

Channel contains information about a chrome channel.

func Channels added in v0.3.0

func Channels(ctx context.Context, typ PlatformType, opts ...Option) ([]Channel, error)

Channels returns channels for the platform type.

type ChannelType added in v0.3.0

type ChannelType string

ChannelType is a channel type.

const (
	Beta       ChannelType = "beta"
	CanaryASAN ChannelType = "canary_asan"
	Canary     ChannelType = "canary"
	Dev        ChannelType = "dev"
	Extended   ChannelType = "extended"
	LTS        ChannelType = "lts"
	LTC        ChannelType = "ltc"
	Stable     ChannelType = "stable"
)

Channel types.

func (ChannelType) MarshalText added in v0.3.0

func (typ ChannelType) MarshalText() ([]byte, error)

MarshalText satisfies the encoding.TextMarshaler interface.

func (ChannelType) String added in v0.3.0

func (typ ChannelType) String() string

String satisfies the fmt.Stinger interface.

func (*ChannelType) UnmarshalText added in v0.3.0

func (typ *ChannelType) UnmarshalText(buf []byte) error

UnmarshalText satisfies the encoding.TextUnmarshaler interface.

type ChannelsResponse added in v0.3.0

type ChannelsResponse struct {
	Channels      []Channel `json:"channels,omitempty"`
	NextPageToken string    `json:"nextPageToken,omitempty"`
}

ChannelsResponse wraps the channels API response.

type Client

type Client struct {
	Transport http.RoundTripper
}

Client is a version history client.

func New

func New(opts ...Option) *Client

New creates a new version history client.

func (*Client) All added in v0.3.0

func (cl *Client) All(ctx context.Context) ([]Channel, error)

All returns all channels.

func (*Client) Channels added in v0.3.0

func (cl *Client) Channels(ctx context.Context, typ PlatformType) ([]Channel, error)

Channels returns channels for the platform type.

func (*Client) Latest added in v0.3.0

func (cl *Client) Latest(ctx context.Context, platform, channel string) (Version, error)

Latest returns the latest version for the platform, channel.

func (*Client) Platforms added in v0.3.0

func (cl *Client) Platforms(ctx context.Context) ([]Platform, error)

Platforms returns platforms.

func (*Client) UserAgent

func (cl *Client) UserAgent(ctx context.Context, platform, channel string) (string, error)

UserAgent builds the user agent for the platform, channel.

func (*Client) Versions

func (cl *Client) Versions(ctx context.Context, platform, channel string, q ...string) ([]Version, error)

Versions returns the versions for the platform, channel.

type Error added in v0.3.0

type Error string

Error is a error.

const (
	// ErrInvalidPlatformType is the invalid platform type error.
	ErrInvalidPlatformType Error = "invalid platform type"
	// ErrInvalidChannelType is the invalid channel type error.
	ErrInvalidChannelType Error = "invalid channel type"
	// ErrInvalidQuery is the invalid query error.
	ErrInvalidQuery Error = "invalid query"
	// ErrNoVersionsAvailable is the no versions available error.
	ErrNoVersionsAvailable Error = "no versions available"
)

Errors.

func (Error) Error added in v0.3.0

func (err Error) Error() string

Error satisfies the [error] interface.

type Option

type Option func(*Client)

Option is a version history client option.

func WithLogf

func WithLogf(logf any, opts ...httplog.Option) Option

WithLogf is a version history client option to set a log handler for HTTP requests and responses.

func WithTransport

func WithTransport(transport http.RoundTripper) Option

WithTransport is a version history client option to set the http transport.

type Platform added in v0.3.0

type Platform struct {
	Name         string       `json:"name,omitempty"`
	PlatformType PlatformType `json:"platformType,omitempty"`
}

Platform contains information about a chrome platform.

func Platforms added in v0.3.0

func Platforms(ctx context.Context, opts ...Option) ([]Platform, error)

Platforms returns platforms.

type PlatformType added in v0.3.0

type PlatformType string

PlatformType is a platform type.

const (
	All          PlatformType = "all"
	Android      PlatformType = "android"
	ChromeOS     PlatformType = "chromeos"
	Fuchsia      PlatformType = "fuchsia"
	IOS          PlatformType = "ios"
	LacrosARM32  PlatformType = "lacros_arm32"
	LacrosARM64  PlatformType = "lacros_arm64"
	Lacros       PlatformType = "lacros"
	Linux        PlatformType = "linux"
	MacARM64     PlatformType = "mac_arm64"
	Mac          PlatformType = "mac"
	Webview      PlatformType = "webview"
	Windows64    PlatformType = "win64"
	WindowsARM64 PlatformType = "win_arm64"
	Windows      PlatformType = "win"
)

Platform types.

func (PlatformType) MarshalText added in v0.3.0

func (typ PlatformType) MarshalText() ([]byte, error)

MarshalText satisfies the encoding.TextMarshaler interface.

func (PlatformType) String added in v0.3.0

func (typ PlatformType) String() string

String satisfies the fmt.Stinger interface.

func (*PlatformType) UnmarshalText added in v0.3.0

func (typ *PlatformType) UnmarshalText(buf []byte) error

UnmarshalText satisfies the encoding.TextUnmarshaler interface.

type PlatformsResponse added in v0.3.0

type PlatformsResponse struct {
	Platforms     []Platform `json:"platforms,omitempty"`
	NextPageToken string     `json:"nextPageToken,omitempty"`
}

PlatformsResponse wraps the platforms API response.

type Version

type Version struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

Version contains information about a chrome release.

func Latest added in v0.3.0

func Latest(ctx context.Context, platform, channel string, opts ...Option) (Version, error)

Latest returns the latest version for the platform, channel.

func Versions

func Versions(ctx context.Context, platform, channel string, opts ...Option) ([]Version, error)

Versions returns the versions for the platform, channel.

func (Version) UserAgent

func (ver Version) UserAgent(platform string) string

UserAgent builds a user agent for the platform.

type VersionsResponse

type VersionsResponse struct {
	Versions      []Version `json:"versions,omitempty"`
	NextPageToken string    `json:"nextPageToken,omitempty"`
}

VersionsResponse wraps the versions API response.

Directories

Path Synopsis
cmd
verhist command

Jump to

Keyboard shortcuts

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