Created
September 2, 2015 20:07
-
-
Save ptrelford/106660d64a1d866294db to your computer and use it in GitHub Desktop.
Go program to download the specified package from Nuget
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
package main | |
import "os" | |
import "fmt" | |
import "net/http" | |
import "io" | |
func downloadPackage(name string) { | |
url := fmt.Sprintf("https://www.nuget.org/api/v2/package/%s",name) | |
resp, _ := http.Get(url) | |
defer resp.Body.Close() | |
file := fmt.Sprintf("%s.nupkg",name) | |
out, _ := os.Create(file) | |
defer out.Close() | |
io.Copy(out, resp.Body) | |
} | |
func main() { | |
if len(os.Args) < 2 { | |
fmt.Print("Please specify a Nuget package") | |
return | |
} | |
name := os.Args[1] | |
downloadPackage(name) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment