Skip to content

Commit

Permalink
Unmarshall TagSet from a list of tags fix #768
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Feb 1, 2019
1 parent 8af8dc3 commit 884ac1e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
package lib

import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"net"
"reflect"
"strings"

"github.com/loadimpact/k6/lib/types"
"github.com/loadimpact/k6/stats"
Expand Down Expand Up @@ -73,6 +75,16 @@ func (t *TagSet) UnmarshalJSON(data []byte) error {
return nil
}

// UnmarshalText converts the tag list to tagset.
func (t *TagSet) UnmarshalText(data []byte) error {
var list = bytes.Split(data, []byte(","))
*t = make(map[string]bool, len(list))
for _, key := range list {
(*t)[strings.TrimSpace(string(key))] = true
}
return nil
}

// Describes a TLS version. Serialised to/from JSON as a string, eg. "tls1.2".
type TLSVersion int

Expand Down

0 comments on commit 884ac1e

Please sign in to comment.