mirror of
https://github.com/fullstorydev/grpcurl.git
synced 2026-05-22 19:51:44 +03:00
refactor: use slices.Contains to simplify code (#536)
Signed-off-by: vastonus <vastonus@outlook.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -450,11 +451,9 @@ func makeTemplate(md *desc.MessageDescriptor, path []*desc.MessageDescriptor) pr
|
|||||||
dm := dynamic.NewMessage(md)
|
dm := dynamic.NewMessage(md)
|
||||||
|
|
||||||
// if the message is a recursive structure, we don't want to blow the stack
|
// if the message is a recursive structure, we don't want to blow the stack
|
||||||
for _, seen := range path {
|
if slices.Contains(path, md) {
|
||||||
if seen == md {
|
// already visited this type; avoid infinite recursion
|
||||||
// already visited this type; avoid infinite recursion
|
return dm
|
||||||
return dm
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
path = append(path, dm.GetMessageDescriptor())
|
path = append(path, dm.GetMessageDescriptor())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user