Skip to content

reflect: wrong struct field names for embedded byte, rune #17766

@rsc

Description

@rsc

Inspired by discussion on #17746, https://play.golang.org/p/X3OBse1q8_

package main

import "fmt"

type T struct {
	byte
	uint8
	int
	int32
	rune
}

func main() {
	t := T{byte: 1, uint8: 2, int: 3, int32: 4, rune: 5}
	println(t.byte, t.uint8, t.int, t.int32, t.rune)
	fmt.Printf("%#v\n", t)
}

Prints:

1 2 3 4 5
main.T{uint8:0x1, uint8:0x2, int:3, int32:4, int32:5}

The second print should be fixed. It's always been this way, though, so it can and should wait until Go 1.9.

/cc @mdempsky @griesemer @alandonovan @mpvl

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions