Commit 19525e62 authored by Steven Allen's avatar Steven Allen

fix go vet errors

fixes #42
parent 4e1cdfb5
......@@ -76,7 +76,9 @@ func (x *executor) Execute(req *Request, re ResponseEmitter, env Environment) (e
if err != nil {
return err
}
req.Context, _ = context.WithTimeout(req.Context, timeout)
var cancel func()
req.Context, cancel = context.WithTimeout(req.Context, timeout)
defer cancel()
}
if cmd.PreRun != nil {
......
......@@ -38,7 +38,7 @@ func TestAPIPrefixHandler(t *testing.T) {
assert := func(name string, exp, real interface{}) {
if exp != real {
t.Error("expected %s to be %q, but got %q", name, exp, real)
t.Errorf("expected %s to be %q, but got %q", name, exp, real)
} else {
t.Log("ok:", name)
}
......
......@@ -175,12 +175,14 @@ func (c *client) Send(req *cmds.Request) (cmds.Response, error) {
httpRes, err := c.httpClient.Do(httpReq)
if err != nil {
reqCancel()
return nil, err
}
// using the overridden JSON encoding in request
res, err := parseResponse(httpRes, req)
if err != nil {
reqCancel()
return nil, err
}
......
......@@ -35,7 +35,7 @@ func NewServerConfig() *ServerConfig {
return cfg
}
func (cfg ServerConfig) AllowedOrigins() []string {
func (cfg *ServerConfig) AllowedOrigins() []string {
cfg.corsOptsRWMutex.RLock()
defer cfg.corsOptsRWMutex.RUnlock()
return cfg.corsOpts.AllowedOrigins
......@@ -55,7 +55,7 @@ func (cfg *ServerConfig) AppendAllowedOrigins(origins ...string) {
cfg.corsOpts.AllowedOrigins = append(cfg.corsOpts.AllowedOrigins, origins...)
}
func (cfg ServerConfig) AllowedMethods() []string {
func (cfg *ServerConfig) AllowedMethods() []string {
cfg.corsOptsRWMutex.RLock()
defer cfg.corsOptsRWMutex.RUnlock()
return []string(cfg.corsOpts.AllowedMethods)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment