Skip to content

Commit

Permalink
Remove support for Go 1.6 (digitalocean#166)
Browse files Browse the repository at this point in the history
* Move DoRequest* to godo package with stdlib context

* Use stdlib context package in place of godo context.

* Remove Go 1.6 from TravisCI configuration.

* Use stdlib context in util and tests instead of godo context.

* Add in Go 1.8, 1.9, and 1.10 to TravisCI configuration.

* Put 1.10 in quotes.
  • Loading branch information
iheanyi authored and viola committed May 8, 2018
1 parent 7a32b5c commit e6249e5
Show file tree
Hide file tree
Showing 29 changed files with 46 additions and 230 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: go

go:
- 1.6.3
- 1.7
- 1.8
- 1.9
- "1.10"
- tip
3 changes: 1 addition & 2 deletions account.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package godo

import (
"context"
"net/http"

"github.com/digitalocean/godo/context"
)

// AccountService is an interface for interfacing with the Account
Expand Down
3 changes: 1 addition & 2 deletions action.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package godo

import (
"context"
"fmt"
"net/http"

"github.com/digitalocean/godo/context"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions certificates.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package godo

import (
"context"
"net/http"
"path"

"github.com/digitalocean/godo/context"
)

const certificatesBasePath = "/v2/certificates"
Expand Down
98 changes: 0 additions & 98 deletions context/context.go

This file was deleted.

39 changes: 0 additions & 39 deletions context/context_go17.go

This file was deleted.

41 changes: 0 additions & 41 deletions context/context_pre_go17.go

This file was deleted.

3 changes: 1 addition & 2 deletions domains.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package godo

import (
"context"
"fmt"
"net/http"

"github.com/digitalocean/godo/context"
)

const domainsBasePath = "v2/domains"
Expand Down
3 changes: 1 addition & 2 deletions droplet_actions.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package godo

import (
"context"
"fmt"
"net/http"
"net/url"

"github.com/digitalocean/godo/context"
)

// ActionRequest reprents DigitalOcean Action Request
Expand Down
3 changes: 1 addition & 2 deletions droplets.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package godo

import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"

"github.com/digitalocean/godo/context"
)

const dropletBasePath = "v2/droplets"
Expand Down
3 changes: 1 addition & 2 deletions firewalls.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package godo

import (
"context"
"net/http"
"path"
"strconv"

"github.com/digitalocean/godo/context"
)

const firewallsBasePath = "/v2/firewalls"
Expand Down
3 changes: 1 addition & 2 deletions floating_ips.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package godo

import (
"context"
"fmt"
"net/http"

"github.com/digitalocean/godo/context"
)

const floatingBasePath = "v2/floating_ips"
Expand Down
3 changes: 1 addition & 2 deletions floating_ips_actions.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package godo

import (
"context"
"fmt"
"net/http"

"github.com/digitalocean/godo/context"
)

// FloatingIPActionsService is an interface for interfacing with the
Expand Down
20 changes: 17 additions & 3 deletions godo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package godo

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
Expand All @@ -14,8 +15,6 @@ import (

"github.com/google/go-querystring/query"
headerLink "github.com/tent/http-link-go"

"github.com/digitalocean/godo/context"
)

const (
Expand Down Expand Up @@ -296,7 +295,7 @@ func (r *Response) populateRate() {
// pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface,
// the raw response will be written to v, without attempting to decode it.
func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error) {
resp, err := context.DoRequestWithClient(ctx, c.client, req)
resp, err := DoRequestWithClient(ctx, c.client, req)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -334,6 +333,21 @@ func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Res

return response, err
}

// DoRequest submits an HTTP request.
func DoRequest(ctx context.Context, req *http.Request) (*http.Response, error) {
return DoRequestWithClient(ctx, http.DefaultClient, req)
}

// DoRequestWithClient submits an HTTP request using the specified client.
func DoRequestWithClient(
ctx context.Context,
client *http.Client,
req *http.Request) (*http.Response, error) {
req = req.WithContext(ctx)
return client.Do(req)
}

func (r *ErrorResponse) Error() string {
if r.RequestID != "" {
return fmt.Sprintf("%v %v: %d (request %q) %v",
Expand Down
3 changes: 1 addition & 2 deletions godo_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package godo

import (
"context"
"fmt"
"io/ioutil"
"net/http"
Expand All @@ -11,8 +12,6 @@ import (
"strings"
"testing"
"time"

"github.com/digitalocean/godo/context"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions image_actions.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package godo

import (
"context"
"fmt"
"net/http"

"github.com/digitalocean/godo/context"
)

// ImageActionsService is an interface for interfacing with the image actions
Expand Down
3 changes: 1 addition & 2 deletions images.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package godo

import (
"context"
"fmt"
"net/http"

"github.com/digitalocean/godo/context"
)

const imageBasePath = "v2/images"
Expand Down
Loading

0 comments on commit e6249e5

Please sign in to comment.