key_value.go 648 B

12345678910111213141516171819202122232425262728293031323334
  1. package client
  2. import "strings"
  3. type KeyValue struct {
  4. columns []string
  5. values []string
  6. }
  7. func NewKeyValue() *KeyValue {
  8. return &KeyValue{
  9. columns: make([]string, 0),
  10. values: make([]string, 0),
  11. }
  12. }
  13. func (keyValue *KeyValue) Add(column string, value string) *KeyValue {
  14. if strings.Trim(column, " ") == "" || strings.Trim(value, " ") == "" {
  15. return keyValue
  16. }
  17. keyValue.columns = append(keyValue.columns, column)
  18. keyValue.values = append(keyValue.values, value)
  19. return keyValue
  20. }
  21. func (keyValue *KeyValue) Columns() []string {
  22. return keyValue.columns
  23. }
  24. func (keyValue *KeyValue) Values() []string {
  25. return keyValue.values
  26. }