-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
155 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
``` |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.