func (i *Item) SetID(ctx context.Context) error {
	span, _ := ot.StartSpanFromContext(ctx, "SetID")
	defer span.Finish()
	id, err := util.StringToHashID(strings.ToLower(i.Name))
	if err != nil {
		return err
	}
	i.ID = id
	return nil
}
SetID creates a HashID from an already set Name field.
package item
import (
	"context"
	"encoding/json"
	"fmt"
	"strconv"
	"strings"
	"github.com/obitech/micro-obs/util"
	ot "github.com/opentracing/opentracing-go"
	"github.com/pkg/errors"
)
type Item struct {
	Name string `json:"name"`
	ID   string `json:"id"`
	Desc string `json:"desc"`
	Qty  int    `json:"qty"`
}
func (i *Item) String() string {
	return fmt.Sprintf("Name:%s ID:%s Desc:%s Qty:%d", i.Name, i.ID, i.Desc, i.Qty)
}
func NewItem(name, desc string, qty int) (*Item, error) {
	id, err := util.StringToHashID(strings.ToLower(name))
	if err != nil {
		return nil, err
	}
	return &Item{
		ID:   id,
		Name: name,
		Desc: desc,
		Qty:  qty,
	}, nil
}
func DataToItems(data []byte) ([]*Item, error) {
	items := []*Item{}
	err := json.Unmarshal(data, &items)
	if err != nil {
		return nil, errors.Wrapf(err, "unable to marshal %s", data)
	}
	if len(items) == 0 {
		return nil, errors.New("data can't be empty")
	}
	for _, i := range items {
		if err = i.SetID(context.Background()); err != nil {
			return nil, errors.Wrapf(err, "unable to set HashID of %s", i.Name)
		}
	}
	return items, nil
}