From 4f9a6ee99ad3ccc8b3b0112a305c0c5ee11cdfef Mon Sep 17 00:00:00 2001 From: Bojan Date: Fri, 23 Oct 2020 11:16:45 -0300 Subject: [PATCH] fix: in NewConfig() set host and call only if not set via config options. fixes #237 --- runner/options.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/runner/options.go b/runner/options.go index 45706b40..99af85ee 100644 --- a/runner/options.go +++ b/runner/options.go @@ -568,13 +568,9 @@ func WithTemplateFuncs(funcMap template.FuncMap) Option { // NewConfig creates a new RunConfig from the options passed func NewConfig(call, host string, options ...Option) (*RunConfig, error) { - call = strings.TrimSpace(call) - host = strings.TrimSpace(host) // init with defaults c := &RunConfig{ - call: call, - host: host, n: 200, c: 50, nConns: 1, @@ -593,6 +589,16 @@ func NewConfig(call, host string, options ...Option) (*RunConfig, error) { } } + // host and call may have been applied via options + // only override if not present + if c.host == "" { + c.host = strings.TrimSpace(host) + } + + if c.call == "" { + c.call = strings.TrimSpace(call) + } + // fix up durations if c.z > 0 { c.n = math.MaxInt32