├── .gitignore ├── README.md └── main.go /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pos-web-go 2 | Conteúdo da disciplina Desenvolvimento Web Com Go 3 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | //uma função pode retornar mais de um valor 7 | //a construção := cria a variável caso ela não exista, já definindo seu tipo 8 | ok, err := say("Hello World") 9 | if err != nil { 10 | panic(err.Error()) 11 | } 12 | switch ok { 13 | case true: 14 | fmt.Println("Deu certo") 15 | default: 16 | fmt.Println("deu errado") 17 | } 18 | 19 | } 20 | 21 | //as funções devem declarar o tipo de cada variável que recebe ou que retorna 22 | func say(what string) (bool, error) { 23 | if what == "" { 24 | return false, fmt.Errorf("Empty string") 25 | } 26 | fmt.Println(what) 27 | return true, nil 28 | } 29 | --------------------------------------------------------------------------------