<commit_before>package config

import (
	"fmt"
	"reflect"
	"runtime"

	host "github.com/libp2p/go-libp2p-host"
	tptu "github.com/libp2p/go-libp2p-transport-upgrader"
)

var errorType = reflect.TypeOf((*error)(nil)).Elem()

// checks if a function returns either the specified type or the specified type
// and an error.
func checkReturnType(fnType, tptType reflect.Type) error {
	switch fnType.NumOut() {
	case 2:
		if fnType.Out(1) != errorType {
			return fmt.Errorf("expected (optional) second return value from transport constructor to be an error")
		}

		fallthrough
	case 1:
		if !fnType.Out(0).Implements(tptType) {
			return fmt.Errorf("expected first return value from transport constructor to be a transport")
		}
	default:<commit_msg>improve error message in libp2p reflection-based transport option<commit_after>package config

import (
	"fmt"
	"reflect"
	"runtime"

	host "github.com/libp2p/go-libp2p-host"
	tptu "github.com/libp2p/go-libp2p-transport-upgrader"
)

var errorType = reflect.TypeOf((*error)(nil)).Elem()

// checks if a function returns either the specified type or the specified type
// and an error.
func checkReturnType(fnType, tptType reflect.Type) error {
	switch fnType.NumOut() {
	case 2:
		if fnType.Out(1) != errorType {
			return fmt.Errorf("expected (optional) second return value from transport constructor to be an error")
		}

		fallthrough
	case 1:
		if !fnType.Out(0).Implements(tptType) {
			return fmt.Errorf("transport constructor returns %s which doesn't implement %s", fnType.Out(0), tptType)
		}
	default:
{'fraction_non_alphanumeric': 0.11254019292604502, 'fraction_numerical': 0.01157556270096463, 'mean_word_length': 4.459649122807018, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7217596', 'n_tokens_mistral': 547, 'n_tokens_neox': 517, 'n_words': 149}