verhist

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 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 UserAgent

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

UserAgent builds the user agent for the os, channel.

Types

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) UserAgent

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

UserAgent builds the user agent for the os, channel.

func (*Client) Versions

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

Versions returns the versions for the os, channel.

type Option

type Option func(*Client)

Option is a version history client option.

func WithLogf

func WithLogf(logf interface{}, 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 Version

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

Version contains information about a chrome release.

func Versions

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

Versions returns the versions for the os, channel.

func (Version) UserAgent

func (ver Version) UserAgent(os string) string

UserAgent builds the user agent for the

type VersionsResponse

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

VersionsResponse wraps the versions API response.

Jump to

Keyboard shortcuts

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