as i m on it, please consider, what below code might be with little imagination,
// Create a new Tomate func (t Controller) Create(postColor *string) (jsonResBody *Tomate, err error) { mustNot(postColor, nil) or return ... &UserInputError{errors.New("Missing color parameter")} color, _ := mustNot(strings.TrimSpace(*postColor), "") or return ... &UserInputError{errors.New("color must not be empty")} t.backend.Transact(func(backend *Tomates) { must(backend.Filter(FilterTomates.ByColor(color)).Empty(), true) or { err = &UserInputError{errors.New("color must be unique")} return } jsonResBody = &Tomate{ID: fmt.Sprintf("%v", backend.Len()), Color: color} backend.Push(jsonResBody) }) return jsonResBody, err } >From that go compatible code, // Create a new Tomate func (t Controller) Create(postColor *string) (jsonResBody *Tomate, err error) { if postColor == nil { return nil, &UserInputError{errors.New("Missing color parameter")} } color := strings.TrimSpace(*postColor) if color == "" { return nil, &UserInputError{errors.New("color must not be empty")} } t.backend.Transact(func(backend *Tomates) { exist := backend.Filter(FilterTomates.ByColor(color)).Len() if exist > 0 { err = &UserInputError{errors.New("color must be unique")} return } jsonResBody = &Tomate{ID: fmt.Sprintf("%v", backend.Len()), Color: color} backend.Push(jsonResBody) }) return jsonResBody, err } On Wednesday, May 24, 2017 at 9:52:27 AM UTC+2, mhh...@gmail.com wrote: > > see the title, only for what s needed > Slice/Splice/Each/Map/First/Last/Reverse/Sort ect ect not len, for reason. > so interface system serves the userland by its definition of struct, and > the basic slice type provided by the language is fully operational, without > breaking, btw. i don t go further in evaluation, i leave that to the > reader, just trying to work decently. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.