Skip to content

Instantly share code, notes, and snippets.

@felixge felixge/main.go Secret
Created Oct 23, 2017

Embed
What would you like to do?
package main
import (
"flag"
"fmt"
"io/ioutil"
"net/http"
"os"
"runtime"
)
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func run() error {
var (
urlF = flag.String("url", "", "URL to upload to.")
)
flag.Parse()
fmt.Printf("%s\n", runtime.Version())
res, err := http.Get(*urlF)
if err != nil {
return err
}
defer res.Body.Close()
resData, err := ioutil.ReadAll(res.Body)
if err != nil {
return err
}
fmt.Printf("%d %s\n", res.StatusCode, res.Status)
fmt.Printf("%s\n", resData)
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.