// Copyright 2024 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package cryptotestimport ()// NoExtraMethods checks that the concrete type of *ms has no exported methods// beyond the methods of the interface type of *ms, and any others specified in// the allowed list.//// These methods are accessible through interface upgrades, so they end up part// of the API even if undocumented per Hyrum's Law.//// ms must be a pointer to a non-nil interface.func ( *testing.T, interface{}, ...string) { .Helper() , := extraMethods()if != nil { .Fatal() }for , := range {ifslices.Contains(, ) {continue } .Errorf("unexpected method %q", ) }}func extraMethods( interface{}) ([]string, error) { := reflect.ValueOf()if .Kind() != reflect.Ptr || .Elem().Kind() != reflect.Interface || .Elem().IsNil() {returnnil, fmt.Errorf("argument must be a pointer to a non-nil interface") } := .Elem().Type() := .Elem().Elem().Type() := make(map[string]bool)for := range .NumMethod() { [.Method().Name] = true }var []stringfor := range .NumMethod() { := .Method()if !.IsExported() {continue }if ![.Name] { = append(, .Name) } }return , nil}
The pages are generated with Goldsv0.7.7-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.