diff --git a/context.go b/context.go index 5e629fc..8529f8c 100644 --- a/context.go +++ b/context.go @@ -1,9 +1,8 @@ package maps import ( + "context" "net/http" - - "golang.org/x/net/context" ) type contextKey int diff --git a/directions.go b/directions.go index 1c04a3e..3c8a972 100644 --- a/directions.go +++ b/directions.go @@ -1,12 +1,11 @@ package maps import ( + "context" "fmt" "net/url" "strings" "time" - - "golang.org/x/net/context" ) const ( diff --git a/distance.go b/distance.go index 57aec55..45a0714 100644 --- a/distance.go +++ b/distance.go @@ -1,11 +1,10 @@ package maps import ( + "context" "fmt" "net/url" "time" - - "golang.org/x/net/context" ) // DistanceMatrix requests travel distance and time for a matrix of origins and destinations. diff --git a/elevation.go b/elevation.go index 50489d8..83c25b1 100644 --- a/elevation.go +++ b/elevation.go @@ -1,10 +1,9 @@ package maps import ( + "context" "fmt" "net/url" - - "golang.org/x/net/context" ) // Elevation requests elevation data for a series of locations. diff --git a/geocode.go b/geocode.go index a1d5e59..34bce74 100644 --- a/geocode.go +++ b/geocode.go @@ -1,11 +1,10 @@ package maps import ( + "context" "fmt" "net/url" "strings" - - "golang.org/x/net/context" ) const ( diff --git a/maps.go b/maps.go index e787466..b020447 100644 --- a/maps.go +++ b/maps.go @@ -1,6 +1,7 @@ package maps import ( + "context" "crypto/hmac" "crypto/sha1" "encoding/base64" @@ -8,8 +9,6 @@ import ( "fmt" "net/http" "strings" - - "golang.org/x/net/context" ) const ( diff --git a/maps_test.go b/maps_test.go index ee44709..6682295 100644 --- a/maps_test.go +++ b/maps_test.go @@ -1,22 +1,25 @@ package maps import ( - "flag" "image/color" + "log" "net/http" + "os" "testing" "time" ) var ( - apiKey = flag.String("apiKey", "", "Google Maps API key") - - ctx = NewContext("", &http.Client{}) - wctx = NewWorkContext("clientID", "privKey", &http.Client{}) + apiKey string + ctx = NewContext("", &http.Client{}) + wctx = NewWorkContext("clientID", "privKey", &http.Client{}) ) func init() { - flag.Parse() + apiKey = os.Getenv("API_KEY") + if apiKey == "" { + log.Fatal("API_KEY must be provided") + } } func TestDirections(t *testing.T) { @@ -200,7 +203,7 @@ func TestSnapToRoads(t *testing.T) { t.Errorf("unexpected error, got %v, want %v", err, ErrNoAPIKey) } - keyCtx := NewContext(*apiKey, &http.Client{}) + keyCtx := NewContext(apiKey, &http.Client{}) r, err := SnapToRoads(keyCtx, path, opts) if err != nil { t.Errorf("unexpected error: %v", err) diff --git a/roads.go b/roads.go index 0f163f8..a6846e9 100644 --- a/roads.go +++ b/roads.go @@ -1,10 +1,9 @@ package maps import ( + "context" "errors" "net/url" - - "code.google.com/p/go.net/context" ) const roadsAPIBaseURL = "https://roads.googleapis.com/v1/" diff --git a/static.go b/static.go index 2483978..19f08ba 100644 --- a/static.go +++ b/static.go @@ -1,14 +1,13 @@ package maps import ( + "context" "fmt" "image/color" "io" "net/http" "net/url" "strings" - - "golang.org/x/net/context" ) const ( diff --git a/streetview.go b/streetview.go index 7673cb6..f655890 100644 --- a/streetview.go +++ b/streetview.go @@ -1,12 +1,11 @@ package maps import ( + "context" "fmt" "io" "net/http" "net/url" - - "golang.org/x/net/context" ) // StreetView requests a static StreetView image of the requested size. diff --git a/timezone.go b/timezone.go index f698080..cb74a55 100644 --- a/timezone.go +++ b/timezone.go @@ -1,11 +1,10 @@ package maps import ( + "context" "fmt" "net/url" "time" - - "golang.org/x/net/context" ) // TimeZone requests time zone information about a location.