package
0.5.1
Repository: https://github.com/awalterschulze/goderive.git
Documentation: pkg.go.dev

# README

The deriveContains function returns whether an element exists in a list.

Given the following input:

package contains

import (
	"fmt"
)

type boat struct {
	id int
}

func appendUnique(olds, news []boat) ([]boat, error) {
	for i := range news {
		if deriveContains(olds, news[i]) {
			return nil, fmt.Errorf("duplicate found")
		}
	}
	return append(olds, news...), nil
}

goderive will generate the following code:

// Code generated by goderive DO NOT EDIT.

package contains

// deriveContains returns whether the item is contained in the list.
//
// Deprecated: In favour of generics.
func deriveContains(list []boat, item boat) bool {
	for _, v := range list {
		if v == item {
			return true
		}
	}
	return false
}