Skip to content

reflect: the docs of StructOf should mention embedding types with too many method will panic. #25402

Closed
@dotaheor

Description

@dotaheor

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10.2 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

package main

import "fmt"
import "reflect"
import "time"

func main() {
	type T = struct {
		time.Time
	}
	fmt.Println(reflect.TypeOf(T{})) // struct { x int }
	
	var n time.Time
	tn := reflect.TypeOf(n)
	// panic: reflect.StructOf: too many methods
	tt := reflect.StructOf([]reflect.StructField{
		{Name: "Time", Type: tn, Anonymous: true},
	})
	fmt.Println(tt)
}

What did you expect to see?

not panic, or document it.

What did you see instead?

panic

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions