Skip to content

Instantly share code, notes, and snippets.

@odeke-em
Created June 6, 2017 07:14
Show Gist options
  • Save odeke-em/8f056c7e1ba2f34d03df348d8fe874be to your computer and use it in GitHub Desktop.
Save odeke-em/8f056c7e1ba2f34d03df348d8fe874be to your computer and use it in GitHub Desktop.
Requesting an Uber in Go
package main
import (
"fmt"
"log"
"github.com/orijtech/uber/v1"
)
func main() {
client, err := uber.NewClientFromOAuth2File(".uber/credentials.json")
if err != nil {
log.Fatal(err)
}
ride, err := client.RequestRide(&uber.RideRequest{
StartLatitude: 37.7752315,
StartLongitude: -122.418075,
EndLatitude: 37.7752415,
EndLongitude: -122.518075,
PromptOnFare: func(fare *uber.UpfrontFare) error {
if fare.Fare.Value >= 6.00 {
return fmt.Errorf("exercise can't hurt instead of $6.00 for that walk!")
}
return nil
},
})
if err != nil {
log.Fatalf("ride request err: %v", err)
}
fmt.Printf("Your ride information: %+v\n", ride)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment