Skip to content

proposal: x/tools/cmd/eg: support for generics #68070

Open
@janisz

Description

@janisz

Proposal Details

It will be great is eg can support generics in a way it can handle e.g. slices of different types.

Example: Replacing a method that takes slices of elements that implements given interface.

package template

import (
        "github.com/golang/protobuf/proto"
        "github.com/stackrox/rox/pkg/protoassert"
        "github.com/stretchr/testify/assert"
        "testing"
)

func before[T proto.Message](t *testing.T, a, b []T) bool {
        return assert.Equal(t, a, b)
}

func after[T proto.Message](t *testing.T, a, b []T) bool {
        return protoassert.SlicesEqual(t, a, b)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions