Skip to content

Instantly share code, notes, and snippets.

@felixge

felixge/main.go Secret

Created October 23, 2017 08:43
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 felixge/2981efeccbe31591069e422c347c5528 to your computer and use it in GitHub Desktop.
Save felixge/2981efeccbe31591069e422c347c5528 to your computer and use it in GitHub Desktop.
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