Started translation to Brazilian Portuguese PT-BR

This commit is contained in:
Lucassauro 2023-03-05 01:31:46 -03:00
parent 38eb2236ca
commit 2ffb8a3a49
No known key found for this signature in database
GPG Key ID: 92473917252F6589
128 changed files with 1046 additions and 998 deletions

View File

@ -74,7 +74,7 @@ Environment Variables
HTTP Client HTTP Client
HTTP Server HTTP Server
Context Context
Spawning Processes Spawning Processes (Invocando processos)
Exec'ing Processes Executing Processes
Signals Signals
Exit Exit

View File

@ -1,7 +1,7 @@
// In Go, an _array_ is a numbered sequence of elements of a // Em Go, um _array_ é uma sequência numerada de elementos
// specific length. In typical Go code, [slices](slices) are // de um tamanho específico. Tipicamente, [slices](slices) são
// much more common; arrays are useful in some special // muito mais comuns; arrays são úteis em alguns cenários
// scenarios. // específicos.
package main package main
@ -9,36 +9,35 @@ import "fmt"
func main() { func main() {
// Here we create an array `a` that will hold exactly // Aqui é criado um array `a` com capacidade de armazenar
// 5 `int`s. The type of elements and length are both // exatamente 5 inteiros. O tipo de elemento que ele irá
// part of the array's type. By default an array is // armazenar (int) e seu tamanho (5) são partes do tipo do array.
// zero-valued, which for `int`s means `0`s. // Neste caso, o array tem valores padrão zero.
var a [5]int var a [5]int
fmt.Println("emp:", a) fmt.Println("vazio:", a)
// We can set a value at an index using the // É possível alterar o valor de um índice do array
// `array[index] = value` syntax, and get a value with // utilizando a sintaxe `array[índice] = valor`,
// `array[index]`. // bem como selecionar um valor com `array[índice]`.
a[4] = 100 a[4] = 100
fmt.Println("set:", a) fmt.Println("índice 4 alterado:", a)
fmt.Println("get:", a[4]) fmt.Println("valor índice 4:", a[4])
// The builtin `len` returns the length of an array. // A função nativa `len` retorna o tamanho de um array.
fmt.Println("len:", len(a)) fmt.Println("len:", len(a))
// Use this syntax to declare and initialize an array // Para declarar a inicializar um array em uma linha,
// in one line. // é possível usar esta sintaxe.
b := [5]int{1, 2, 3, 4, 5} b := [5]int{1, 2, 3, 4, 5}
fmt.Println("dcl:", b) fmt.Println("array inicializado:", b)
// Array types are one-dimensional, but you can // Arrays, via de regra são unidimensionais, mas é possível
// compose types to build multi-dimensional data // compor tipos para formar arrays multidimensionais.
// structures.
var twoD [2][3]int var twoD [2][3]int
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
for j := 0; j < 3; j++ { for j := 0; j < 3; j++ {
twoD[i][j] = i + j twoD[i][j] = i + j
} }
} }
fmt.Println("2d: ", twoD) fmt.Println("bi-dimensional: ", twoD)
} }

View File

@ -1,2 +1,2 @@
e2bdc11af83f9c6964cfa0e06e4642943b3055ae 1cc84ed730687fb03976f901fe6aa6047aedf027
bBVikSoZ1Z7 6x5yvAy8AT6

View File

@ -1,9 +1,9 @@
# Note that arrays appear in the form `[v1 v2 v3 ...]` # Note que arrays aparecem na forma `[v1 v2 v3 ...]`
# when printed with `fmt.Println`. # quando exibidos com `fmt.Println`.
$ go run arrays.go $ go run arrays.go
emp: [0 0 0 0 0] vazio: [0 0 0 0 0]
set: [0 0 0 0 100] índice 4 alterado: [0 0 0 0 100]
get: 100 valor índice 4: 100
len: 5 len: 5
dcl: [1 2 3 4 5] array inicializado:: [1 2 3 4 5]
2d: [[0 1 2] [1 2 3]] bi-dimensional: [[0 1 2] [1 2 3]]

View File

@ -1,16 +1,17 @@
// Go supports [_anonymous functions_](https://en.wikipedia.org/wiki/Anonymous_function), // Go suporta [_funções anônimas_](https://en.wikipedia.org/wiki/Anonymous_function),
// which can form <a href="https://en.wikipedia.org/wiki/Closure_(computer_science)"><em>closures</em></a>. // as quais podem formar
// Anonymous functions are useful when you want to define // <a href="https://pt.wikipedia.org/wiki/Clausura_(ci%C3%AAncia_da_computa%C3%A7%C3%A3o)"><em>closures</em></a>.
// a function inline without having to name it. // Funções anônimas são úteis quando se pretende
// definir a função em linha sem ser necessário nomeá-la.
package main package main
import "fmt" import "fmt"
// This function `intSeq` returns another function, which // Esta função `intSeq` retorna outra função, que é
// we define anonymously in the body of `intSeq`. The // definida anonimamente no corpo de `intSeq`. A função
// returned function _closes over_ the variable `i` to // retornada _fecha sobre_ (_closes over_) a variavel
// form a closure. // `i` para formar um fechamento (closure).
func intSeq() func() int { func intSeq() func() int {
i := 0 i := 0
return func() int { return func() int {
@ -21,20 +22,20 @@ func intSeq() func() int {
func main() { func main() {
// We call `intSeq`, assigning the result (a function) // Aqui, a execução da função `intSeq` (que retorna outra
// to `nextInt`. This function value captures its // função) é atribuída à variável `nextInt`.
// own `i` value, which will be updated each time // Esta função captura o próprio valor de `i`, que
// we call `nextInt`. // será atualizado a cada vez que é chamada `nextInt`.
nextInt := intSeq() nextInt := intSeq()
// See the effect of the closure by calling `nextInt` // Veja o efeito do closure chamando `nextInt`
// a few times. // algumas vezes.
fmt.Println(nextInt()) fmt.Println(nextInt())
fmt.Println(nextInt()) fmt.Println(nextInt())
fmt.Println(nextInt()) fmt.Println(nextInt())
// To confirm that the state is unique to that // Para confirmar que o estado é único àquela variável
// particular function, create and test a new one. // específica, ao criar outra e testar, o resultado é diverso.
newInts := intSeq() newInts := intSeq()
fmt.Println(newInts()) fmt.Println(newInts())
} }

View File

@ -1,2 +1,2 @@
6514e124c8127250a2eecfadc9708181e51f9603 62c797cd5c1e484d0886b633c8af71652368ef02
NpgpzS8ZG8y i-JqAhb-yJ1

View File

@ -4,5 +4,5 @@ $ go run closures.go
3 3
1 1
# The last feature of functions we'll look at for now is # O último recurso de funções a ser apresentado
# recursion. # é a recursão.

View File

@ -1,5 +1,5 @@
// Go supports _constants_ of character, string, boolean, // Go suporta _constantes_ de tipos strings, booleanos,
// and numeric values. // e numericos.
package main package main
@ -8,28 +8,29 @@ import (
"math" "math"
) )
// `const` declares a constant value. // `const` é a palavra reservada para declarar uma constante.
const s string = "constant" const s string = "constant"
func main() { func main() {
fmt.Println(s) fmt.Println(s)
// A `const` statement can appear anywhere a `var` // A declaração `const` pode aparecer em qualquer
// statement can. // lugar que a declaração `var` também possa.
const n = 500000000 const n = 500000000
// Constant expressions perform arithmetic with // Expressões com constantes são performadas
// arbitrary precision. // aritmeticamente com precisão arbitrária.
const d = 3e20 / n const d = 3e20 / n
fmt.Println(d) fmt.Println(d)
// A numeric constant has no type until it's given // Uma constante numérica não possui um tipo
// one, such as by an explicit conversion. // até que seja atribuído um, como uma conversão explícita.
fmt.Println(int64(d)) fmt.Println(int64(d))
// A number can be given a type by using it in a // Um tipo pode ser implicitamente atribuído a uma constante
// context that requires one, such as a variable // numérica ao usá-la num contexto que requer um tipo,
// assignment or function call. For example, here // como atribuição a uma variável ou uma chamada de função.
// `math.Sin` expects a `float64`. // Por exemplo, a função `math.Sin` espera um valor de tipo
// `float64`.
fmt.Println(math.Sin(n)) fmt.Println(math.Sin(n))
} }

View File

@ -1,2 +1,2 @@
9f776516953ae57a76544444c72802d3fad63da3 b03b175d283759d21b5bd2bab3dd99d0d74f9ff4
Vw-pXSfo9_b NA0z_34sqzx

View File

@ -1,5 +1,5 @@
// `for` is Go's only looping construct. Here are // `for` é a única ferramenta de repetição em Go.
// some basic types of `for` loops. // Aqui estão algumas formas básicas de utilização.
package main package main
@ -7,28 +7,28 @@ import "fmt"
func main() { func main() {
// The most basic type, with a single condition. // O tipo mais simples com apenas uma condição.
i := 1 i := 1
for i <= 3 { for i <= 3 {
fmt.Println(i) fmt.Println(i)
i = i + 1 i = i + 1
} }
// A classic initial/condition/after `for` loop. // O tipo clássico com inicial, condição
// de continuação e pós iteração.
for j := 7; j <= 9; j++ { for j := 7; j <= 9; j++ {
fmt.Println(j) fmt.Println(j)
} }
// `for` without a condition will loop repeatedly // `for` sem nenhuma condição será repetido indefinidamente,
// until you `break` out of the loop or `return` from // até que `break` ou `return` sejam usados para interromper.
// the enclosing function.
for { for {
fmt.Println("loop") fmt.Println("loop")
break break
} }
// You can also `continue` to the next iteration of // Também é possível utilizar o comando `continue`
// the loop. // para prosseguir para a próxima iteração do loop.
for n := 0; n <= 5; n++ { for n := 0; n <= 5; n++ {
if n%2 == 0 { if n%2 == 0 {
continue continue

View File

@ -1,2 +1,2 @@
7af221b7da2f2b22b0b1b0a1b365afc5a56ef815 72ef42973b9b9b78fbc266d61bf3c618e15afe67
2-4H-ArwHHS ilDqCUXz1gQ

View File

@ -10,6 +10,6 @@ loop
3 3
5 5
# We'll see some other `for` forms later when we look at # Algumas outras formas de utilizar o `for` serão
# `range` statements, channels, and other data # mencionados na declarações `range`; e em outras
# structures. # estruturas como channels.

View File

@ -1,32 +1,30 @@
// _Functions_ are central in Go. We'll learn about // _Functions_ são centrais em Go. Serão demonstradas
// functions with a few different examples. // funções com alguns exemplos diferentes.
package main package main
import "fmt" import "fmt"
// Here's a function that takes two `int`s and returns // Aqui está uma função que recebe dois inteiros `int` e retorna a soma de ambos como outro inteiro `int`.
// their sum as an `int`.
func plus(a int, b int) int { func plus(a int, b int) int {
// Go requires explicit returns, i.e. it won't // Go exige retornos explícitos. Por exemplo,
// automatically return the value of the last // não será retornado automaticamente o valor
// expression. // da última expressão
return a + b return a + b
} }
// When you have multiple consecutive parameters of // Ao existir multiplos parâmetros consecutivos de um
// the same type, you may omit the type name for the // mesmo tipo, é possível omitir o tipo dos parâmetros
// like-typed parameters up to the final parameter that // até a declaração do último parâmetro daquele tipo.
// declares the type.
func plusPlus(a, b, c int) int { func plusPlus(a, b, c int) int {
return a + b + c return a + b + c
} }
func main() { func main() {
// Call a function just as you'd expect, with // Para executar uma função é utilizada a
// `name(args)`. // sintaxe `nomeDaFuncao(argumentos)`.
res := plus(1, 2) res := plus(1, 2)
fmt.Println("1+2 =", res) fmt.Println("1+2 =", res)

View File

@ -1,2 +1,2 @@
94ade6d23721234a9612c9f77431106308b84953 2b0fbcad1f490acff84ac28e8f20e2f4891cfec6
-o49-dQfGbK D8sGhZBD4Ai

View File

@ -2,5 +2,6 @@ $ go run functions.go
1+2 = 3 1+2 = 3
1+2+3 = 6 1+2+3 = 6
# There are several other features to Go functions. One is # Existem muitos outros recursos em Funções,
# multiple return values, which we'll look at next. # um dos quais é chamado de Retorno de Valores
# Múltiplos que será apresentado no próximo exemplo.

View File

@ -1,5 +1,5 @@
// Our first program will print the classic "hello world" // O nosso primeiro programa exibirá a mensagem "hello world".
// message. Here's the full source code. // Aqui está o código completo.
package main package main
import "fmt" import "fmt"

View File

@ -1,2 +1,2 @@
3eb6e21f5f89b9a4bf64f267972a24211f0032e7 f0d362732151b2e0e19e682d0d649e0e0d08ea66
NeviD0awXjt kj7TRRdvOse

View File

@ -1,17 +1,19 @@
# To run the program, put the code in `hello-world.go` and # Para rodar o programa, insira o código no arquivo
# use `go run`. # `hello-world.go` e em seguida, execute o comando
# `go run`.
$ go run hello-world.go $ go run hello-world.go
hello world hello world
# Sometimes we'll want to build our programs into # Por vezes é útil ter nossos programas em binário.
# binaries. We can do this using `go build`. # É possível fazer isso por meio do comando `go build`
$ go build hello-world.go $ go build hello-world.go
$ ls $ ls
hello-world hello-world.go hello-world hello-world.go
# We can then execute the built binary directly. # É possível, então, executar diretamente o binário
# gerado.
$ ./hello-world $ ./hello-world
hello world hello world
# Now that we can run and build basic Go programs, let's # Agora que conseguimos executar e gerar programas
# learn more about the language. # em Go, vamos aprender mais sobre a linguagem.

View File

@ -1,5 +1,4 @@
// Branching with `if` and `else` in Go is // A condicional `if` e `else` em Go é bem direta.
// straight-forward.
package main package main
@ -7,29 +6,30 @@ import "fmt"
func main() { func main() {
// Here's a basic example. // Aqui está um exemplo básico.
if 7%2 == 0 { if 7%2 == 0 {
fmt.Println("7 is even") fmt.Println("7 é par")
} else { } else {
fmt.Println("7 is odd") fmt.Println("7 é ímpar")
} }
// You can have an `if` statement without an else. // Também é possível utilizar o `if` sem `else`.
if 8%4 == 0 { if 8%4 == 0 {
fmt.Println("8 is divisible by 4") fmt.Println("8 é divisível por 4")
} }
// A statement can precede conditionals; any variables // Declarações podem preceder as condições; qualquer
// declared in this statement are available in the current // variável declarada na estrutura condicional ficará
// and all subsequent branches. // disponível em todas as suas ramificações.
if num := 9; num < 0 { if num := 9; num < 0 {
fmt.Println(num, "is negative") fmt.Println(num, "é negativo")
} else if num < 10 { } else if num < 10 {
fmt.Println(num, "has 1 digit") fmt.Println(num, "possui 1 dígito")
} else { } else {
fmt.Println(num, "has multiple digits") fmt.Println(num, "possui múltiplos dígitos")
} }
} }
// Note that you don't need parentheses around conditions // É importante lembrar que não é necessário envelopar
// in Go, but that the braces are required. // condicionais com parenteses em Go, no entanto,
// as chaves {} são necessárias.

View File

@ -1,2 +1,2 @@
d6a962236fc1296684cd1ffb2d95d131ed84abde 57a5f486eec14ec74c4db2dc633b38b76fea053c
U7xcpdutgCJ 1I2JHAXgr-3

View File

@ -1,8 +1,8 @@
$ go run if-else.go $ go run if-else.go
7 is odd 7 é ímpar
8 is divisible by 4 8 é divisível por 4
9 has 1 digit 9 possui 1 dígito
# There is no [ternary if](https://en.wikipedia.org/wiki/%3F:) # Não há [operador ternário](https://en.wikipedia.org/wiki/%3F:)
# in Go, so you'll need to use a full `if` statement even # em Go, então é necessário utilizar `if`
# for basic conditions. # mesmo para condições básicas.

View File

@ -1,5 +1,6 @@
// _Maps_ are Go's built-in [associative data type](https://en.wikipedia.org/wiki/Associative_array) // _Maps_ é o [vetor associativo](https://pt.wikipedia.org/wiki/Vetor_associativo)
// (sometimes called _hashes_ or _dicts_ in other languages). // nativo de Go.
// (também chamado de _hashes_ ou _dicts_ em outras linguagens).
package main package main
@ -7,44 +8,46 @@ import "fmt"
func main() { func main() {
// To create an empty map, use the builtin `make`: // Para criar um map vazio, utilize o comando nativo `make`:
// `make(map[key-type]val-type)`. // `make(map[tipoDaChave]tipoDoValor)`.
m := make(map[string]int) m := make(map[string]int)
// Set key/value pairs using typical `name[key] = val` // É possível alterar ou criar pares de chave/valor
// syntax. // usando a sintaxe `nomeDoMap[chave] = valor`.
m["k1"] = 7 m["k1"] = 7
m["k2"] = 13 m["k2"] = 13
// Printing a map with e.g. `fmt.Println` will show all of // Ao imprimir um map com `fmt.Println`, por exemplo,
// its key/value pairs. // serão exibidos todos os pares chave/valor.
fmt.Println("map:", m) fmt.Println("mapa:", m)
// Get a value for a key with `name[key]`. // Para selecionar o valor de determinada chave,
// usa-se o comando `nomeDoMap[chave]`.
v1 := m["k1"] v1 := m["k1"]
fmt.Println("v1: ", v1) fmt.Println("valor 1: ", v1)
// The builtin `len` returns the number of key/value // O comando nativo `len`, recebendo um mapa como
// pairs when called on a map. // argumento, retorna o número de pares chave/valor.
fmt.Println("len:", len(m)) fmt.Println("len:", len(m))
// The builtin `delete` removes key/value pairs from // O comando nativo `delete` remove um determinado
// a map. // par de chave/valor do mapa.
delete(m, "k2") delete(m, "k2")
fmt.Println("map:", m) fmt.Println("mapa:", m)
// The optional second return value when getting a // Ao selecionar um determinado valor em um mapa,
// value from a map indicates if the key was present // existe um segundo retorno opcional, do tipo booleano,
// in the map. This can be used to disambiguate // que indica a presença ou ausência de um determinado
// between missing keys and keys with zero values // par no map. Isto pode ser utilizado para desambiguação
// like `0` or `""`. Here we didn't need the value // entre chaves ausentes e chaves com valor zero, como
// itself, so we ignored it with the _blank identifier_ // `0` or `""`. Onde o valor correspondente à chave não
// `_`. // for necessário, é possível ignorar com um identificador
// vazio `_`.
_, prs := m["k2"] _, prs := m["k2"]
fmt.Println("prs:", prs) fmt.Println("presença da chave:", prs)
// You can also declare and initialize a new map in // Também é possível declarar e inicializar um
// the same line with this syntax. // novo mapa na mesma linha com a sintaxe a seguir.
n := map[string]int{"foo": 1, "bar": 2} n := map[string]int{"foo": 1, "bar": 2}
fmt.Println("map:", n) fmt.Println("mapa:", n)
} }

View File

@ -1,2 +1,2 @@
22d147fe9402f9ff210f12b9810811c07f4d64ca 91de19de49ffa1003c309ad4c1418e025b0c7a8f
ulCzODwCde_0 Z1XbrBn9vsr

View File

@ -1,9 +1,9 @@
# Note that maps appear in the form `map[k:v k:v]` when # Note que os mapas são exibidos na forma `map[k:v k:v]`
# printed with `fmt.Println`. # quando impressos com `fmt.Println`.
$ go run maps.go $ go run maps.go
map: map[k1:7 k2:13] mapa: map[k1:7 k2:13]
v1: 7 valor 1: 7
len: 2 len: 2
map: map[k1:7] mapa: map[k1:7]
prs: false presença da chave: false
map: map[bar:2 foo:1] mapa: map[bar:2 foo:1]

View File

@ -1,27 +1,28 @@
// Go has built-in support for _multiple return values_. // Go tem suporte nativo para _múltiplos valores de retorno_.
// This feature is used often in idiomatic Go, for example // Esse recurso é utilizado frequentemente
// to return both result and error values from a function. // em Go idiomático, por exemplo, para retornar
// valores de resultado e de erro de uma função.
package main package main
import "fmt" import "fmt"
// The `(int, int)` in this function signature shows that // A expressão `(int, int)` na assinatura desta função
// the function returns 2 `int`s. // demonstra que a função retorna dois inteiros `int`.
func vals() (int, int) { func vals() (int, int) {
return 3, 7 return 3, 7
} }
func main() { func main() {
// Here we use the 2 different return values from the // Aqui são utilizados ambos valores retornados
// call with _multiple assignment_. // da função com _atribuição múltipla_.
a, b := vals() a, b := vals()
fmt.Println(a) fmt.Println(a)
fmt.Println(b) fmt.Println(b)
// If you only want a subset of the returned values, // Para utilizar apenas um dos valores retornados,
// use the blank identifier `_`. // utiliza-se o identificador vazio `_`.
_, c := vals() _, c := vals()
fmt.Println(c) fmt.Println(c)
} }

View File

@ -1,2 +1,2 @@
c6e4f5dd9c55b5d2aaeb7e939c216ec76f042501 6789db626f3d2330a6f968a0670cc220bcafcbac
vZdUvLB1WbK 7kvvjKA16K7

View File

@ -3,5 +3,6 @@ $ go run multiple-return-values.go
7 7
7 7
# Accepting a variable number of arguments is another nice # Aceitar um número variável de argumentos é outro
# feature of Go functions; we'll look at this next. # ótimo recurso de Go functions; será apresentado
# no próximo exemplo.

View File

@ -1,6 +1,7 @@
// _range_ iterates over elements in a variety of data // _range_ itera sobre elementos de uma variedade
// structures. Let's see how to use `range` with some // de estrutura de dados. Aqui será demonstrado como
// of the data structures we've already learned. // utilizá-lo com algumas das estruturas de dados já
// apresentadas.
package main package main
@ -8,43 +9,43 @@ import "fmt"
func main() { func main() {
// Here we use `range` to sum the numbers in a slice. // Aqui é utilizado o `range` para somar os números
// Arrays work like this too. // de um slice. Funciona da mesma forma em arrays.
nums := []int{2, 3, 4} nums := []int{2, 3, 4}
sum := 0 sum := 0
for _, num := range nums { for _, num := range nums {
sum += num sum += num
} }
fmt.Println("sum:", sum) fmt.Println("soma:", sum)
// `range` on arrays and slices provides both the // `range` tanto em arrays quanto em slices fornece
// index and value for each entry. Above we didn't // chave e valor; ou índice e valor para cada entrada.
// need the index, so we ignored it with the // No exemplo acima não foi necessário o índice, então
// blank identifier `_`. Sometimes we actually want // foi ignorado com identificador vazio `_`.
// the indexes though. // Algumas vezes, entretanto, os índices serão necessários.
for i, num := range nums { for i, num := range nums {
if num == 3 { if num == 3 {
fmt.Println("index:", i) fmt.Println("índice:", i)
} }
} }
// `range` on map iterates over key/value pairs. // `range` em mapas itera sobre os pares de chave/valor.
kvs := map[string]string{"a": "apple", "b": "banana"} kvs := map[string]string{"a": "apple", "b": "banana"}
for k, v := range kvs { for k, v := range kvs {
fmt.Printf("%s -> %s\n", k, v) fmt.Printf("%s -> %s\n", k, v)
} }
// `range` can also iterate over just the keys of a map. // `range` pode iterar apenas sobre as chaves de um mapa.
for k := range kvs { for k := range kvs {
fmt.Println("key:", k) fmt.Println("key:", k)
} }
// `range` on strings iterates over Unicode code // `range` em strings itera sobre pontos de código Unicode.
// points. The first value is the starting byte index // O primeiro valor é o byte de índice de início da `rune`,
// of the `rune` and the second the `rune` itself. // e o segundo, da própria `rune`.
// See [Strings and Runes](strings-and-runes) for more // Veja a seção [Strings and Runes](strings-and-runes)
// details. // para mais detalhes.
for i, c := range "go" { for i, rune := range "go" {
fmt.Println(i, c) fmt.Println(i, rune)
} }
} }

View File

@ -1,2 +1,2 @@
c8da490660d234fc420f39d9b8a4aba27f8aba46 27e654eba4cb1f7a23c99c2a07cc83d2631821ef
kRsyWNmLFLz 0jbhU_qHfKO

View File

@ -1,6 +1,6 @@
$ go run range.go $ go run range.go
sum: 9 soma: 9
index: 1 índice: 1
a -> apple a -> apple
b -> banana b -> banana
key: a key: a

View File

@ -1,5 +1,6 @@
// _Slices_ are an important data type in Go, giving // _Slices_ é um importante tipo de dado em Go,
// a more powerful interface to sequences than arrays. // oferecendo uma interface mais completa do que
// arrays para lidar com sequências.
package main package main
@ -7,63 +8,69 @@ import "fmt"
func main() { func main() {
// Unlike arrays, slices are typed only by the // Diferente de arrays, slices são tipados apenas com
// elements they contain (not the number of elements). // tipo dos elementos que armazenará (sem um tamanho).
// To create an empty slice with non-zero length, use // Para criar um slice vazio, com tamanho não zero,
// the builtin `make`. Here we make a slice of // deve-se usar o comando nativo `make`. Aqui é feito
// `string`s of length `3` (initially zero-valued). // um slice de `string`, com tamanho 3
// (inicialmente com valor padrão zero).
s := make([]string, 3) s := make([]string, 3)
fmt.Println("emp:", s) fmt.Println("vazio:", s)
// We can set and get just like with arrays. // Para alterar os valores de um slice e seleciná-los,
// faz-se da mesma forma que com array.
s[0] = "a" s[0] = "a"
s[1] = "b" s[1] = "b"
s[2] = "c" s[2] = "c"
fmt.Println("set:", s) fmt.Println("exibe slice:", s)
fmt.Println("get:", s[2]) fmt.Println("valor índice 2:", s[2])
// `len` returns the length of the slice as expected. // `len` retorna o tamanho de slices, da mesma forma
// que com arrays.
fmt.Println("len:", len(s)) fmt.Println("len:", len(s))
// In addition to these basic operations, slices // Em adição a estas operações básicas, slices
// support several more that make them richer than // suportam muitas outras que as fazem mais úteis do que
// arrays. One is the builtin `append`, which // arrays. Uma delas é a função nativa `append`, que
// returns a slice containing one or more new values. // retorna a slice contendo um ou mais novos valores.
// Note that we need to accept a return value from // Note que é preciso aceitar o valor retornado da função
// `append` as we may get a new slice value. // `append` para ter a slice atualizada.
s = append(s, "d") s = append(s, "d")
s = append(s, "e", "f") s = append(s, "e", "f")
fmt.Println("apd:", s) fmt.Println("slice com acréscimo:", s)
// Slices can also be `copy`'d. Here we create an // Slices também podem ser copiadas com `copy`. Aqui
// empty slice `c` of the same length as `s` and copy // é criado uma slice vazia `c` do mesmo tamanho da
// into `c` from `s`. // slice `s`. Então, a slice `s` é copiada para `c`.
c := make([]string, len(s)) c := make([]string, len(s))
copy(c, s) copy(c, s)
fmt.Println("cpy:", c) fmt.Println("slice copiada:", c)
// Slices support a "slice" operator with the syntax // Slices suportam um operador "slice" com a sintaxe
// `slice[low:high]`. For example, this gets a slice // `slice[índiceBaixo:índiceAlto]`. Por exemplo, o
// of the elements `s[2]`, `s[3]`, and `s[4]`. // comando a seguir seleciona os elementos da slice
// de índices 2, 3 e 4; ou `s[2]`, `s[3]`, e `s[4]`.
l := s[2:5] l := s[2:5]
fmt.Println("sl1:", l) fmt.Println("slice 1:", l)
// This slices up to (but excluding) `s[5]`. // Já este, "fatia" o slice `s` até o
// índice 5 (não incluso) ou `s[5]`.
l = s[:5] l = s[:5]
fmt.Println("sl2:", l) fmt.Println("slice 2:", l)
// And this slices up from (and including) `s[2]`. // E este, "fatia" o slices `s` a partir do
// índice 2 (incluso) ou `s[2]`.
l = s[2:] l = s[2:]
fmt.Println("sl3:", l) fmt.Println("slice 3:", l)
// We can declare and initialize a variable for slice // Também é possível declarar e inicializar um
// in a single line as well. // slice em apenas uma linha.
t := []string{"g", "h", "i"} t := []string{"g", "h", "i"}
fmt.Println("dcl:", t) fmt.Println("slice inicializada:", t)
// Slices can be composed into multi-dimensional data // Slices podem ser compsotas em estruturas
// structures. The length of the inner slices can // multi-dimensionais. O tamanho das slices internas
// vary, unlike with multi-dimensional arrays. // pode variar, diferente de arrays multi-dimensionais.
twoD := make([][]int, 3) twoD := make([][]int, 3)
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
innerLen := i + 1 innerLen := i + 1
@ -72,5 +79,5 @@ func main() {
twoD[i][j] = i + j twoD[i][j] = i + j
} }
} }
fmt.Println("2d: ", twoD) fmt.Println("bi-dimensional: ", twoD)
} }

View File

@ -1,2 +1,2 @@
13835b88336e031808f2f3887cd43d0b9d85cad0 bd0d70746f218672f81c716638b594350c1fa8f1
76f4Jif5Z8o qAON5gPJwlP

View File

@ -1,21 +1,22 @@
# Note that while slices are different types than arrays, # Note que enquanto slices são tipos diferentes
# they are rendered similarly by `fmt.Println`. # de arrays, eles são exibidos de maneira similar
# pelo comando `fmt.Println`.
$ go run slices.go $ go run slices.go
emp: [ ] vazio: [ ]
set: [a b c] exibe slice: [a b c]
get: c valor índice 2: c
len: 3 len: 3
apd: [a b c d e f] slice com acréscimo: [a b c d e f]
cpy: [a b c d e f] slice copiada: [a b c d e f]
sl1: [c d e] slice 1: [c d e]
sl2: [a b c d e] slice 2: [a b c d e]
sl3: [c d e f] slice 3: [c d e f]
dcl: [g h i] slice inicializada: [g h i]
2d: [[0] [1 2] [2 3 4]] bi-dimensional: [[0] [1 2] [2 3 4]]
# Check out this [great blog post](https://go.dev/blog/slices-intro) # Veja esse [post](https://go.dev/blog/slices-intro)
# by the Go team for more details on the design and # do time de Go para mais detalhes sobre o design e
# implementation of slices in Go. # implementação de slices na linguagem.
# Now that we've seen arrays and slices we'll look at # Agora que vimos arrays e slices, passaremos a estudar
# Go's other key builtin data structure: maps. # outra estrutura de dados nativa de Go: maps.

View File

@ -1,5 +1,5 @@
// _Switch statements_ express conditionals across many // Declarações _Switch_ são geralmente utilizadas
// branches. // para condicionais com muitas ramificações.
package main package main
@ -10,51 +10,51 @@ import (
func main() { func main() {
// Here's a basic `switch`. // Aqui está um `switch` básico.
i := 2 i := 2
fmt.Print("Write ", i, " as ") fmt.Print("Imprima ", i, " como ")
switch i { switch i {
case 1: case 1:
fmt.Println("one") fmt.Println("um")
case 2: case 2:
fmt.Println("two") fmt.Println("dois")
case 3: case 3:
fmt.Println("three") fmt.Println("três")
} }
// You can use commas to separate multiple expressions // Vírgulas podem ser utilizadas para separar múltiplas
// in the same `case` statement. We use the optional // expressões na mesma declaração `case`. A utilização
// `default` case in this example as well. // de `default` é opcional.
switch time.Now().Weekday() { switch time.Now().Weekday() {
case time.Saturday, time.Sunday: case time.Saturday, time.Sunday:
fmt.Println("It's the weekend") fmt.Println("É fim de semana")
default: default:
fmt.Println("It's a weekday") fmt.Println("É dia de semana")
} }
// `switch` without an expression is an alternate way // `switch` sem nenhuma expressão é um meio alternativo
// to express if/else logic. Here we also show how the // para representar a lógica if/else. Aqui também é exibido como
// `case` expressions can be non-constants. // as expressões `case` podem ser não constantes.
t := time.Now() t := time.Now()
switch { switch {
case t.Hour() < 12: case t.Hour() < 12:
fmt.Println("It's before noon") fmt.Println("É antes do meio-dia")
default: default:
fmt.Println("It's after noon") fmt.Println("É depois do meio-dia")
} }
// A type `switch` compares types instead of values. You // Um `switch` de tipos compara tipos ao invés de valores.
// can use this to discover the type of an interface // É possível utilizá-lo para descobrir o valor de um tipo
// value. In this example, the variable `t` will have the // interface. Neste exemplo, a variável `t` terá o tipo
// type corresponding to its clause. // correspondente à sua cláusula.
whatAmI := func(i interface{}) { whatAmI := func(i interface{}) {
switch t := i.(type) { switch t := i.(type) {
case bool: case bool:
fmt.Println("I'm a bool") fmt.Println("Sou um booleano")
case int: case int:
fmt.Println("I'm an int") fmt.Println("Sou um inteiro")
default: default:
fmt.Printf("Don't know type %T\n", t) fmt.Printf("Não sei o meu tipo %T\n", t)
} }
} }
whatAmI(true) whatAmI(true)

View File

@ -1,2 +1,2 @@
28a8909ee7963cb315f14a3be1607def1d91f3a3 010a84fa4d50561624f3bd635a6b15c71e096436
qVDqWoUQ6AI Y5mGHTuumK0

View File

@ -1,7 +1,7 @@
$ go run switch.go $ go run switch.go
Write 2 as two Imprima 2 como dois
It's a weekday É fim de semana
It's after noon É depois do meio-dia
I'm a bool Sou um booleano
I'm an int Sou um inteiro
Don't know type string Não sei o meu tipo string

View File

@ -1,6 +1,6 @@
// Go has various value types including strings, // Go tem vários tipos de valores, dentre eles:
// integers, floats, booleans, etc. Here are a few // strings, integers, floats, booleans, etc.
// basic examples. // Aqui estão alguns exemplos básicos.
package main package main
@ -8,14 +8,14 @@ import "fmt"
func main() { func main() {
// Strings, which can be added together with `+`. // Strings, que podem ser concatenadas usando `+`.
fmt.Println("go" + "lang") fmt.Println("go" + "lang")
// Integers and floats. // Integers e floats.
fmt.Println("1+1 =", 1+1) fmt.Println("1+1 =", 1+1)
fmt.Println("7.0/3.0 =", 7.0/3.0) fmt.Println("7.0/3.0 =", 7.0/3.0)
// Booleans, with boolean operators as you'd expect. // Booleans, com operadores booleanos.
fmt.Println(true && false) fmt.Println(true && false)
fmt.Println(true || false) fmt.Println(true || false)
fmt.Println(!true) fmt.Println(!true)

View File

@ -1,2 +1,2 @@
476982956a689418d548148af5f17145de16f063 61a4fe5de5cf99bed41f516b2dd902e4589f5b67
YnVS3LZr8pk 76t8TCPZB4E

View File

@ -1,6 +1,6 @@
// In Go, _variables_ are explicitly declared and used by // Em Go, _variáveis_ são explicitamente declaradas
// the compiler to e.g. check type-correctness of function // e usadas pelo compilador para, por exemplo,
// calls. // verificar validade de tipos em chamadas a funções.
package main package main
@ -8,28 +8,31 @@ import "fmt"
func main() { func main() {
// `var` declares 1 or more variables. // `var` é uma palavra reservada que é utilizada
// para declarar variáveis.
var a = "initial" var a = "initial"
fmt.Println(a) fmt.Println(a)
// You can declare multiple variables at once. // Você pode declarar mais de uma variável.
var b, c int = 1, 2 var b, c int = 1, 2
fmt.Println(b, c) fmt.Println(b, c)
// Go will infer the type of initialized variables. // Go, na ausência de declaração de um tipo, irá inferir
// o tipo da variável inicializada.
var d = true var d = true
fmt.Println(d) fmt.Println(d)
// Variables declared without a corresponding // Variáveis declaradas sem um tipo correspondente são
// initialization are _zero-valued_. For example, the // inicializadas com valores padrões, ou zero (zero-value).
// zero value for an `int` is `0`. // Por exemplo, o valor padrão para uma variável do tipo
// `int` é `0`.
var e int var e int
fmt.Println(e) fmt.Println(e)
// The `:=` syntax is shorthand for declaring and // A sintaxe `:=` é uma abreviação para declarar e
// initializing a variable, e.g. for // inicializar uma variavel. Por exemplo,
// `var f string = "apple"` in this case. // `var f string = "apple"`.
// This syntax is only available inside functions. // Esta sintaxe é permitida somente dentro de funções.
f := "apple" f := "apple"
fmt.Println(f) fmt.Println(f)
} }

View File

@ -1,2 +1,2 @@
9aeef52b289d7ad9b9ac79f129d4e49f956c60ef 4477b99ff2f7744239b716c12336a6f5d6027fac
N5rWndIliJW 2mFIGGGSjvo

View File

@ -1,20 +1,22 @@
// [_Variadic functions_](https://en.wikipedia.org/wiki/Variadic_function) // [_Funções variádicas_](https://en.wikipedia.org/wiki/Variadic_function)
// can be called with any number of trailing arguments. // podem ser chamads com qualquer número de argumentos.
// For example, `fmt.Println` is a common variadic // Por exemplo, `fmt.Println` é uma função variádica
// function. // comumente utilizada.
package main package main
import "fmt" import "fmt"
// Here's a function that will take an arbitrary number // Aqui está uma função que aceitará um número arbitrário de
// of `int`s as arguments. // inteiros `int`s como argumento(s).
// Atenção para o operador de espalhamento (spread operator)
// que deve preceder a declaração do tipo.
func sum(nums ...int) { func sum(nums ...int) {
fmt.Print(nums, " ") fmt.Print(nums, " ")
total := 0 total := 0
// Within the function, the type of `nums` is // Dentro da função, o tipo `nums` é
// equivalent to `[]int`. We can call `len(nums)`, // equivalente a `[]int`. É possível usar `len(nums)`,
// iterate over it with `range`, etc. // iterar utilizando `range`, etc.
for _, num := range nums { for _, num := range nums {
total += num total += num
} }
@ -23,14 +25,16 @@ func sum(nums ...int) {
func main() { func main() {
// Variadic functions can be called in the usual way // Funções variádicas pode ser chamada de
// with individual arguments. // forma usual com argumentos individuais.
sum(1, 2) sum(1, 2)
sum(1, 2, 3) sum(1, 2, 3)
// If you already have multiple args in a slice, // Se uma slice com multiplos argumentos estiver
// apply them to a variadic function using // disponível, é possível passá-la como parâmetro
// `func(slice...)` like this. // para uma função variádica usando `func(slice...)`.
// Atenção que agora o operador de espalhamento deve
// suceder o nome do parâmetro.
nums := []int{1, 2, 3, 4} nums := []int{1, 2, 3, 4}
sum(nums...) sum(nums...)
} }

View File

@ -1,2 +1,2 @@
561184169a1b4c3d4970d496b282cc81016583d6 8a6a24ec58ed49771c82e94ce0ffea66fee1294f
glNdE8aKPNq Tl71iwyXk-F

View File

@ -3,5 +3,6 @@ $ go run variadic-functions.go
[1 2 3] 6 [1 2 3] 6
[1 2 3 4] 10 [1 2 3 4] 10
# Another key aspect of functions in Go is their ability # Outro aspecto chave de funções em Go é a
# to form closures, which we'll look at next. # capacidade para formar fechamentos (closures),
# que serão apresentados em seguida.

2
public/404.html generated
View File

@ -11,7 +11,7 @@
<p>Sorry, we couldn't find that! Check out the <a href="./">home page</a>?</p> <p>Sorry, we couldn't find that! Check out the <a href="./">home page</a>?</p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

67
public/arrays generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Arrays</title> <title>Go Em Exemplos: Arrays</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -27,10 +27,10 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p>In Go, an <em>array</em> is a numbered sequence of elements of a <p>Em Go, um <em>array</em> é uma sequência numerada de elementos
specific length. In typical Go code, <a href="slices">slices</a> are de um tamanho específico. Tipicamente, <a href="slices">slices</a> são
much more common; arrays are useful in some special muito mais comuns; arrays são úteis em alguns cenários
scenarios.</p> específicos.</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -44,7 +44,7 @@ scenarios.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/bBVikSoZ1Z7"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/6x5yvAy8AT6"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -74,41 +74,41 @@ scenarios.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Here we create an array <code>a</code> that will hold exactly <p>Aqui é criado um array <code>a</code> com capacidade de armazenar
5 <code>int</code>s. The type of elements and length are both exatamente 5 inteiros. O tipo de elemento que ele irá
part of the array&rsquo;s type. By default an array is armazenar (int) e seu tamanho (5) são partes do tipo do array.
zero-valued, which for <code>int</code>s means <code>0</code>s.</p> Neste caso, o array tem valores padrão zero.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="kd">var</span> <span class="nx">a</span> <span class="p">[</span><span class="mi">5</span><span class="p">]</span><span class="kt">int</span> <span class="kd">var</span> <span class="nx">a</span> <span class="p">[</span><span class="mi">5</span><span class="p">]</span><span class="kt">int</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;emp:&#34;</span><span class="p">,</span> <span class="nx">a</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;vazio:&#34;</span><span class="p">,</span> <span class="nx">a</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>We can set a value at an index using the <p>É possível alterar o valor de um índice do array
<code>array[index] = value</code> syntax, and get a value with utilizando a sintaxe <code>array[índice] = valor</code>,
<code>array[index]</code>.</p> bem como selecionar um valor com <code>array[índice]</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nx">a</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="p">=</span> <span class="mi">100</span> <span class="nx">a</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="p">=</span> <span class="mi">100</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;set:&#34;</span><span class="p">,</span> <span class="nx">a</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;índice 4 alterado:&#34;</span><span class="p">,</span> <span class="nx">a</span><span class="p">)</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;get:&#34;</span><span class="p">,</span> <span class="nx">a</span><span class="p">[</span><span class="mi">4</span><span class="p">])</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;valor índice 4:&#34;</span><span class="p">,</span> <span class="nx">a</span><span class="p">[</span><span class="mi">4</span><span class="p">])</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>The builtin <code>len</code> returns the length of an array.</p> <p>A função nativa <code>len</code> retorna o tamanho de um array.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -121,24 +121,23 @@ zero-valued, which for <code>int</code>s means <code>0</code>s.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Use this syntax to declare and initialize an array <p>Para declarar a inicializar um array em uma linha,
in one line.</p> é possível usar esta sintaxe.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nx">b</span> <span class="o">:=</span> <span class="p">[</span><span class="mi">5</span><span class="p">]</span><span class="kt">int</span><span class="p">{</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">}</span> <span class="nx">b</span> <span class="o">:=</span> <span class="p">[</span><span class="mi">5</span><span class="p">]</span><span class="kt">int</span><span class="p">{</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">}</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;dcl:&#34;</span><span class="p">,</span> <span class="nx">b</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;array inicializado:&#34;</span><span class="p">,</span> <span class="nx">b</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Array types are one-dimensional, but you can <p>Arrays, via de regra são unidimensionais, mas é possível
compose types to build multi-dimensional data compor tipos para formar arrays multidimensionais.</p>
structures.</p>
</td> </td>
<td class="code"> <td class="code">
@ -150,7 +149,7 @@ structures.</p>
<span class="nx">twoD</span><span class="p">[</span><span class="nx">i</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span> <span class="p">=</span> <span class="nx">i</span> <span class="o">+</span> <span class="nx">j</span> <span class="nx">twoD</span><span class="p">[</span><span class="nx">i</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span> <span class="p">=</span> <span class="nx">i</span> <span class="o">+</span> <span class="nx">j</span>
<span class="p">}</span> <span class="p">}</span>
<span class="p">}</span> <span class="p">}</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;2d: &#34;</span><span class="p">,</span> <span class="nx">twoD</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;bi-dimensional: &#34;</span><span class="p">,</span> <span class="nx">twoD</span><span class="p">)</span>
<span class="p">}</span> <span class="p">}</span>
</pre> </pre>
</td> </td>
@ -162,20 +161,20 @@ structures.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Note that arrays appear in the form <code>[v1 v2 v3 ...]</code> <p>Note que arrays aparecem na forma <code>[v1 v2 v3 ...]</code>
when printed with <code>fmt.Println</code>.</p> quando exibidos com <code>fmt.Println</code>.</p>
</td> </td>
<td class="code"> <td class="code">
<pre class="chroma"> <pre class="chroma">
<span class="gp">$</span> go run arrays.go <span class="gp">$</span> go run arrays.go
<span class="go">emp: [0 0 0 0 0] <span class="go">vazio: [0 0 0 0 0]
</span><span class="go">set: [0 0 0 0 100] </span><span class="go">índice 4 alterado: [0 0 0 0 100]
</span><span class="go">get: 100 </span><span class="go">valor índice 4: 100
</span><span class="go">len: 5 </span><span class="go">len: 5
</span><span class="go">dcl: [1 2 3 4 5] </span><span class="go">array inicializado:: [1 2 3 4 5]
</span><span class="go">2d: [[0 1 2] [1 2 3]]</span></pre> </span><span class="go">bi-dimensional: [[0 1 2] [1 2 3]]</span></pre>
</td> </td>
</tr> </tr>
@ -183,18 +182,18 @@ when printed with <code>fmt.Println</code>.</p>
<p class="next"> <p class="next">
Next example: <a href="slices">Slices</a>. Próximo exemplo: <a href="slices">Slices</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>
<script> <script>
var codeLines = []; var codeLines = [];
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' var a [5]int\u000A fmt.Println(\"emp:\", a)\u000A');codeLines.push(' a[4] \u003D 100\u000A fmt.Println(\"set:\", a)\u000A fmt.Println(\"get:\", a[4])\u000A');codeLines.push(' fmt.Println(\"len:\", len(a))\u000A');codeLines.push(' b :\u003D [5]int{1, 2, 3, 4, 5}\u000A fmt.Println(\"dcl:\", b)\u000A');codeLines.push(' var twoD [2][3]int\u000A for i :\u003D 0; i \u003C 2; i++ {\u000A for j :\u003D 0; j \u003C 3; j++ {\u000A twoD[i][j] \u003D i + j\u000A }\u000A }\u000A fmt.Println(\"2d: \", twoD)\u000A}\u000A');codeLines.push(''); codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' var a [5]int\u000A fmt.Println(\"vazio:\", a)\u000A');codeLines.push(' a[4] \u003D 100\u000A fmt.Println(\"índice 4 alterado:\", a)\u000A fmt.Println(\"valor índice 4:\", a[4])\u000A');codeLines.push(' fmt.Println(\"len:\", len(a))\u000A');codeLines.push(' b :\u003D [5]int{1, 2, 3, 4, 5}\u000A fmt.Println(\"array inicializado:\", b)\u000A');codeLines.push(' var twoD [2][3]int\u000A for i :\u003D 0; i \u003C 2; i++ {\u000A for j :\u003D 0; j \u003C 3; j++ {\u000A twoD[i][j] \u003D i + j\u000A }\u000A }\u000A fmt.Println(\"bi-dimensional: \", twoD)\u000A}\u000A');codeLines.push('');
</script> </script>
<script src="site.js" async></script> <script src="site.js" async></script>
</body> </body>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Atomic Counters</title> <title>Go Em Exemplos: Atomic Counters</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -46,7 +46,7 @@ counters</em> accessed by multiple goroutines.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/j-14agntvEO"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/j-14agntvEO"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -221,12 +221,12 @@ state.</p>
<p class="next"> <p class="next">
Next example: <a href="mutexes">Mutexes</a>. Próximo exemplo: <a href="mutexes">Mutexes</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Base64 Encoding</title> <title>Go Em Exemplos: Base64 Encoding</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -42,7 +42,7 @@ encoding/decoding</a>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/yztzkirFEvv"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/yztzkirFEvv"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -177,12 +177,12 @@ but they both decode to the original string as desired.</p>
<p class="next"> <p class="next">
Next example: <a href="reading-files">Reading Files</a>. Próximo exemplo: <a href="reading-files">Reading Files</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Channel Buffering</title> <title>Go Em Exemplos: Channel Buffering</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -46,7 +46,7 @@ those values.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/3BRCdRnRszb"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/3BRCdRnRszb"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -139,12 +139,12 @@ concurrent receive.</p>
<p class="next"> <p class="next">
Next example: <a href="channel-synchronization">Channel Synchronization</a>. Próximo exemplo: <a href="channel-synchronization">Channel Synchronization</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Channel Directions</title> <title>Go Em Exemplos: Channel Directions</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ the program.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/mjNJDHwUH4R"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/mjNJDHwUH4R"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -131,12 +131,12 @@ receive on this channel.</p>
<p class="next"> <p class="next">
Next example: <a href="select">Select</a>. Próximo exemplo: <a href="select">Select</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Channel Synchronization</title> <title>Go Em Exemplos: Channel Synchronization</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -45,7 +45,7 @@ you may prefer to use a <a href="waitgroups">WaitGroup</a>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/Nw-1DzIGk5f"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/Nw-1DzIGk5f"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -170,12 +170,12 @@ started.</p>
<p class="next"> <p class="next">
Next example: <a href="channel-directions">Channel Directions</a>. Próximo exemplo: <a href="channel-directions">Channel Directions</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/channels generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Channels</title> <title>Go Em Exemplos: Channels</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ goroutine.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/MaLY7AiAkHM"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/MaLY7AiAkHM"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -155,12 +155,12 @@ message without having to use any other synchronization.</p>
<p class="next"> <p class="next">
Next example: <a href="channel-buffering">Channel Buffering</a>. Próximo exemplo: <a href="channel-buffering">Channel Buffering</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Closing Channels</title> <title>Go Em Exemplos: Closing Channels</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -43,7 +43,7 @@ completion to the channel&rsquo;s receivers.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/vCvRjcMq7p3"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/vCvRjcMq7p3"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -181,12 +181,12 @@ example: <code>range</code> over channels.</p>
<p class="next"> <p class="next">
Next example: <a href="range-over-channels">Range over Channels</a>. Próximo exemplo: <a href="range-over-channels">Range over Channels</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

45
public/closures generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Closures</title> <title>Go Em Exemplos: Closures</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -27,10 +27,11 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Go supports <a href="https://en.wikipedia.org/wiki/Anonymous_function"><em>anonymous functions</em></a>, <p>Go suporta <a href="https://en.wikipedia.org/wiki/Anonymous_function"><em>funções anônimas</em></a>,
which can form <a href="https://en.wikipedia.org/wiki/Closure_(computer_science)"><em>closures</em></a>. as quais podem formar
Anonymous functions are useful when you want to define <a href="https://pt.wikipedia.org/wiki/Clausura_(ci%C3%AAncia_da_computa%C3%A7%C3%A3o)"><em>closures</em></a>.
a function inline without having to name it.</p> Funções anônimas são úteis quando se pretende
definir a função em linha sem ser necessário nomeá-la.</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -44,7 +45,7 @@ a function inline without having to name it.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/NpgpzS8ZG8y"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/i-JqAhb-yJ1"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -63,10 +64,10 @@ a function inline without having to name it.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>This function <code>intSeq</code> returns another function, which <p>Esta função <code>intSeq</code> retorna outra função, que é
we define anonymously in the body of <code>intSeq</code>. The definida anonimamente no corpo de <code>intSeq</code>. A função
returned function <em>closes over</em> the variable <code>i</code> to retornada <em>fecha sobre</em> (<em>closes over</em>) a variavel
form a closure.</p> <code>i</code> para formar um fechamento (closure).</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -96,10 +97,10 @@ form a closure.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>We call <code>intSeq</code>, assigning the result (a function) <p>Aqui, a execução da função <code>intSeq</code> (que retorna outra
to <code>nextInt</code>. This function value captures its função) é atribuída à variável <code>nextInt</code>.
own <code>i</code> value, which will be updated each time Esta função captura o próprio valor de <code>i</code>, que
we call <code>nextInt</code>.</p> será atualizado a cada vez que é chamada <code>nextInt</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -112,8 +113,8 @@ we call <code>nextInt</code>.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>See the effect of the closure by calling <code>nextInt</code> <p>Veja o efeito do closure chamando <code>nextInt</code>
a few times.</p> algumas vezes.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -128,8 +129,8 @@ a few times.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>To confirm that the state is unique to that <p>Para confirmar que o estado é único àquela variável
particular function, create and test a new one.</p> específica, ao criar outra e testar, o resultado é diverso.</p>
</td> </td>
<td class="code"> <td class="code">
@ -162,8 +163,8 @@ particular function, create and test a new one.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>The last feature of functions we&rsquo;ll look at for now is <p>O último recurso de funções a ser apresentado
recursion.</p> é a recursão.</p>
</td> </td>
<td class="code empty"> <td class="code empty">
@ -176,12 +177,12 @@ recursion.</p>
<p class="next"> <p class="next">
Next example: <a href="recursion">Recursion</a>. Próximo exemplo: <a href="recursion">Recursion</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Command-Line Arguments</title> <title>Go Em Exemplos: Command-Line Arguments</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ For example, <code>go run hello.go</code> uses <code>run</code> and
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/UYCEvh9d2Zb"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/UYCEvh9d2Zb"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -156,12 +156,12 @@ with flags.</p>
<p class="next"> <p class="next">
Next example: <a href="command-line-flags">Command-Line Flags</a>. Próximo exemplo: <a href="command-line-flags">Command-Line Flags</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Command-Line Flags</title> <title>Go Em Exemplos: Command-Line Flags</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ command-line flag.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/IUPZlYSigc3"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/IUPZlYSigc3"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -292,12 +292,12 @@ and show the help text again.</p>
<p class="next"> <p class="next">
Next example: <a href="command-line-subcommands">Command-Line Subcommands</a>. Próximo exemplo: <a href="command-line-subcommands">Command-Line Subcommands</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Command-Line Subcommands</title> <title>Go Em Exemplos: Command-Line Subcommands</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -46,7 +46,7 @@ subcommands that have their own flags.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/DkvdHKK-XCv"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/DkvdHKK-XCv"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -246,12 +246,12 @@ way to parameterize programs.</p>
<p class="next"> <p class="next">
Next example: <a href="environment-variables">Environment Variables</a>. Próximo exemplo: <a href="environment-variables">Environment Variables</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

35
public/constants generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Constants</title> <title>Go Em Exemplos: Constants</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -27,8 +27,8 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Go supports <em>constants</em> of character, string, boolean, <p>Go suporta <em>constantes</em> de tipos strings, booleanos,
and numeric values.</p> e numericos.</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -42,7 +42,7 @@ and numeric values.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/Vw-pXSfo9_b"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/NA0z_34sqzx"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -64,7 +64,7 @@ and numeric values.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p><code>const</code> declares a constant value.</p> <p><code>const</code> é a palavra reservada para declarar uma constante.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -89,8 +89,8 @@ and numeric values.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>A <code>const</code> statement can appear anywhere a <code>var</code> <p>A declaração <code>const</code> pode aparecer em qualquer
statement can.</p> lugar que a declaração <code>var</code> também possa.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -103,8 +103,8 @@ statement can.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Constant expressions perform arithmetic with <p>Expressões com constantes são performadas
arbitrary precision.</p> aritmeticamente com precisão arbitrária.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -118,8 +118,8 @@ arbitrary precision.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>A numeric constant has no type until it&rsquo;s given <p>Uma constante numérica não possui um tipo
one, such as by an explicit conversion.</p> até que seja atribuído um, como uma conversão explícita.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -132,10 +132,11 @@ one, such as by an explicit conversion.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>A number can be given a type by using it in a <p>Um tipo pode ser implicitamente atribuído a uma constante
context that requires one, such as a variable numérica ao usá-la num contexto que requer um tipo,
assignment or function call. For example, here como atribuição a uma variável ou uma chamada de função.
<code>math.Sin</code> expects a <code>float64</code>.</p> Por exemplo, a função <code>math.Sin</code> espera um valor de tipo
<code>float64</code>.</p>
</td> </td>
<td class="code"> <td class="code">
@ -169,12 +170,12 @@ assignment or function call. For example, here
<p class="next"> <p class="next">
Next example: <a href="for">For</a>. Próximo exemplo: <a href="for">For</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

10
public/context generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Context</title> <title>Go Em Exemplos: Context</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -14,7 +14,7 @@
if (e.key == "ArrowRight") { if (e.key == "ArrowRight") {
window.location.href = 'spawning-processes'; window.location.href = 'spawning-processes-(invocando-processos)';
} }
} }
@ -36,7 +36,7 @@ across API boundaries and goroutines.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/0_bu1o8rIBO"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/0_bu1o8rIBO"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"> <pre class="chroma">
<span class="kn">package</span> <span class="nx">main</span> <span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
@ -191,12 +191,12 @@ cancellation.</p>
<p class="next"> <p class="next">
Next example: <a href="spawning-processes">Spawning Processes</a>. Próximo exemplo: <a href="spawning-processes-(invocando-processos)">Spawning Processes (Invocando processos)</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/defer generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Defer</title> <title>Go Em Exemplos: Defer</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ purposes of cleanup. <code>defer</code> is often used where e.g.
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/5SDVfc_jxbg"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/5SDVfc_jxbg"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -195,12 +195,12 @@ after being written.</p>
<p class="next"> <p class="next">
Next example: <a href="recover">Recover</a>. Próximo exemplo: <a href="recover">Recover</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/directories generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Directories</title> <title>Go Em Exemplos: Directories</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -42,7 +42,7 @@
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/cICbVSX51zI"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/cICbVSX51zI"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -333,12 +333,12 @@ recursively by <code>filepath.Walk</code>.</p>
<p class="next"> <p class="next">
Next example: <a href="temporary-files-and-directories">Temporary Files and Directories</a>. Próximo exemplo: <a href="temporary-files-and-directories">Temporary Files and Directories</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Embed Directive</title> <title>Go Em Exemplos: Embed Directive</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -35,7 +35,7 @@ build time. Read more about the embed directive
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/6m2ll-D52BB"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/6m2ll-D52BB"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"> <pre class="chroma">
<span class="kn">package</span> <span class="nx">main</span> <span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
@ -196,12 +196,12 @@ this example can only be run on your local machine.)</p>
<p class="next"> <p class="next">
Next example: <a href="testing-and-benchmarking">Testing and Benchmarking</a>. Próximo exemplo: <a href="testing-and-benchmarking">Testing and Benchmarking</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Environment Variables</title> <title>Go Em Exemplos: Environment Variables</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ Let&rsquo;s look at how to set, get, and list environment variables.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/2jmwXM264NC"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/2jmwXM264NC"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -172,12 +172,12 @@ program picks that value up.</p>
<p class="next"> <p class="next">
Next example: <a href="http-client">HTTP Client</a>. Próximo exemplo: <a href="http-client">HTTP Client</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/epoch generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Epoch</title> <title>Go Em Exemplos: Epoch</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ Here&rsquo;s how to do it in Go.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/lRmD1EWHHPz"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/lRmD1EWHHPz"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -156,12 +156,12 @@ parsing and formatting.</p>
<p class="next"> <p class="next">
Next example: <a href="time-formatting-parsing">Time Formatting / Parsing</a>. Próximo exemplo: <a href="time-formatting-parsing">Time Formatting / Parsing</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/errors generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Errors</title> <title>Go Em Exemplos: Errors</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -48,7 +48,7 @@ non-error tasks.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/NiJOpCPO3L0"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/NiJOpCPO3L0"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -282,12 +282,12 @@ on the Go blog for more on error handling.</p>
<p class="next"> <p class="next">
Next example: <a href="goroutines">Goroutines</a>. Próximo exemplo: <a href="goroutines">Goroutines</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -9,7 +9,7 @@
onkeydown = (e) => { onkeydown = (e) => {
if (e.key == "ArrowLeft") { if (e.key == "ArrowLeft") {
window.location.href = 'spawning-processes'; window.location.href = 'spawning-processes-(invocando-processos)';
} }
@ -195,7 +195,7 @@ processes covers most use cases for <code>fork</code>.</p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | translated by <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a>
</p> </p>
</div> </div>

6
public/exit generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Exit</title> <title>Go Em Exemplos: Exit</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -38,7 +38,7 @@ status.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/b9aYzlENkb__R"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/b9aYzlENkb__R"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -161,7 +161,7 @@ the status in the terminal.</p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/file-paths generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: File Paths</title> <title>Go Em Exemplos: File Paths</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -34,7 +34,7 @@ between operating systems; <code>dir/file</code> on Linux vs.
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/5h3lUytvmyO"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/5h3lUytvmyO"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"> <pre class="chroma">
<span class="kn">package</span> <span class="nx">main</span> <span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
@ -235,12 +235,12 @@ be made relative to base.</p>
<p class="next"> <p class="next">
Next example: <a href="directories">Directories</a>. Próximo exemplo: <a href="directories">Directories</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

32
public/for generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: For</title> <title>Go Em Exemplos: For</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -27,8 +27,8 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p><code>for</code> is Go&rsquo;s only looping construct. Here are <p><code>for</code> é a única ferramenta de repetição em Go.
some basic types of <code>for</code> loops.</p> Aqui estão algumas formas básicas de utilização.</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -42,7 +42,7 @@ some basic types of <code>for</code> loops.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/2-4H-ArwHHS"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/ilDqCUXz1gQ"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -72,7 +72,7 @@ some basic types of <code>for</code> loops.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>The most basic type, with a single condition.</p> <p>O tipo mais simples com apenas uma condição.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -89,7 +89,8 @@ some basic types of <code>for</code> loops.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>A classic initial/condition/after <code>for</code> loop.</p> <p>O tipo clássico com inicial, condição
de continuação e pós iteração.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -104,9 +105,8 @@ some basic types of <code>for</code> loops.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p><code>for</code> without a condition will loop repeatedly <p><code>for</code> sem nenhuma condição será repetido indefinidamente,
until you <code>break</code> out of the loop or <code>return</code> from até que <code>break</code> ou <code>return</code> sejam usados para interromper.</p>
the enclosing function.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -122,8 +122,8 @@ the enclosing function.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>You can also <code>continue</code> to the next iteration of <p>Também é possível utilizar o comando <code>continue</code>
the loop.</p> para prosseguir para a próxima iteração do loop.</p>
</td> </td>
<td class="code"> <td class="code">
@ -166,9 +166,9 @@ the loop.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>We&rsquo;ll see some other <code>for</code> forms later when we look at <p>Algumas outras formas de utilizar o <code>for</code> serão
<code>range</code> statements, channels, and other data mencionados na declarações <code>range</code>; e em outras
structures.</p> estruturas como channels.</p>
</td> </td>
<td class="code empty"> <td class="code empty">
@ -181,12 +181,12 @@ structures.</p>
<p class="next"> <p class="next">
Next example: <a href="if-else">If/Else</a>. Próximo exemplo: <a href="if-else">If/Else</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

37
public/functions generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Functions</title> <title>Go Em Exemplos: Functions</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -27,8 +27,8 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p><em>Functions</em> are central in Go. We&rsquo;ll learn about <p><em>Functions</em> são centrais em Go. Serão demonstradas
functions with a few different examples.</p> funções com alguns exemplos diferentes.</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -42,7 +42,7 @@ functions with a few different examples.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/-o49-dQfGbK"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/D8sGhZBD4Ai"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -61,8 +61,7 @@ functions with a few different examples.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Here&rsquo;s a function that takes two <code>int</code>s and returns <p>Aqui está uma função que recebe dois inteiros <code>int</code> e retorna a soma de ambos como outro inteiro <code>int</code>.</p>
their sum as an <code>int</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -75,9 +74,9 @@ their sum as an <code>int</code>.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Go requires explicit returns, i.e. it won&rsquo;t <p>Go exige retornos explícitos. Por exemplo,
automatically return the value of the last não será retornado automaticamente o valor
expression.</p> da última expressão</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -91,10 +90,9 @@ expression.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>When you have multiple consecutive parameters of <p>Ao existir multiplos parâmetros consecutivos de um
the same type, you may omit the type name for the mesmo tipo, é possível omitir o tipo dos parâmetros
like-typed parameters up to the final parameter that até a declaração do último parâmetro daquele tipo.</p>
declares the type.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -120,8 +118,8 @@ declares the type.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Call a function just as you&rsquo;d expect, with <p>Para executar uma função é utilizada a
<code>name(args)</code>.</p> sintaxe <code>nomeDaFuncao(argumentos)</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -164,8 +162,9 @@ declares the type.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>There are several other features to Go functions. One is <p>Existem muitos outros recursos em Funções,
multiple return values, which we&rsquo;ll look at next.</p> um dos quais é chamado de Retorno de Valores
Múltiplos que será apresentado no próximo exemplo.</p>
</td> </td>
<td class="code empty"> <td class="code empty">
@ -178,12 +177,12 @@ multiple return values, which we&rsquo;ll look at next.</p>
<p class="next"> <p class="next">
Next example: <a href="multiple-return-values">Multiple Return Values</a>. Próximo exemplo: <a href="multiple-return-values">Multiple Return Values</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/generics generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Generics</title> <title>Go Em Exemplos: Generics</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -42,7 +42,7 @@
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/uXlb-AyeYmQ"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/uXlb-AyeYmQ"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -233,12 +233,12 @@ automatically.</p>
<p class="next"> <p class="next">
Next example: <a href="errors">Errors</a>. Próximo exemplo: <a href="errors">Errors</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/goroutines generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Goroutines</title> <title>Go Em Exemplos: Goroutines</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -41,7 +41,7 @@
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/I7scqRijEJt"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/I7scqRijEJt"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -194,12 +194,12 @@ concurrent Go programs: channels.</p>
<p class="next"> <p class="next">
Next example: <a href="channels">Channels</a>. Próximo exemplo: <a href="channels">Channels</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

28
public/hello-world generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Hello World</title> <title>Go Em Exemplos: Hello World</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -23,12 +23,12 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Our first program will print the classic &ldquo;hello world&rdquo; <p>O nosso primeiro programa exibirá a mensagem &ldquo;hello world&rdquo;.
message. Here&rsquo;s the full source code.</p> Aqui está o código completo.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/NeviD0awXjt"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/kj7TRRdvOse"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"> <pre class="chroma">
<span class="kn">package</span> <span class="nx">main</span> <span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
@ -65,8 +65,9 @@ message. Here&rsquo;s the full source code.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>To run the program, put the code in <code>hello-world.go</code> and <p>Para rodar o programa, insira o código no arquivo
use <code>go run</code>.</p> <code>hello-world.go</code> e em seguida, execute o comando
<code>go run</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -79,8 +80,8 @@ use <code>go run</code>.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Sometimes we&rsquo;ll want to build our programs into <p>Por vezes é útil ter nossos programas em binário.
binaries. We can do this using <code>go build</code>.</p> É possível fazer isso por meio do comando <code>go build</code></p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -94,7 +95,8 @@ binaries. We can do this using <code>go build</code>.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>We can then execute the built binary directly.</p> <p>É possível, então, executar diretamente o binário
gerado.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -107,8 +109,8 @@ binaries. We can do this using <code>go build</code>.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Now that we can run and build basic Go programs, let&rsquo;s <p>Agora que conseguimos executar e gerar programas
learn more about the language.</p> em Go, vamos aprender mais sobre a linguagem.</p>
</td> </td>
<td class="code empty"> <td class="code empty">
@ -121,12 +123,12 @@ learn more about the language.</p>
<p class="next"> <p class="next">
Next example: <a href="values">Values</a>. Próximo exemplo: <a href="values">Values</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/http-client generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: HTTP Client</title> <title>Go Em Exemplos: HTTP Client</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -34,7 +34,7 @@ HTTP requests.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/vFW_el7oHMk"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/vFW_el7oHMk"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"> <pre class="chroma">
<span class="kn">package</span> <span class="nx">main</span> <span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
@ -155,12 +155,12 @@ settings.</p>
<p class="next"> <p class="next">
Next example: <a href="http-server">HTTP Server</a>. Próximo exemplo: <a href="http-server">HTTP Server</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/http-server generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: HTTP Server</title> <title>Go Em Exemplos: HTTP Server</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -32,7 +32,7 @@
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/s3xMMt9Ytry"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/s3xMMt9Ytry"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"> <pre class="chroma">
<span class="kn">package</span> <span class="nx">main</span> <span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
@ -196,12 +196,12 @@ router we&rsquo;ve just set up.</p>
<p class="next"> <p class="next">
Next example: <a href="context">Context</a>. Próximo exemplo: <a href="context">Context</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

52
public/if-else generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: If/Else</title> <title>Go Em Exemplos: If/Else</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -27,8 +27,7 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Branching with <code>if</code> and <code>else</code> in Go is <p>A condicional <code>if</code> e <code>else</code> em Go é bem direta.</p>
straight-forward.</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -42,7 +41,7 @@ straight-forward.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/U7xcpdutgCJ"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/1I2JHAXgr-3"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -72,16 +71,16 @@ straight-forward.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Here&rsquo;s a basic example.</p> <p>Aqui está um exemplo básico.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="k">if</span> <span class="mi">7</span><span class="o">%</span><span class="mi">2</span> <span class="o">==</span> <span class="mi">0</span> <span class="p">{</span> <span class="k">if</span> <span class="mi">7</span><span class="o">%</span><span class="mi">2</span> <span class="o">==</span> <span class="mi">0</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;7 is even&#34;</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;7 é par&#34;</span><span class="p">)</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;7 is odd&#34;</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;7 é ímpar&#34;</span><span class="p">)</span>
<span class="p">}</span> <span class="p">}</span>
</pre> </pre>
</td> </td>
@ -89,14 +88,14 @@ straight-forward.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>You can have an <code>if</code> statement without an else.</p> <p>Também é possível utilizar o <code>if</code> sem <code>else</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="k">if</span> <span class="mi">8</span><span class="o">%</span><span class="mi">4</span> <span class="o">==</span> <span class="mi">0</span> <span class="p">{</span> <span class="k">if</span> <span class="mi">8</span><span class="o">%</span><span class="mi">4</span> <span class="o">==</span> <span class="mi">0</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;8 is divisible by 4&#34;</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;8 é divisível por 4&#34;</span><span class="p">)</span>
<span class="p">}</span> <span class="p">}</span>
</pre> </pre>
</td> </td>
@ -104,20 +103,20 @@ straight-forward.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>A statement can precede conditionals; any variables <p>Declarações podem preceder as condições; qualquer
declared in this statement are available in the current variável declarada na estrutura condicional ficará
and all subsequent branches.</p> disponível em todas as suas ramificações.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="k">if</span> <span class="nx">num</span> <span class="o">:=</span> <span class="mi">9</span><span class="p">;</span> <span class="nx">num</span> <span class="p">&lt;</span> <span class="mi">0</span> <span class="p">{</span> <span class="k">if</span> <span class="nx">num</span> <span class="o">:=</span> <span class="mi">9</span><span class="p">;</span> <span class="nx">num</span> <span class="p">&lt;</span> <span class="mi">0</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">num</span><span class="p">,</span> <span class="s">&#34;is negative&#34;</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">num</span><span class="p">,</span> <span class="s">&#34;é negativo&#34;</span><span class="p">)</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="nx">num</span> <span class="p">&lt;</span> <span class="mi">10</span> <span class="p">{</span> <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="nx">num</span> <span class="p">&lt;</span> <span class="mi">10</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">num</span><span class="p">,</span> <span class="s">&#34;has 1 digit&#34;</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">num</span><span class="p">,</span> <span class="s">&#34;possui 1 dígito&#34;</span><span class="p">)</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">num</span><span class="p">,</span> <span class="s">&#34;has multiple digits&#34;</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">num</span><span class="p">,</span> <span class="s">&#34;possui múltiplos dígitos&#34;</span><span class="p">)</span>
<span class="p">}</span> <span class="p">}</span>
<span class="p">}</span> <span class="p">}</span>
</pre> </pre>
@ -126,8 +125,9 @@ and all subsequent branches.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Note that you don&rsquo;t need parentheses around conditions <p>É importante lembrar que não é necessário envelopar
in Go, but that the braces are required.</p> condicionais com parenteses em Go, no entanto,
as chaves {} são necessárias.</p>
</td> </td>
<td class="code empty"> <td class="code empty">
@ -147,17 +147,17 @@ in Go, but that the braces are required.</p>
<td class="code leading"> <td class="code leading">
<pre class="chroma"><span class="gp">$</span> go run if-else.go <pre class="chroma"><span class="gp">$</span> go run if-else.go
<span class="go">7 is odd <span class="go">7 é ímpar
</span><span class="go">8 is divisible by 4 </span><span class="go">8 é divisível por 4
</span><span class="go">9 has 1 digit</span></pre> </span><span class="go">9 possui 1 dígito</span></pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>There is no <a href="https://en.wikipedia.org/wiki/%3F:">ternary if</a> <p>Não há <a href="https://en.wikipedia.org/wiki/%3F:">operador ternário</a>
in Go, so you&rsquo;ll need to use a full <code>if</code> statement even em Go, então é necessário utilizar <code>if</code>
for basic conditions.</p> mesmo para condições básicas.</p>
</td> </td>
<td class="code empty"> <td class="code empty">
@ -170,18 +170,18 @@ for basic conditions.</p>
<p class="next"> <p class="next">
Next example: <a href="switch">Switch</a>. Próximo exemplo: <a href="switch">Switch</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>
<script> <script>
var codeLines = []; var codeLines = [];
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' if 7%2 \u003D\u003D 0 {\u000A fmt.Println(\"7 is even\")\u000A } else {\u000A fmt.Println(\"7 is odd\")\u000A }\u000A');codeLines.push(' if 8%4 \u003D\u003D 0 {\u000A fmt.Println(\"8 is divisible by 4\")\u000A }\u000A');codeLines.push(' if num :\u003D 9; num \u003C 0 {\u000A fmt.Println(num, \"is negative\")\u000A } else if num \u003C 10 {\u000A fmt.Println(num, \"has 1 digit\")\u000A } else {\u000A fmt.Println(num, \"has multiple digits\")\u000A }\u000A}\u000A');codeLines.push('');codeLines.push('');codeLines.push(''); codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' if 7%2 \u003D\u003D 0 {\u000A fmt.Println(\"7 é par\")\u000A } else {\u000A fmt.Println(\"7 é ímpar\")\u000A }\u000A');codeLines.push(' if 8%4 \u003D\u003D 0 {\u000A fmt.Println(\"8 é divisível por 4\")\u000A }\u000A');codeLines.push(' if num :\u003D 9; num \u003C 0 {\u000A fmt.Println(num, \"é negativo\")\u000A } else if num \u003C 10 {\u000A fmt.Println(num, \"possui 1 dígito\")\u000A } else {\u000A fmt.Println(num, \"possui múltiplos dígitos\")\u000A }\u000A}\u000A');codeLines.push('');codeLines.push('');codeLines.push('');
</script> </script>
<script src="site.js" async></script> <script src="site.js" async></script>
</body> </body>

32
public/index.html generated
View File

@ -2,27 +2,27 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example</title> <title>Go Em Exemplos</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<body> <body>
<div id="intro"> <div id="intro">
<h2><a href="./">Go by Example</a></h2> <h2><a href="./">Go Em Exemplos</a></h2>
<p> <p>
<a href="https://go.dev">Go</a> is an <a href="https://go.dev">Go</a> é uma
open source programming language designed for linguagem de programação de código aberto construída para
building simple, fast, and reliable software. gerar softwares simples, rápidos e confiáveis.
Please read the official Leia a
<a href="https://go.dev/doc/tutorial/getting-started">documentation</a> <a href="https://go.dev/doc/tutorial/getting-started">documentação oficial</a>
to learn a bit about Go code, tools packages, para aprender mais sobre Go, suas ferramentas, pacotes
and modules. e módulos.
</p> </p>
<p> <p>
<em>Go by Example</em> is a hands-on introduction <em>Go by Example</em> é uma intrudução prática
to Go using annotated example programs. Check out ao Go que utiliza exemplos de programas comentados.
the <a href="hello-world">first example</a> or Confira o <a href="hello-world">primeiro exemplo</a> ou
browse the full list below. visualize a lista completa a seguir.
</p> </p>
<ul> <ul>
@ -179,9 +179,9 @@
<li><a href="context">Context</a></li> <li><a href="context">Context</a></li>
<li><a href="spawning-processes">Spawning Processes</a></li> <li><a href="spawning-processes-(invocando-processos)">Spawning Processes (Invocando processos)</a></li>
<li><a href="execing-processes">Exec'ing Processes</a></li> <li><a href="executing-processes">Executing Processes</a></li>
<li><a href="signals">Signals</a></li> <li><a href="signals">Signals</a></li>
@ -190,7 +190,7 @@
</ul> </ul>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/interfaces generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Interfaces</title> <title>Go Em Exemplos: Interfaces</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -42,7 +42,7 @@ signatures.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/XJASG4MxBQr"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/XJASG4MxBQr"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -222,12 +222,12 @@ these structs as arguments to <code>measure</code>.</p>
<p class="next"> <p class="next">
Next example: <a href="struct-embedding">Struct Embedding</a>. Próximo exemplo: <a href="struct-embedding">Struct Embedding</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/json generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: JSON</title> <title>Go Em Exemplos: JSON</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -43,7 +43,7 @@ data types.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/JOQpRGJWAxR"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/JOQpRGJWAxR"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -398,12 +398,12 @@ for more.</p>
<p class="next"> <p class="next">
Next example: <a href="xml">XML</a>. Próximo exemplo: <a href="xml">XML</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/line-filters generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Line Filters</title> <title>Go Em Exemplos: Line Filters</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -47,7 +47,7 @@ pattern to write your own Go line filters.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/kNcupWRsYPP"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/kNcupWRsYPP"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"> <pre class="chroma">
<span class="kn">package</span> <span class="nx">main</span> <span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
@ -189,12 +189,12 @@ lowercase lines.</p>
<p class="next"> <p class="next">
Next example: <a href="file-paths">File Paths</a>. Próximo exemplo: <a href="file-paths">File Paths</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

81
public/maps generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Maps</title> <title>Go Em Exemplos: Maps</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -27,8 +27,9 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p><em>Maps</em> are Go&rsquo;s built-in <a href="https://en.wikipedia.org/wiki/Associative_array">associative data type</a> <p><em>Maps</em> é o <a href="https://pt.wikipedia.org/wiki/Vetor_associativo">vetor associativo</a>
(sometimes called <em>hashes</em> or <em>dicts</em> in other languages).</p> nativo de Go.
(também chamado de <em>hashes</em> ou <em>dicts</em> em outras linguagens).</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -42,7 +43,7 @@
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/ulCzODwCde_0"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/Z1XbrBn9vsr"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -72,8 +73,8 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p>To create an empty map, use the builtin <code>make</code>: <p>Para criar um map vazio, utilize o comando nativo <code>make</code>:
<code>make(map[key-type]val-type)</code>.</p> <code>make(map[tipoDaChave]tipoDoValor)</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -86,8 +87,8 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Set key/value pairs using typical <code>name[key] = val</code> <p>É possível alterar ou criar pares de chave/valor
syntax.</p> usando a sintaxe <code>nomeDoMap[chave] = valor</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -101,36 +102,37 @@ syntax.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Printing a map with e.g. <code>fmt.Println</code> will show all of <p>Ao imprimir um map com <code>fmt.Println</code>, por exemplo,
its key/value pairs.</p> serão exibidos todos os pares chave/valor.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;map:&#34;</span><span class="p">,</span> <span class="nx">m</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;mapa:&#34;</span><span class="p">,</span> <span class="nx">m</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Get a value for a key with <code>name[key]</code>.</p> <p>Para selecionar o valor de determinada chave,
usa-se o comando <code>nomeDoMap[chave]</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nx">v1</span> <span class="o">:=</span> <span class="nx">m</span><span class="p">[</span><span class="s">&#34;k1&#34;</span><span class="p">]</span> <span class="nx">v1</span> <span class="o">:=</span> <span class="nx">m</span><span class="p">[</span><span class="s">&#34;k1&#34;</span><span class="p">]</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;v1: &#34;</span><span class="p">,</span> <span class="nx">v1</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;valor 1: &#34;</span><span class="p">,</span> <span class="nx">v1</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>The builtin <code>len</code> returns the number of key/value <p>O comando nativo <code>len</code>, recebendo um mapa como
pairs when called on a map.</p> argumento, retorna o número de pares chave/valor.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -143,50 +145,51 @@ pairs when called on a map.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>The builtin <code>delete</code> removes key/value pairs from <p>O comando nativo <code>delete</code> remove um determinado
a map.</p> par de chave/valor do mapa.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nb">delete</span><span class="p">(</span><span class="nx">m</span><span class="p">,</span> <span class="s">&#34;k2&#34;</span><span class="p">)</span> <span class="nb">delete</span><span class="p">(</span><span class="nx">m</span><span class="p">,</span> <span class="s">&#34;k2&#34;</span><span class="p">)</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;map:&#34;</span><span class="p">,</span> <span class="nx">m</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;mapa:&#34;</span><span class="p">,</span> <span class="nx">m</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>The optional second return value when getting a <p>Ao selecionar um determinado valor em um mapa,
value from a map indicates if the key was present existe um segundo retorno opcional, do tipo booleano,
in the map. This can be used to disambiguate que indica a presença ou ausência de um determinado
between missing keys and keys with zero values par no map. Isto pode ser utilizado para desambiguação
like <code>0</code> or <code>&quot;&quot;</code>. Here we didn&rsquo;t need the value entre chaves ausentes e chaves com valor zero, como
itself, so we ignored it with the <em>blank identifier</em> <code>0</code> or <code>&quot;&quot;</code>. Onde o valor correspondente à chave não
<code>_</code>.</p> for necessário, é possível ignorar com um identificador
vazio <code>_</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nx">_</span><span class="p">,</span> <span class="nx">prs</span> <span class="o">:=</span> <span class="nx">m</span><span class="p">[</span><span class="s">&#34;k2&#34;</span><span class="p">]</span> <span class="nx">_</span><span class="p">,</span> <span class="nx">prs</span> <span class="o">:=</span> <span class="nx">m</span><span class="p">[</span><span class="s">&#34;k2&#34;</span><span class="p">]</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;prs:&#34;</span><span class="p">,</span> <span class="nx">prs</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;presença da chave:&#34;</span><span class="p">,</span> <span class="nx">prs</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>You can also declare and initialize a new map in <p>Também é possível declarar e inicializar um
the same line with this syntax.</p> novo mapa na mesma linha com a sintaxe a seguir.</p>
</td> </td>
<td class="code"> <td class="code">
<pre class="chroma"> <pre class="chroma">
<span class="nx">n</span> <span class="o">:=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kt">int</span><span class="p">{</span><span class="s">&#34;foo&#34;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s">&#34;bar&#34;</span><span class="p">:</span> <span class="mi">2</span><span class="p">}</span> <span class="nx">n</span> <span class="o">:=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kt">int</span><span class="p">{</span><span class="s">&#34;foo&#34;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s">&#34;bar&#34;</span><span class="p">:</span> <span class="mi">2</span><span class="p">}</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;map:&#34;</span><span class="p">,</span> <span class="nx">n</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;mapa:&#34;</span><span class="p">,</span> <span class="nx">n</span><span class="p">)</span>
<span class="p">}</span> <span class="p">}</span>
</pre> </pre>
</td> </td>
@ -198,20 +201,20 @@ the same line with this syntax.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Note that maps appear in the form <code>map[k:v k:v]</code> when <p>Note que os mapas são exibidos na forma <code>map[k:v k:v]</code>
printed with <code>fmt.Println</code>.</p> quando impressos com <code>fmt.Println</code>.</p>
</td> </td>
<td class="code"> <td class="code">
<pre class="chroma"> <pre class="chroma">
<span class="gp">$</span> go run maps.go <span class="gp">$</span> go run maps.go
<span class="go">map: map[k1:7 k2:13] <span class="go">mapa: map[k1:7 k2:13]
</span><span class="go">v1: 7 </span><span class="go">valor 1: 7
</span><span class="go">len: 2 </span><span class="go">len: 2
</span><span class="go">map: map[k1:7] </span><span class="go">mapa: map[k1:7]
</span><span class="go">prs: false </span><span class="go">presença da chave: false
</span><span class="go">map: map[bar:2 foo:1]</span></pre> </span><span class="go">mapa: map[bar:2 foo:1]</span></pre>
</td> </td>
</tr> </tr>
@ -219,18 +222,18 @@ printed with <code>fmt.Println</code>.</p>
<p class="next"> <p class="next">
Next example: <a href="range">Range</a>. Próximo exemplo: <a href="range">Range</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>
<script> <script>
var codeLines = []; var codeLines = [];
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' m :\u003D make(map[string]int)\u000A');codeLines.push(' m[\"k1\"] \u003D 7\u000A m[\"k2\"] \u003D 13\u000A');codeLines.push(' fmt.Println(\"map:\", m)\u000A');codeLines.push(' v1 :\u003D m[\"k1\"]\u000A fmt.Println(\"v1: \", v1)\u000A');codeLines.push(' fmt.Println(\"len:\", len(m))\u000A');codeLines.push(' delete(m, \"k2\")\u000A fmt.Println(\"map:\", m)\u000A');codeLines.push(' _, prs :\u003D m[\"k2\"]\u000A fmt.Println(\"prs:\", prs)\u000A');codeLines.push(' n :\u003D map[string]int{\"foo\": 1, \"bar\": 2}\u000A fmt.Println(\"map:\", n)\u000A}\u000A');codeLines.push(''); codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' m :\u003D make(map[string]int)\u000A');codeLines.push(' m[\"k1\"] \u003D 7\u000A m[\"k2\"] \u003D 13\u000A');codeLines.push(' fmt.Println(\"mapa:\", m)\u000A');codeLines.push(' v1 :\u003D m[\"k1\"]\u000A fmt.Println(\"valor 1: \", v1)\u000A');codeLines.push(' fmt.Println(\"len:\", len(m))\u000A');codeLines.push(' delete(m, \"k2\")\u000A fmt.Println(\"mapa:\", m)\u000A');codeLines.push(' _, prs :\u003D m[\"k2\"]\u000A fmt.Println(\"presença da chave:\", prs)\u000A');codeLines.push(' n :\u003D map[string]int{\"foo\": 1, \"bar\": 2}\u000A fmt.Println(\"mapa:\", n)\u000A}\u000A');codeLines.push('');
</script> </script>
<script src="site.js" async></script> <script src="site.js" async></script>
</body> </body>

8
public/methods generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Methods</title> <title>Go Em Exemplos: Methods</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -41,7 +41,7 @@
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/4wmDCAydC1e"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/4wmDCAydC1e"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -182,12 +182,12 @@ naming related sets of methods: interfaces.</p>
<p class="next"> <p class="next">
Next example: <a href="interfaces">Interfaces</a>. Próximo exemplo: <a href="interfaces">Interfaces</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Multiple Return Values</title> <title>Go Em Exemplos: Multiple Return Values</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -27,9 +27,10 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Go has built-in support for <em>multiple return values</em>. <p>Go tem suporte nativo para <em>múltiplos valores de retorno</em>.
This feature is used often in idiomatic Go, for example Esse recurso é utilizado frequentemente
to return both result and error values from a function.</p> em Go idiomático, por exemplo, para retornar
valores de resultado e de erro de uma função.</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -43,7 +44,7 @@ to return both result and error values from a function.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/vZdUvLB1WbK"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/7kvvjKA16K7"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -62,8 +63,8 @@ to return both result and error values from a function.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>The <code>(int, int)</code> in this function signature shows that <p>A expressão <code>(int, int)</code> na assinatura desta função
the function returns 2 <code>int</code>s.</p> demonstra que a função retorna dois inteiros <code>int</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -89,8 +90,8 @@ the function returns 2 <code>int</code>s.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Here we use the 2 different return values from the <p>Aqui são utilizados ambos valores retornados
call with <em>multiple assignment</em>.</p> da função com <em>atribuição múltipla</em>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -105,8 +106,8 @@ call with <em>multiple assignment</em>.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>If you only want a subset of the returned values, <p>Para utilizar apenas um dos valores retornados,
use the blank identifier <code>_</code>.</p> utiliza-se o identificador vazio <code>_</code>.</p>
</td> </td>
<td class="code"> <td class="code">
@ -138,8 +139,9 @@ use the blank identifier <code>_</code>.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Accepting a variable number of arguments is another nice <p>Aceitar um número variável de argumentos é outro
feature of Go functions; we&rsquo;ll look at this next.</p> ótimo recurso de Go functions; será apresentado
no próximo exemplo.</p>
</td> </td>
<td class="code empty"> <td class="code empty">
@ -152,12 +154,12 @@ feature of Go functions; we&rsquo;ll look at this next.</p>
<p class="next"> <p class="next">
Next example: <a href="variadic-functions">Variadic Functions</a>. Próximo exemplo: <a href="variadic-functions">Variadic Functions</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/mutexes generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Mutexes</title> <title>Go Em Exemplos: Mutexes</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ to safely access data across multiple goroutines.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/JU735qy2UmB"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/JU735qy2UmB"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -236,12 +236,12 @@ management task using only goroutines and channels.</p>
<p class="next"> <p class="next">
Next example: <a href="stateful-goroutines">Stateful Goroutines</a>. Próximo exemplo: <a href="stateful-goroutines">Stateful Goroutines</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Non-Blocking Channel Operations</title> <title>Go Em Exemplos: Non-Blocking Channel Operations</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ non-blocking multi-way <code>select</code>s.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/TFv6-7OVNVq"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/TFv6-7OVNVq"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -162,12 +162,12 @@ on both <code>messages</code> and <code>signals</code>.</p>
<p class="next"> <p class="next">
Next example: <a href="closing-channels">Closing Channels</a>. Próximo exemplo: <a href="closing-channels">Closing Channels</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/number-parsing generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Number Parsing</title> <title>Go Em Exemplos: Number Parsing</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -42,7 +42,7 @@ in many programs; here&rsquo;s how to do it in Go.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/ZAMEid6Fpmu"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/ZAMEid6Fpmu"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -200,12 +200,12 @@ bits.</p>
<p class="next"> <p class="next">
Next example: <a href="url-parsing">URL Parsing</a>. Próximo exemplo: <a href="url-parsing">URL Parsing</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/panic generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Panic</title> <title>Go Em Exemplos: Panic</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ aren&rsquo;t prepared to handle gracefully.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/9-2vCvRuhmE"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/9-2vCvRuhmE"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -171,12 +171,12 @@ to use error-indicating return values wherever possible.</p>
<p class="next"> <p class="next">
Next example: <a href="defer">Defer</a>. Próximo exemplo: <a href="defer">Defer</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/pointers generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Pointers</title> <title>Go Em Exemplos: Pointers</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -43,7 +43,7 @@ within your program.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/OlWCLpxAyBz"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/OlWCLpxAyBz"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -179,12 +179,12 @@ the memory address for that variable.</p>
<p class="next"> <p class="next">
Next example: <a href="strings-and-runes">Strings and Runes</a>. Próximo exemplo: <a href="strings-and-runes">Strings and Runes</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/random-numbers generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Random Numbers</title> <title>Go Em Exemplos: Random Numbers</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -43,7 +43,7 @@ generation.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/Enb5uJEx0Bt"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/Enb5uJEx0Bt"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -221,12 +221,12 @@ that Go can provide.</p>
<p class="next"> <p class="next">
Next example: <a href="number-parsing">Number Parsing</a>. Próximo exemplo: <a href="number-parsing">Number Parsing</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

57
public/range generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Range</title> <title>Go Em Exemplos: Range</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -27,9 +27,10 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p><em>range</em> iterates over elements in a variety of data <p><em>range</em> itera sobre elementos de uma variedade
structures. Let&rsquo;s see how to use <code>range</code> with some de estrutura de dados. Aqui será demonstrado como
of the data structures we&rsquo;ve already learned.</p> utilizá-lo com algumas das estruturas de dados já
apresentadas.</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -43,7 +44,7 @@ of the data structures we&rsquo;ve already learned.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/kRsyWNmLFLz"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/0jbhU_qHfKO"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -73,8 +74,8 @@ of the data structures we&rsquo;ve already learned.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Here we use <code>range</code> to sum the numbers in a slice. <p>Aqui é utilizado o <code>range</code> para somar os números
Arrays work like this too.</p> de um slice. Funciona da mesma forma em arrays.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -85,18 +86,18 @@ Arrays work like this too.</p>
<span class="k">for</span> <span class="nx">_</span><span class="p">,</span> <span class="nx">num</span> <span class="o">:=</span> <span class="k">range</span> <span class="nx">nums</span> <span class="p">{</span> <span class="k">for</span> <span class="nx">_</span><span class="p">,</span> <span class="nx">num</span> <span class="o">:=</span> <span class="k">range</span> <span class="nx">nums</span> <span class="p">{</span>
<span class="nx">sum</span> <span class="o">+=</span> <span class="nx">num</span> <span class="nx">sum</span> <span class="o">+=</span> <span class="nx">num</span>
<span class="p">}</span> <span class="p">}</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;sum:&#34;</span><span class="p">,</span> <span class="nx">sum</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;soma:&#34;</span><span class="p">,</span> <span class="nx">sum</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p><code>range</code> on arrays and slices provides both the <p><code>range</code> tanto em arrays quanto em slices fornece
index and value for each entry. Above we didn&rsquo;t chave e valor; ou índice e valor para cada entrada.
need the index, so we ignored it with the No exemplo acima não foi necessário o índice, então
blank identifier <code>_</code>. Sometimes we actually want foi ignorado com identificador vazio <code>_</code>.
the indexes though.</p> Algumas vezes, entretanto, os índices serão necessários.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -104,7 +105,7 @@ the indexes though.</p>
<pre class="chroma"> <pre class="chroma">
<span class="k">for</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">num</span> <span class="o">:=</span> <span class="k">range</span> <span class="nx">nums</span> <span class="p">{</span> <span class="k">for</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">num</span> <span class="o">:=</span> <span class="k">range</span> <span class="nx">nums</span> <span class="p">{</span>
<span class="k">if</span> <span class="nx">num</span> <span class="o">==</span> <span class="mi">3</span> <span class="p">{</span> <span class="k">if</span> <span class="nx">num</span> <span class="o">==</span> <span class="mi">3</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;index:&#34;</span><span class="p">,</span> <span class="nx">i</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;índice:&#34;</span><span class="p">,</span> <span class="nx">i</span><span class="p">)</span>
<span class="p">}</span> <span class="p">}</span>
<span class="p">}</span> <span class="p">}</span>
</pre> </pre>
@ -113,7 +114,7 @@ the indexes though.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p><code>range</code> on map iterates over key/value pairs.</p> <p><code>range</code> em mapas itera sobre os pares de chave/valor.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -129,7 +130,7 @@ the indexes though.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p><code>range</code> can also iterate over just the keys of a map.</p> <p><code>range</code> pode iterar apenas sobre as chaves de um mapa.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -144,18 +145,18 @@ the indexes though.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p><code>range</code> on strings iterates over Unicode code <p><code>range</code> em strings itera sobre pontos de código Unicode.
points. The first value is the starting byte index O primeiro valor é o byte de índice de início da <code>rune</code>,
of the <code>rune</code> and the second the <code>rune</code> itself. e o segundo, da própria <code>rune</code>.
See <a href="strings-and-runes">Strings and Runes</a> for more Veja a seção <a href="strings-and-runes">Strings and Runes</a>
details.</p> para mais detalhes.</p>
</td> </td>
<td class="code"> <td class="code">
<pre class="chroma"> <pre class="chroma">
<span class="k">for</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">c</span> <span class="o">:=</span> <span class="k">range</span> <span class="s">&#34;go&#34;</span> <span class="p">{</span> <span class="k">for</span> <span class="nx">i</span><span class="p">,</span> <span class="kt">rune</span> <span class="o">:=</span> <span class="k">range</span> <span class="s">&#34;go&#34;</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="nx">c</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="kt">rune</span><span class="p">)</span>
<span class="p">}</span> <span class="p">}</span>
<span class="p">}</span> <span class="p">}</span>
</pre> </pre>
@ -173,8 +174,8 @@ details.</p>
<td class="code"> <td class="code">
<pre class="chroma"><span class="gp">$</span> go run range.go <pre class="chroma"><span class="gp">$</span> go run range.go
<span class="go">sum: 9 <span class="go">soma: 9
</span><span class="go">index: 1 </span><span class="go">índice: 1
</span><span class="go">a -&gt; apple </span><span class="go">a -&gt; apple
</span><span class="go">b -&gt; banana </span><span class="go">b -&gt; banana
</span><span class="go">key: a </span><span class="go">key: a
@ -188,18 +189,18 @@ details.</p>
<p class="next"> <p class="next">
Next example: <a href="functions">Functions</a>. Próximo exemplo: <a href="functions">Functions</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>
<script> <script>
var codeLines = []; var codeLines = [];
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' nums :\u003D []int{2, 3, 4}\u000A sum :\u003D 0\u000A for _, num :\u003D range nums {\u000A sum +\u003D num\u000A }\u000A fmt.Println(\"sum:\", sum)\u000A');codeLines.push(' for i, num :\u003D range nums {\u000A if num \u003D\u003D 3 {\u000A fmt.Println(\"index:\", i)\u000A }\u000A }\u000A');codeLines.push(' kvs :\u003D map[string]string{\"a\": \"apple\", \"b\": \"banana\"}\u000A for k, v :\u003D range kvs {\u000A fmt.Printf(\"%s -\u003E %s\\n\", k, v)\u000A }\u000A');codeLines.push(' for k :\u003D range kvs {\u000A fmt.Println(\"key:\", k)\u000A }\u000A');codeLines.push(' for i, c :\u003D range \"go\" {\u000A fmt.Println(i, c)\u000A }\u000A}\u000A');codeLines.push(''); codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' nums :\u003D []int{2, 3, 4}\u000A sum :\u003D 0\u000A for _, num :\u003D range nums {\u000A sum +\u003D num\u000A }\u000A fmt.Println(\"soma:\", sum)\u000A');codeLines.push(' for i, num :\u003D range nums {\u000A if num \u003D\u003D 3 {\u000A fmt.Println(\"índice:\", i)\u000A }\u000A }\u000A');codeLines.push(' kvs :\u003D map[string]string{\"a\": \"apple\", \"b\": \"banana\"}\u000A for k, v :\u003D range kvs {\u000A fmt.Printf(\"%s -\u003E %s\\n\", k, v)\u000A }\u000A');codeLines.push(' for k :\u003D range kvs {\u000A fmt.Println(\"key:\", k)\u000A }\u000A');codeLines.push(' for i, rune :\u003D range \"go\" {\u000A fmt.Println(i, rune)\u000A }\u000A}\u000A');codeLines.push('');
</script> </script>
<script src="site.js" async></script> <script src="site.js" async></script>
</body> </body>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Range over Channels</title> <title>Go Em Exemplos: Range over Channels</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -44,7 +44,7 @@ values received from a channel.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/yQMclmwOYs9"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/yQMclmwOYs9"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -140,12 +140,12 @@ values be received.</p>
<p class="next"> <p class="next">
Next example: <a href="timers">Timers</a>. Próximo exemplo: <a href="timers">Timers</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/rate-limiting generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Rate Limiting</title> <title>Go Em Exemplos: Rate Limiting</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -45,7 +45,7 @@ channels, and <a href="tickers">tickers</a>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/lqf7pC2FUeT"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/lqf7pC2FUeT"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -247,12 +247,12 @@ then serve the remaining 2 with ~200ms delays each.</p>
<p class="next"> <p class="next">
Next example: <a href="atomic-counters">Atomic Counters</a>. Próximo exemplo: <a href="atomic-counters">Atomic Counters</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/reading-files generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Reading Files</title> <title>Go Em Exemplos: Reading Files</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -43,7 +43,7 @@ reading files.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/DF2Wo8nDKaF"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/DF2Wo8nDKaF"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -272,12 +272,12 @@ be scheduled immediately after <code>Open</code>ing with
<p class="next"> <p class="next">
Next example: <a href="writing-files">Writing Files</a>. Próximo exemplo: <a href="writing-files">Writing Files</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/recover generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Recover</title> <title>Go Em Exemplos: Recover</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -60,7 +60,7 @@ does by default for HTTP servers.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/Sk-SVdofEIZ"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/Sk-SVdofEIZ"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -181,12 +181,12 @@ panic and resumes in the deferred closure.</p>
<p class="next"> <p class="next">
Next example: <a href="string-functions">String Functions</a>. Próximo exemplo: <a href="string-functions">String Functions</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/recursion generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Recursion</title> <title>Go Em Exemplos: Recursion</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -43,7 +43,7 @@ Here&rsquo;s a classic example.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/MBTKk9VpAiK"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/MBTKk9VpAiK"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -167,12 +167,12 @@ knows which function to call with <code>fib</code> here.</p>
<p class="next"> <p class="next">
Next example: <a href="pointers">Pointers</a>. Próximo exemplo: <a href="pointers">Pointers</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Regular Expressions</title> <title>Go Em Exemplos: Regular Expressions</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -43,7 +43,7 @@ in Go.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/fI2YIfYsCaL"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/fI2YIfYsCaL"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -329,12 +329,12 @@ the <a href="https://pkg.go.dev/regexp"><code>regexp</code></a> package docs.</p
<p class="next"> <p class="next">
Next example: <a href="json">JSON</a>. Próximo exemplo: <a href="json">JSON</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/select generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Select</title> <title>Go Em Exemplos: Select</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -43,7 +43,7 @@ select is a powerful feature of Go.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/FzONhs4-tae"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/FzONhs4-tae"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -169,12 +169,12 @@ concurrently.</p>
<p class="next"> <p class="next">
Next example: <a href="timeouts">Timeouts</a>. Próximo exemplo: <a href="timeouts">Timeouts</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

8
public/sha256-hashes generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: SHA256 Hashes</title> <title>Go Em Exemplos: SHA256 Hashes</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -45,7 +45,7 @@ SHA256 hashes in Go.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/IHM1lZVm_Jm"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/IHM1lZVm_Jm"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -185,12 +185,12 @@ you should carefully research
<p class="next"> <p class="next">
Next example: <a href="base64-encoding">Base64 Encoding</a>. Próximo exemplo: <a href="base64-encoding">Base64 Encoding</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

10
public/signals generated
View File

@ -2,14 +2,14 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Signals</title> <title>Go Em Exemplos: Signals</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
onkeydown = (e) => { onkeydown = (e) => {
if (e.key == "ArrowLeft") { if (e.key == "ArrowLeft") {
window.location.href = 'execing-processes'; window.location.href = 'executing-processes';
} }
@ -46,7 +46,7 @@ Here&rsquo;s how to handle signals in Go with channels.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/RKLAbvblJMQ"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/RKLAbvblJMQ"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -199,12 +199,12 @@ causing the program to print <code>interrupt</code> and then exit.</p>
<p class="next"> <p class="next">
Next example: <a href="exit">Exit</a>. Próximo exemplo: <a href="exit">Exit</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

128
public/slices generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Slices</title> <title>Go Em Exemplos: Slices</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -27,8 +27,9 @@
<tr> <tr>
<td class="docs"> <td class="docs">
<p><em>Slices</em> are an important data type in Go, giving <p><em>Slices</em> é um importante tipo de dado em Go,
a more powerful interface to sequences than arrays.</p> oferecendo uma interface mais completa do que
arrays para lidar com sequências.</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -42,7 +43,7 @@ a more powerful interface to sequences than arrays.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/76f4Jif5Z8o"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/qAON5gPJwlP"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -72,25 +73,27 @@ a more powerful interface to sequences than arrays.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Unlike arrays, slices are typed only by the <p>Diferente de arrays, slices são tipados apenas com
elements they contain (not the number of elements). tipo dos elementos que armazenará (sem um tamanho).
To create an empty slice with non-zero length, use Para criar um slice vazio, com tamanho não zero,
the builtin <code>make</code>. Here we make a slice of deve-se usar o comando nativo <code>make</code>. Aqui é feito
<code>string</code>s of length <code>3</code> (initially zero-valued).</p> um slice de <code>string</code>, com tamanho 3
(inicialmente com valor padrão zero).</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nx">s</span> <span class="o">:=</span> <span class="nb">make</span><span class="p">([]</span><span class="kt">string</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> <span class="nx">s</span> <span class="o">:=</span> <span class="nb">make</span><span class="p">([]</span><span class="kt">string</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;emp:&#34;</span><span class="p">,</span> <span class="nx">s</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;vazio:&#34;</span><span class="p">,</span> <span class="nx">s</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>We can set and get just like with arrays.</p> <p>Para alterar os valores de um slice e seleciná-los,
faz-se da mesma forma que com array.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -99,15 +102,16 @@ the builtin <code>make</code>. Here we make a slice of
<span class="nx">s</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="p">=</span> <span class="s">&#34;a&#34;</span> <span class="nx">s</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="p">=</span> <span class="s">&#34;a&#34;</span>
<span class="nx">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">=</span> <span class="s">&#34;b&#34;</span> <span class="nx">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">=</span> <span class="s">&#34;b&#34;</span>
<span class="nx">s</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="p">=</span> <span class="s">&#34;c&#34;</span> <span class="nx">s</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="p">=</span> <span class="s">&#34;c&#34;</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;set:&#34;</span><span class="p">,</span> <span class="nx">s</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;exibe slice:&#34;</span><span class="p">,</span> <span class="nx">s</span><span class="p">)</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;get:&#34;</span><span class="p">,</span> <span class="nx">s</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;valor índice 2:&#34;</span><span class="p">,</span> <span class="nx">s</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p><code>len</code> returns the length of the slice as expected.</p> <p><code>len</code> retorna o tamanho de slices, da mesma forma
que com arrays.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -120,12 +124,12 @@ the builtin <code>make</code>. Here we make a slice of
<tr> <tr>
<td class="docs"> <td class="docs">
<p>In addition to these basic operations, slices <p>Em adição a estas operações básicas, slices
support several more that make them richer than suportam muitas outras que as fazem mais úteis do que
arrays. One is the builtin <code>append</code>, which arrays. Uma delas é a função nativa <code>append</code>, que
returns a slice containing one or more new values. retorna a slice contendo um ou mais novos valores.
Note that we need to accept a return value from Note que é preciso aceitar o valor retornado da função
<code>append</code> as we may get a new slice value.</p> <code>append</code> para ter a slice atualizada.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -133,16 +137,16 @@ Note that we need to accept a return value from
<pre class="chroma"> <pre class="chroma">
<span class="nx">s</span> <span class="p">=</span> <span class="nb">append</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="s">&#34;d&#34;</span><span class="p">)</span> <span class="nx">s</span> <span class="p">=</span> <span class="nb">append</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="s">&#34;d&#34;</span><span class="p">)</span>
<span class="nx">s</span> <span class="p">=</span> <span class="nb">append</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="s">&#34;e&#34;</span><span class="p">,</span> <span class="s">&#34;f&#34;</span><span class="p">)</span> <span class="nx">s</span> <span class="p">=</span> <span class="nb">append</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="s">&#34;e&#34;</span><span class="p">,</span> <span class="s">&#34;f&#34;</span><span class="p">)</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;apd:&#34;</span><span class="p">,</span> <span class="nx">s</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;slice com acréscimo:&#34;</span><span class="p">,</span> <span class="nx">s</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Slices can also be <code>copy</code>&rsquo;d. Here we create an <p>Slices também podem ser copiadas com <code>copy</code>. Aqui
empty slice <code>c</code> of the same length as <code>s</code> and copy é criado uma slice vazia <code>c</code> do mesmo tamanho da
into <code>c</code> from <code>s</code>.</p> slice <code>s</code>. Então, a slice <code>s</code> é copiada para <code>c</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
@ -150,75 +154,78 @@ into <code>c</code> from <code>s</code>.</p>
<pre class="chroma"> <pre class="chroma">
<span class="nx">c</span> <span class="o">:=</span> <span class="nb">make</span><span class="p">([]</span><span class="kt">string</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="nx">s</span><span class="p">))</span> <span class="nx">c</span> <span class="o">:=</span> <span class="nb">make</span><span class="p">([]</span><span class="kt">string</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="nx">s</span><span class="p">))</span>
<span class="nb">copy</span><span class="p">(</span><span class="nx">c</span><span class="p">,</span> <span class="nx">s</span><span class="p">)</span> <span class="nb">copy</span><span class="p">(</span><span class="nx">c</span><span class="p">,</span> <span class="nx">s</span><span class="p">)</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;cpy:&#34;</span><span class="p">,</span> <span class="nx">c</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;slice copiada:&#34;</span><span class="p">,</span> <span class="nx">c</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Slices support a &ldquo;slice&rdquo; operator with the syntax <p>Slices suportam um operador &ldquo;slice&rdquo; com a sintaxe
<code>slice[low:high]</code>. For example, this gets a slice <code>slice[índiceBaixo:índiceAlto]</code>. Por exemplo, o
of the elements <code>s[2]</code>, <code>s[3]</code>, and <code>s[4]</code>.</p> comando a seguir seleciona os elementos da slice
de índices 2, 3 e 4; ou <code>s[2]</code>, <code>s[3]</code>, e <code>s[4]</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nx">l</span> <span class="o">:=</span> <span class="nx">s</span><span class="p">[</span><span class="mi">2</span><span class="p">:</span><span class="mi">5</span><span class="p">]</span> <span class="nx">l</span> <span class="o">:=</span> <span class="nx">s</span><span class="p">[</span><span class="mi">2</span><span class="p">:</span><span class="mi">5</span><span class="p">]</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;sl1:&#34;</span><span class="p">,</span> <span class="nx">l</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;slice 1:&#34;</span><span class="p">,</span> <span class="nx">l</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>This slices up to (but excluding) <code>s[5]</code>.</p> <p>Já este, &ldquo;fatia&rdquo; o slice <code>s</code> até o
índice 5 (não incluso) ou <code>s[5]</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nx">l</span> <span class="p">=</span> <span class="nx">s</span><span class="p">[:</span><span class="mi">5</span><span class="p">]</span> <span class="nx">l</span> <span class="p">=</span> <span class="nx">s</span><span class="p">[:</span><span class="mi">5</span><span class="p">]</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;sl2:&#34;</span><span class="p">,</span> <span class="nx">l</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;slice 2:&#34;</span><span class="p">,</span> <span class="nx">l</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>And this slices up from (and including) <code>s[2]</code>.</p> <p>E este, &ldquo;fatia&rdquo; o slices <code>s</code> a partir do
índice 2 (incluso) ou <code>s[2]</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nx">l</span> <span class="p">=</span> <span class="nx">s</span><span class="p">[</span><span class="mi">2</span><span class="p">:]</span> <span class="nx">l</span> <span class="p">=</span> <span class="nx">s</span><span class="p">[</span><span class="mi">2</span><span class="p">:]</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;sl3:&#34;</span><span class="p">,</span> <span class="nx">l</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;slice 3:&#34;</span><span class="p">,</span> <span class="nx">l</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>We can declare and initialize a variable for slice <p>Também é possível declarar e inicializar um
in a single line as well.</p> slice em apenas uma linha.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="nx">t</span> <span class="o">:=</span> <span class="p">[]</span><span class="kt">string</span><span class="p">{</span><span class="s">&#34;g&#34;</span><span class="p">,</span> <span class="s">&#34;h&#34;</span><span class="p">,</span> <span class="s">&#34;i&#34;</span><span class="p">}</span> <span class="nx">t</span> <span class="o">:=</span> <span class="p">[]</span><span class="kt">string</span><span class="p">{</span><span class="s">&#34;g&#34;</span><span class="p">,</span> <span class="s">&#34;h&#34;</span><span class="p">,</span> <span class="s">&#34;i&#34;</span><span class="p">}</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;dcl:&#34;</span><span class="p">,</span> <span class="nx">t</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;slice inicializada:&#34;</span><span class="p">,</span> <span class="nx">t</span><span class="p">)</span>
</pre> </pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Slices can be composed into multi-dimensional data <p>Slices podem ser compsotas em estruturas
structures. The length of the inner slices can multi-dimensionais. O tamanho das slices internas
vary, unlike with multi-dimensional arrays.</p> pode variar, diferente de arrays multi-dimensionais.</p>
</td> </td>
<td class="code"> <td class="code">
@ -232,7 +239,7 @@ vary, unlike with multi-dimensional arrays.</p>
<span class="nx">twoD</span><span class="p">[</span><span class="nx">i</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span> <span class="p">=</span> <span class="nx">i</span> <span class="o">+</span> <span class="nx">j</span> <span class="nx">twoD</span><span class="p">[</span><span class="nx">i</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span> <span class="p">=</span> <span class="nx">i</span> <span class="o">+</span> <span class="nx">j</span>
<span class="p">}</span> <span class="p">}</span>
<span class="p">}</span> <span class="p">}</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;2d: &#34;</span><span class="p">,</span> <span class="nx">twoD</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">&#34;bi-dimensional: &#34;</span><span class="p">,</span> <span class="nx">twoD</span><span class="p">)</span>
<span class="p">}</span> <span class="p">}</span>
</pre> </pre>
</td> </td>
@ -244,33 +251,34 @@ vary, unlike with multi-dimensional arrays.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Note that while slices are different types than arrays, <p>Note que enquanto slices são tipos diferentes
they are rendered similarly by <code>fmt.Println</code>.</p> de arrays, eles são exibidos de maneira similar
pelo comando <code>fmt.Println</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<pre class="chroma"> <pre class="chroma">
<span class="gp">$</span> go run slices.go <span class="gp">$</span> go run slices.go
<span class="go">emp: [ ] <span class="go">vazio: [ ]
</span><span class="go">set: [a b c] </span><span class="go">exibe slice: [a b c]
</span><span class="go">get: c </span><span class="go">valor índice 2: c
</span><span class="go">len: 3 </span><span class="go">len: 3
</span><span class="go">apd: [a b c d e f] </span><span class="go">slice com acréscimo: [a b c d e f]
</span><span class="go">cpy: [a b c d e f] </span><span class="go">slice copiada: [a b c d e f]
</span><span class="go">sl1: [c d e] </span><span class="go">slice 1: [c d e]
</span><span class="go">sl2: [a b c d e] </span><span class="go">slice 2: [a b c d e]
</span><span class="go">sl3: [c d e f] </span><span class="go">slice 3: [c d e f]
</span><span class="go">dcl: [g h i] </span><span class="go">slice inicializada: [g h i]
</span><span class="go">2d: [[0] [1 2] [2 3 4]]</span></pre> </span><span class="go">bi-dimensional: [[0] [1 2] [2 3 4]]</span></pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Check out this <a href="https://go.dev/blog/slices-intro">great blog post</a> <p>Veja esse <a href="https://go.dev/blog/slices-intro">post</a>
by the Go team for more details on the design and do time de Go para mais detalhes sobre o design e
implementation of slices in Go.</p> implementação de slices na linguagem.</p>
</td> </td>
<td class="code empty leading"> <td class="code empty leading">
@ -281,8 +289,8 @@ implementation of slices in Go.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Now that we&rsquo;ve seen arrays and slices we&rsquo;ll look at <p>Agora que vimos arrays e slices, passaremos a estudar
Go&rsquo;s other key builtin data structure: maps.</p> outra estrutura de dados nativa de Go: maps.</p>
</td> </td>
<td class="code empty"> <td class="code empty">
@ -295,18 +303,18 @@ Go&rsquo;s other key builtin data structure: maps.</p>
<p class="next"> <p class="next">
Next example: <a href="maps">Maps</a>. Próximo exemplo: <a href="maps">Maps</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>
<script> <script>
var codeLines = []; var codeLines = [];
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' s :\u003D make([]string, 3)\u000A fmt.Println(\"emp:\", s)\u000A');codeLines.push(' s[0] \u003D \"a\"\u000A s[1] \u003D \"b\"\u000A s[2] \u003D \"c\"\u000A fmt.Println(\"set:\", s)\u000A fmt.Println(\"get:\", s[2])\u000A');codeLines.push(' fmt.Println(\"len:\", len(s))\u000A');codeLines.push(' s \u003D append(s, \"d\")\u000A s \u003D append(s, \"e\", \"f\")\u000A fmt.Println(\"apd:\", s)\u000A');codeLines.push(' c :\u003D make([]string, len(s))\u000A copy(c, s)\u000A fmt.Println(\"cpy:\", c)\u000A');codeLines.push(' l :\u003D s[2:5]\u000A fmt.Println(\"sl1:\", l)\u000A');codeLines.push(' l \u003D s[:5]\u000A fmt.Println(\"sl2:\", l)\u000A');codeLines.push(' l \u003D s[2:]\u000A fmt.Println(\"sl3:\", l)\u000A');codeLines.push(' t :\u003D []string{\"g\", \"h\", \"i\"}\u000A fmt.Println(\"dcl:\", t)\u000A');codeLines.push(' twoD :\u003D make([][]int, 3)\u000A for i :\u003D 0; i \u003C 3; i++ {\u000A innerLen :\u003D i + 1\u000A twoD[i] \u003D make([]int, innerLen)\u000A for j :\u003D 0; j \u003C innerLen; j++ {\u000A twoD[i][j] \u003D i + j\u000A }\u000A }\u000A fmt.Println(\"2d: \", twoD)\u000A}\u000A');codeLines.push('');codeLines.push('');codeLines.push(''); codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' s :\u003D make([]string, 3)\u000A fmt.Println(\"vazio:\", s)\u000A');codeLines.push(' s[0] \u003D \"a\"\u000A s[1] \u003D \"b\"\u000A s[2] \u003D \"c\"\u000A fmt.Println(\"exibe slice:\", s)\u000A fmt.Println(\"valor índice 2:\", s[2])\u000A');codeLines.push(' fmt.Println(\"len:\", len(s))\u000A');codeLines.push(' s \u003D append(s, \"d\")\u000A s \u003D append(s, \"e\", \"f\")\u000A fmt.Println(\"slice com acréscimo:\", s)\u000A');codeLines.push(' c :\u003D make([]string, len(s))\u000A copy(c, s)\u000A fmt.Println(\"slice copiada:\", c)\u000A');codeLines.push(' l :\u003D s[2:5]\u000A fmt.Println(\"slice 1:\", l)\u000A');codeLines.push(' l \u003D s[:5]\u000A fmt.Println(\"slice 2:\", l)\u000A');codeLines.push(' l \u003D s[2:]\u000A fmt.Println(\"slice 3:\", l)\u000A');codeLines.push(' t :\u003D []string{\"g\", \"h\", \"i\"}\u000A fmt.Println(\"slice inicializada:\", t)\u000A');codeLines.push(' twoD :\u003D make([][]int, 3)\u000A for i :\u003D 0; i \u003C 3; i++ {\u000A innerLen :\u003D i + 1\u000A twoD[i] \u003D make([]int, innerLen)\u000A for j :\u003D 0; j \u003C innerLen; j++ {\u000A twoD[i][j] \u003D i + j\u000A }\u000A }\u000A fmt.Println(\"bi-dimensional: \", twoD)\u000A}\u000A');codeLines.push('');codeLines.push('');codeLines.push('');
</script> </script>
<script src="site.js" async></script> <script src="site.js" async></script>
</body> </body>

8
public/sorting generated
View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Go by Example: Sorting</title> <title>Go Em Exemplos: Sorting</title>
<link rel=stylesheet href="site.css"> <link rel=stylesheet href="site.css">
</head> </head>
<script> <script>
@ -43,7 +43,7 @@ builtins first.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="https://go.dev/play/p/_gY0tANzJ4l"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" /> <a target="_blank" href="https://go.dev/play/p/_gY0tANzJ4l"><img title="Executar código em nova aba" src="play.png" class="run" /></a><img title="Copiar código" src="clipboard.png" class="copy" />
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span> <pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
</pre> </pre>
</td> </td>
@ -147,12 +147,12 @@ slices and <code>true</code> as the result of our <code>AreSorted</code> test.</
<p class="next"> <p class="next">
Next example: <a href="sorting-by-functions">Sorting by Functions</a>. Próximo exemplo: <a href="sorting-by-functions">Sorting by Functions</a>.
</p> </p>
<p class="footer"> <p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a> Por <a href="https://markmcgranaghan.com">Mark McGranaghan</a> e <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | traduzido por <a href="https://github.com/lucassauro">Lucassauro</a> | <a href="https://github.com/lucassauro/gobyexample">contribua</a> | <a href="https://github.com/mmcgrana/gobyexample#license">licença</a>
</p> </p>
</div> </div>

Some files were not shown because too many files have changed in this diff Show More