Skip to content

Instantly share code, notes, and snippets.

@kierdavis
Created October 2, 2012 21:06
Show Gist options
  • Save kierdavis/3823314 to your computer and use it in GitHub Desktop.
Save kierdavis/3823314 to your computer and use it in GitHub Desktop.
Sample code for "use of closed network connection" error
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const TheURL = "http://repo.bukkit.org/service/local/repositories/legacy/content/org/bukkit/bukkit/1.9-pre5-R1-SNAPSHOT/bukkit-1.9-pre5-R1-20111122.004050-46.jar"
func main() {
resp, err := http.Get(TheURL)
if err != nil {
log.Fatal(err)
}
// Dump the response
fmt.Printf("%#v\n", resp)
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment