简体   繁体   中英

Is explicit primitive type casting supported?

Is there a way to "down cast" a custom primitive type back to its original primitive? For example casting type AwesomeType byte to byte for use by a Writer ?

You can simply cast with the type you want:

var a AwesomeType; b := byte(a)

Example: http://play.golang.org/p/-Sj7zmz6zt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM