Skip to content

Instantly share code, notes, and snippets.

@russmack
Last active August 29, 2015 14:23
Show Gist options
  • Save russmack/e1eaaaae600543183112 to your computer and use it in GitHub Desktop.
Save russmack/e1eaaaae600543183112 to your computer and use it in GitHub Desktop.
A quick and simple way to convert int to uint8.
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