3 // QuotedString is a string that may have extra quotes around the value. The
4 // quotes are stripped from the value.
5 type QuotedString struct {
9 // Set sets a new value
10 func (s *QuotedString) Set(val string) error {
11 *s.value = trimQuotes(val)
15 // Type returns the type of the value
16 func (s *QuotedString) Type() string {
20 func (s *QuotedString) String() string {
24 func trimQuotes(value string) string {
25 lastIndex := len(value) - 1
26 for _, char := range []byte{'\'', '"'} {
27 if value[0] == char && value[lastIndex] == char {
28 return value[1:lastIndex]
34 // NewQuotedString returns a new quoted string option
35 func NewQuotedString(value *string) *QuotedString {
36 return &QuotedString{value: value}