Skip to content

Instantly share code, notes, and snippets.

@aki237
Last active April 14, 2017 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aki237/600113559fc4012851543f770b59f486 to your computer and use it in GitHub Desktop.
Save aki237/600113559fc4012851543f770b59f486 to your computer and use it in GitHub Desktop.
// We need a URL to be downloaded.
if len(os.Args) < 2 {
fmt.Println("One more commandline argument needed. (url)")
return
}
// assign it to a variable.
url := os.Args[1]
// I'm not checking the URL passed for validity or url query parameters.
// Make a head request for getting the file size.
head, err := http.Head(url)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(head.ContentLength)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment