Skip to content

Commit

Permalink
Rewrite to use version history API
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshaw committed Jan 7, 2024
1 parent 78285e1 commit 609c220
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 292 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2023 Kenneth Shaw
Copyright (c) 2015-2024 Kenneth Shaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
67 changes: 12 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,29 @@
# omahaproxy
# verhist

Package `omahaproxy` provides a simple client to retrieve data from [Omaha
Proxy][omahaproxy].
Package `verhist` provides a simple client to retrieve the latest release
versions of Chrome using the [version history API][verhist].

[omahaproxy]: https://omahaproxy.appspot.com
[verhist]: https://developer.chrome.com/docs/web-platform/versionhistory/guide

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

## Example

```go
// _example/example.go
package main
package verhist_test

import (
"context"
"flag"
"fmt"
"os"
"runtime"

"github.com/chromedp/omahaproxy"
"github.com/chromedp/verhist"
)

func main() {
platform := "linux"
switch runtime.GOOS {
case "windows":
platform = "win"
if runtime.GOARCH == "amd64" {
platform += "64"
}
case "darwin":
platform = "mac"
if runtime.GOARCH == "aarch64" {
platform += "_arm64"
}
}
verbose := flag.Bool("v", false, "verbose")
osstr := flag.String("os", platform, "os")
channel := flag.String("channel", "stable", "channel")
flag.Parse()
if err := run(context.Background(), *verbose, *osstr, *channel); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
}

func run(ctx context.Context, verbose bool, os, channel string) error {
// enable verbose
var opts []omahaproxy.Option
if verbose {
opts = append(opts, omahaproxy.WithLogf(fmt.Printf))
}
// create client
cl := omahaproxy.New(opts...)
// retrieve recent
releases, err := cl.Recent(ctx)
if err != nil {
return err
}
for _, release := range releases {
fmt.Printf("os: %s channel: %s version: %s\n", release.OS, release.Channel, release.Version)
}
// show latest
ver, err := cl.Latest(ctx, os, channel)
func Example() {
userAgent, err := verhist.UserAgent(context.Background(), "linux", "stable")
if err != nil {
return err
panic(err)
}
fmt.Printf("latest: %s\n", ver)
return nil
fmt.Println(userAgent)
}
```
61 changes: 0 additions & 61 deletions _example/example.go

This file was deleted.

Loading

0 comments on commit 609c220

Please sign in to comment.