Last active
August 29, 2015 14:23
-
-
Save russmack/e1eaaaae600543183112 to your computer and use it in GitHub Desktop.
A quick and simple way to convert int to uint8.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
var x int = 217 | |
var y uint8 | |
for i := 0; i < x; i++ { | |
if i == 255 { | |
// Handle overflow as desired. | |
fmt.Println("Too big.") | |
break | |
} | |
y++ | |
} | |
fmt.Println(y) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment