Skip to content

Commit 703a9ba

Browse files
committed
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 <iant@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent a027466 commit 703a9ba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/builtin/builtin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ type uintptr uintptr
8585
// byte is an alias for uint8 and is equivalent to uint8 in all ways. It is
8686
// used, by convention, to distinguish byte values from 8-bit unsigned
8787
// integer values.
88-
type byte byte
88+
type byte = uint8
8989

9090
// rune is an alias for int32 and is equivalent to int32 in all ways. It is
9191
// used, by convention, to distinguish character values from integer values.
92-
type rune rune
92+
type rune = int32
9393

9494
// iota is a predeclared identifier representing the untyped integer ordinal
9595
// number of the current const specification in a (usually parenthesized)

0 commit comments

Comments
 (0)