From 703a9baf5c210ac3955ddaa9df1efcdb2786ab1d Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 6 Jun 2017 22:17:50 +0000 Subject: [PATCH] builtin: use type aliases for rune and byte As motivated by https://golang.org/design/18130-type-alias which says: https://github.com/golang/proposal/blob/master/design/18130-type-alias.md#relationship-to-byte-and-rune > The language specification already defines byte as an alias for > uint8 and similarly rune as an alias for int32, using the word alias > as an informal term. It is a goal that the new type declaration > semantics not introduce a different meaning for alias. That is, it > should be possible to describe the existing meanings of byte and > uint8 by saying that they behave as if predefined by: > > type byte = uint8 > type rune = int32 So, do that. Seems to work. Updates #18130 Change-Id: I0740bab3f8fb23e946f3542fdbe819007a99465a Reviewed-on: https://go-review.googlesource.com/45017 Reviewed-by: Ian Lance Taylor Reviewed-by: Robert Griesemer Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/builtin/builtin.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builtin/builtin.go b/src/builtin/builtin.go index dc166837ae..1c7c041d68 100644 --- a/src/builtin/builtin.go +++ b/src/builtin/builtin.go @@ -85,11 +85,11 @@ type uintptr uintptr // byte is an alias for uint8 and is equivalent to uint8 in all ways. It is // used, by convention, to distinguish byte values from 8-bit unsigned // integer values. -type byte byte +type byte = uint8 // rune is an alias for int32 and is equivalent to int32 in all ways. It is // used, by convention, to distinguish character values from integer values. -type rune rune +type rune = int32 // iota is a predeclared identifier representing the untyped integer ordinal // number of the current const specification in a (usually parenthesized) -- 2.50.0