diff options
| author | Mitch Connors <[email protected]> | 2019-09-17 09:43:30 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-09-17 09:43:30 -0700 |
| commit | 7b22f689a41a1727c42eb02aaa1492d26402c592 (patch) | |
| tree | ca8ae6c13649d5a76f09cd8c7a4ca5011c870c85 /string_array.go | |
| parent | 972238283c0625cf3e881de7699ba8f2524c340a (diff) | |
| parent | 8e39cc44d9bd06ee2d9ef3109c93809072d5e551 (diff) | |
Merge pull request #216 from therealmitchconnors/elegant
Implement SliceValue for better list semantics
Diffstat (limited to 'string_array.go')
| -rw-r--r-- | string_array.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/string_array.go b/string_array.go index fa7bc60..4894af8 100644 --- a/string_array.go +++ b/string_array.go @@ -23,6 +23,32 @@ func (s *stringArrayValue) Set(val string) error { return nil } +func (s *stringArrayValue) Append(val string) error { + *s.value = append(*s.value, val) + return nil +} + +func (s *stringArrayValue) Replace(val []string) error { + out := make([]string, len(val)) + for i, d := range val { + var err error + out[i] = d + if err != nil { + return err + } + } + *s.value = out + return nil +} + +func (s *stringArrayValue) GetSlice() []string { + out := make([]string, len(*s.value)) + for i, d := range *s.value { + out[i] = d + } + return out +} + func (s *stringArrayValue) Type() string { return "stringArray" } |
