Пример #1
0
func fooSetTo(ds datastore.Interface) func(interface{}, ...interface{}) string {
	return func(id interface{}, values ...interface{}) string {
		f := &Foo{ID: toInt64(id)}
		if len(values) == 0 {
			return ShouldBeNil(ds.Delete(ds.KeyForObj(f)))
		}
		if data, ok := values[0].([]byte); ok {
			f.ValueNI = data
		} else {
			f.Value = toIntSlice(values)
		}
		return ShouldBeNil(ds.Put(f))
	}
}