Categories
Go

Golang Resources

A list of resources that have helped me get familiar with Go and all its glory. Setting up the workspace Set your $GOPATH to point to your root folder /goapp Set your $GOBIN to point to $GOPATH/bin Create 3 folders in $GOPATH (src, pkg, bin) Create the main app folder with the convention of $GOPATH/src/github.com/{username}/goapp/main.go Working with JSON […]

Categories
Go

Fetching venues from Foursquare using Go

package main import ( “fmt” “github.com/codegangsta/negroni” “github.com/gorilla/mux” “encoding/json” “net/http” “github.com/elbuo8/4square-venues” ) func main() { mux := mux.NewRouter() mux.HandleFunc(“/”, IndexHandler).Methods(“GET”) mux.HandleFunc(“/venues/{query}”, FoursquareHandler).Methods(“GET”) n := negroni.Classic() n.UseHandler(mux) n.Run(“:3000”) } func IndexHandler(w http.ResponseWriter, r *http.Request){ p := “Page” fmt.Fprintf(w, “Home %s\n”, p) } func FoursquareHandler(w http.ResponseWriter, r *http.Request){ vars := mux.Vars(r) category := vars[“query”] fs := fsvenues.NewFSVenuesClient(“FOURSQUARE_ID”, “FOURSQUARE_SECRET”) […]