Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
458 B

  1. package main
  2. import (
  3. "fmt"
  4. "math"
  5. )
  6. func convert() string {
  7. var i8 int8 = math.MaxInt8
  8. i := 128
  9. f64 := 3.14
  10. m := fmt.Sprintf("int8 = %v -> int64 = %v\n", i8, int64(i8))
  11. m += fmt.Sprintf("int = %v -> int8 = %v\n", i, int8(i))
  12. m += fmt.Sprintf("int8 = %v -> float32 = %v\n", i8, float64(i8))
  13. m += fmt.Sprintf("float64 = %v -> int = %v\n", f64, int(f64))
  14. return m
  15. }
  16. func main() {
  17. fmt.Print(convert())
  18. }