Skip to content

Instantly share code, notes, and snippets.

@groob
Forked from pudquick/hi_groob.py
Last active December 12, 2019 01:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groob/4c8fad93733f82d794d389476f2d717d to your computer and use it in GitHub Desktop.
Save groob/4c8fad93733f82d794d389476f2d717d to your computer and use it in GitHub Desktop.
Search my gists ;p
package main
import (
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
)
func main() {
var (
flQuery = flag.String("query", "", "which gist to look up")
)
flag.Parse()
if *flQuery == "" {
showGists()
return
}
searchGists(*flQuery)
}
func showGists() {
resp, err := http.Get("https://gist.github.com/search?q=%40pudquick&ref=searchresults")
if err != nil {
log.Fatal(err)
}
io.Copy(os.Stdout, resp.Body)
}
func searchGists(q string) {
resp, err := http.Get(fmt.Sprintf("https://gist.github.com/search?q=%%40pudquick+%s&ref=searchresults", q))
if err != nil {
log.Fatal(err)
}
io.Copy(os.Stdout, resp.Body)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment