Mushi

convercoes.go

Apr 23rd, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.49 KB | None | 0 0
  1. // convercoes convercoes.go
  2. package main
  3.  
  4. import (
  5.     "fmt"
  6.     "strconv"
  7. )
  8.  
  9. func main() {
  10.     x := 2.4
  11.     y := 2
  12.     fmt.Println(x / float64(y))
  13.  
  14.     nota := 6.9
  15.     notaFinal := int(nota)
  16.     fmt.Println(notaFinal)
  17.  
  18.     // cuidado...
  19.     fmt.Println("Teste " + string(97))
  20.  
  21.     // int para string
  22.     fmt.Println("Teste " + strconv.Itoa(123))
  23.  
  24.     // string para int
  25.     num, _ := strconv.Atoi("123")
  26.     fmt.Println(num - 122)
  27.  
  28.     b, _ := strconv.ParseBool("true")
  29.     if b {
  30.         fmt.Println("Verdadeiro")
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment