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 ¶
- Variables
- func PlatformString() string
- func UserAgent(ctx context.Context, platform, channel string, opts ...Option) (string, error)
- type Channel
- type ChannelType
- type ChannelsResponse
- type Client
- func (cl *Client) All(ctx context.Context) ([]Channel, error)
- func (cl *Client) Channels(ctx context.Context, typ PlatformType) ([]Channel, error)
- func (cl *Client) Latest(ctx context.Context, platform, channel string) (Version, error)
- func (cl *Client) Platforms(ctx context.Context) ([]Platform, error)
- func (cl *Client) UserAgent(ctx context.Context, platform, channel string) (string, error)
- func (cl *Client) Versions(ctx context.Context, platform, channel string, q ...string) ([]Version, error)
- type Error
- type Option
- type Platform
- type PlatformType
- type PlatformsResponse
- type Version
- type VersionsResponse
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var BaseURL = "https://versionhistory.googleapis.com"
BaseURL is the base URL.
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.
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.
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 (*Client) Latest ¶ added in v0.3.0
Latest returns the latest version 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.
type Option ¶
type Option func(*Client)
Option is a version history client option.
func WithLogf ¶
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.
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.
type VersionsResponse ¶
type VersionsResponse struct {
Versions []Version `json:"versions,omitempty"`
NextPageToken string `json:"nextPageToken,omitempty"`
}
VersionsResponse wraps the versions API response.