Created
September 21, 2012 23:41
-
-
Save jl2/3764533 to your computer and use it in GitHub Desktop.
Update to latest developer build of Chromium using Go
This file contains hidden or 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
| package main | |
| import "net/http" | |
| import "fmt" | |
| import "os" | |
| import "os/exec" | |
| import "log" | |
| import "io/ioutil" | |
| func main() { | |
| const VERSION_URL = "http://commondatastorage.googleapis.com/chromium-browser-continuous/Win/LAST_CHANGE" | |
| resp, err := http.Get(VERSION_URL) | |
| if err != nil { | |
| log.Fatal(err) | |
| // handle error | |
| } | |
| defer resp.Body.Close() | |
| body, err := ioutil.ReadAll(resp.Body) | |
| bstring := string(body) | |
| fmt.Println("Updating to Chromium build", bstring) | |
| installer_url := fmt.Sprintf("http://commondatastorage.googleapis.com/chromium-browser-continuous/Win/%s/mini_installer.exe", bstring) | |
| exe_resp, err := http.Get(installer_url) | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| defer exe_resp.Body.Close() | |
| exe_bod, err := ioutil.ReadAll(exe_resp.Body) | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| fmt.Println("Read", len(exe_bod), "bytes from", installer_url) | |
| outf, err := os.Create("mini_installer.exe") | |
| outf.Write(exe_bod) | |
| outf.Close() | |
| install := exec.Command("mini_installer") | |
| err = install.Run() | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment