Use a pointer config instead

This commit is contained in:
Seth Vargo
2015-04-23 11:13:52 -04:00
parent c7843ed09b
commit d19aa41b21
2 changed files with 5 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ import (
// testHTTPServer creates a test HTTP server that handles requests until // testHTTPServer creates a test HTTP server that handles requests until
// the listener returned is closed. // the listener returned is closed.
func testHTTPServer( func testHTTPServer(
t *testing.T, handler http.Handler) (Config, net.Listener) { t *testing.T, handler http.Handler) (*Config, net.Listener) {
ln, err := net.Listen("tcp", "127.0.0.1:0") ln, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil { if err != nil {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)

View File

@@ -33,8 +33,8 @@ type Config struct {
// DefaultConfig returns a default configuration for the client. It is // DefaultConfig returns a default configuration for the client. It is
// safe to modify the return value of this function. // safe to modify the return value of this function.
func DefaultConfig() Config { func DefaultConfig() *Config {
config := Config{ config := &Config{
Address: "https://127.0.0.1:8200", Address: "https://127.0.0.1:8200",
HttpClient: &http.Client{}, HttpClient: &http.Client{},
} }
@@ -46,11 +46,11 @@ func DefaultConfig() Config {
// NewClient. // NewClient.
type Client struct { type Client struct {
addr *url.URL addr *url.URL
config Config config *Config
} }
// NewClient returns a new client for the given configuration. // NewClient returns a new client for the given configuration.
func NewClient(c Config) (*Client, error) { func NewClient(c *Config) (*Client, error) {
u, err := url.Parse(c.Address) u, err := url.Parse(c.Address)
if err != nil { if err != nil {
return nil, err return nil, err