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 Server
Context
Spawning Processes
Exec'ing Processes
Spawning Processes (Invocando processos)
Executing Processes
Signals
Exit

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,5 +2,6 @@ $ go run functions.go
1+2 = 3
1+2+3 = 6
# There are several other features to Go functions. One is
# multiple return values, which we'll look at next.
# Existem muitos outros recursos em Funções,
# 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"
// message. Here's the full source code.
// O nosso primeiro programa exibirá a mensagem "hello world".
// Aqui está o código completo.
package main
import "fmt"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,5 +3,6 @@ $ go run multiple-return-values.go
7
7
# Accepting a variable number of arguments is another nice
# feature of Go functions; we'll look at this next.
# Aceitar um número variável de argumentos é outro
# ó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
// structures. Let's see how to use `range` with some
// of the data structures we've already learned.
// _range_ itera sobre elementos de uma variedade
// de estrutura de dados. Aqui será demonstrado como
// utilizá-lo com algumas das estruturas de dados já
// apresentadas.
package main
@ -8,43 +9,43 @@ import "fmt"
func main() {
// Here we use `range` to sum the numbers in a slice.
// Arrays work like this too.
// Aqui é utilizado o `range` para somar os números
// de um slice. Funciona da mesma forma em arrays.
nums := []int{2, 3, 4}
sum := 0
for _, num := range nums {
sum += num
}
fmt.Println("sum:", sum)
fmt.Println("soma:", sum)
// `range` on arrays and slices provides both the
// index and value for each entry. Above we didn't
// need the index, so we ignored it with the
// blank identifier `_`. Sometimes we actually want
// the indexes though.
// `range` tanto em arrays quanto em slices fornece
// chave e valor; ou índice e valor para cada entrada.
// No exemplo acima não foi necessário o índice, então
// foi ignorado com identificador vazio `_`.
// Algumas vezes, entretanto, os índices serão necessários.
for i, num := range nums {
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"}
for k, v := range kvs {
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 {
fmt.Println("key:", k)
}
// `range` on strings iterates over Unicode code
// points. The first value is the starting byte index
// of the `rune` and the second the `rune` itself.
// See [Strings and Runes](strings-and-runes) for more
// details.
for i, c := range "go" {
fmt.Println(i, c)
// `range` em strings itera sobre pontos de código Unicode.
// O primeiro valor é o byte de índice de início da `rune`,
// e o segundo, da própria `rune`.
// Veja a seção [Strings and Runes](strings-and-runes)
// para mais detalhes.
for i, rune := range "go" {
fmt.Println(i, rune)
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
// Go has various value types including strings,
// integers, floats, booleans, etc. Here are a few
// basic examples.
// Go tem vários tipos de valores, dentre eles:
// strings, integers, floats, booleans, etc.
// Aqui estão alguns exemplos básicos.
package main
@ -8,14 +8,14 @@ import "fmt"
func main() {
// Strings, which can be added together with `+`.
// Strings, que podem ser concatenadas usando `+`.
fmt.Println("go" + "lang")
// Integers and floats.
// Integers e floats.
fmt.Println("1+1 =", 1+1)
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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,5 +3,6 @@ $ go run variadic-functions.go
[1 2 3] 6
[1 2 3 4] 10
# Another key aspect of functions in Go is their ability
# to form closures, which we'll look at next.
# Outro aspecto chave de funções em Go é a
# 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 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>
</div>

67
public/arrays generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Arrays</title>
<title>Go Em Exemplos: Arrays</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -27,10 +27,10 @@
<tr>
<td class="docs">
<p>In Go, an <em>array</em> is a numbered sequence of elements of a
specific length. In typical Go code, <a href="slices">slices</a> are
much more common; arrays are useful in some special
scenarios.</p>
<p>Em Go, um <em>array</em> é uma sequência numerada de elementos
de um tamanho específico. Tipicamente, <a href="slices">slices</a> são
muito mais comuns; arrays são úteis em alguns cenários
específicos.</p>
</td>
<td class="code empty leading">
@ -44,7 +44,7 @@ scenarios.</p>
</td>
<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>
</td>
@ -74,41 +74,41 @@ scenarios.</p>
<tr>
<td class="docs">
<p>Here we create an array <code>a</code> that will hold exactly
5 <code>int</code>s. The type of elements and length are both
part of the array&rsquo;s type. By default an array is
zero-valued, which for <code>int</code>s means <code>0</code>s.</p>
<p>Aqui é criado um array <code>a</code> com capacidade de armazenar
exatamente 5 inteiros. O tipo de elemento que ele irá
armazenar (int) e seu tamanho (5) são partes do tipo do array.
Neste caso, o array tem valores padrão zero.</p>
</td>
<td class="code leading">
<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="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>
</td>
</tr>
<tr>
<td class="docs">
<p>We can set a value at an index using the
<code>array[index] = value</code> syntax, and get a value with
<code>array[index]</code>.</p>
<p>É possível alterar o valor de um índice do array
utilizando a sintaxe <code>array[índice] = valor</code>,
bem como selecionar um valor com <code>array[índice]</code>.</p>
</td>
<td class="code leading">
<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">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;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;í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;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>
</td>
</tr>
<tr>
<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 class="code leading">
@ -121,24 +121,23 @@ zero-valued, which for <code>int</code>s means <code>0</code>s.</p>
<tr>
<td class="docs">
<p>Use this syntax to declare and initialize an array
in one line.</p>
<p>Para declarar a inicializar um array em uma linha,
é possível usar esta sintaxe.</p>
</td>
<td class="code leading">
<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">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>
</td>
</tr>
<tr>
<td class="docs">
<p>Array types are one-dimensional, but you can
compose types to build multi-dimensional data
structures.</p>
<p>Arrays, via de regra são unidimensionais, mas é possível
compor tipos para formar arrays multidimensionais.</p>
</td>
<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="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>
</pre>
</td>
@ -162,20 +161,20 @@ structures.</p>
<tr>
<td class="docs">
<p>Note that arrays appear in the form <code>[v1 v2 v3 ...]</code>
when printed with <code>fmt.Println</code>.</p>
<p>Note que arrays aparecem na forma <code>[v1 v2 v3 ...]</code>
quando exibidos com <code>fmt.Println</code>.</p>
</td>
<td class="code">
<pre class="chroma">
<span class="gp">$</span> go run arrays.go
<span class="go">emp: [0 0 0 0 0]
</span><span class="go">set: [0 0 0 0 100]
</span><span class="go">get: 100
<span class="go">vazio: [0 0 0 0 0]
</span><span class="go">índice 4 alterado: [0 0 0 0 100]
</span><span class="go">valor índice 4: 100
</span><span class="go">len: 5
</span><span class="go">dcl: [1 2 3 4 5]
</span><span class="go">2d: [[0 1 2] [1 2 3]]</span></pre>
</span><span class="go">array inicializado:: [1 2 3 4 5]
</span><span class="go">bi-dimensional: [[0 1 2] [1 2 3]]</span></pre>
</td>
</tr>
@ -183,18 +182,18 @@ when printed with <code>fmt.Println</code>.</p>
<p class="next">
Next example: <a href="slices">Slices</a>.
Próximo exemplo: <a href="slices">Slices</a>.
</p>
<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>
</div>
<script>
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 src="site.js" async></script>
</body>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Atomic Counters</title>
<title>Go Em Exemplos: Atomic Counters</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -46,7 +46,7 @@ counters</em> accessed by multiple goroutines.</p>
</td>
<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>
</td>
@ -221,12 +221,12 @@ state.</p>
<p class="next">
Next example: <a href="mutexes">Mutexes</a>.
Próximo exemplo: <a href="mutexes">Mutexes</a>.
</p>
<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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Base64 Encoding</title>
<title>Go Em Exemplos: Base64 Encoding</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -42,7 +42,7 @@ encoding/decoding</a>.</p>
</td>
<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>
</td>
@ -177,12 +177,12 @@ but they both decode to the original string as desired.</p>
<p class="next">
Next example: <a href="reading-files">Reading Files</a>.
Próximo exemplo: <a href="reading-files">Reading Files</a>.
</p>
<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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Channel Buffering</title>
<title>Go Em Exemplos: Channel Buffering</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -46,7 +46,7 @@ those values.</p>
</td>
<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>
</td>
@ -139,12 +139,12 @@ concurrent receive.</p>
<p class="next">
Next example: <a href="channel-synchronization">Channel Synchronization</a>.
Próximo exemplo: <a href="channel-synchronization">Channel Synchronization</a>.
</p>
<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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Channel Directions</title>
<title>Go Em Exemplos: Channel Directions</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -44,7 +44,7 @@ the program.</p>
</td>
<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>
</td>
@ -131,12 +131,12 @@ receive on this channel.</p>
<p class="next">
Next example: <a href="select">Select</a>.
Próximo exemplo: <a href="select">Select</a>.
</p>
<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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Channel Synchronization</title>
<title>Go Em Exemplos: Channel Synchronization</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -45,7 +45,7 @@ you may prefer to use a <a href="waitgroups">WaitGroup</a>.</p>
</td>
<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>
</td>
@ -170,12 +170,12 @@ started.</p>
<p class="next">
Next example: <a href="channel-directions">Channel Directions</a>.
Próximo exemplo: <a href="channel-directions">Channel Directions</a>.
</p>
<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>
</div>

8
public/channels generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Channels</title>
<title>Go Em Exemplos: Channels</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -44,7 +44,7 @@ goroutine.</p>
</td>
<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>
</td>
@ -155,12 +155,12 @@ message without having to use any other synchronization.</p>
<p class="next">
Next example: <a href="channel-buffering">Channel Buffering</a>.
Próximo exemplo: <a href="channel-buffering">Channel Buffering</a>.
</p>
<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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Closing Channels</title>
<title>Go Em Exemplos: Closing Channels</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -43,7 +43,7 @@ completion to the channel&rsquo;s receivers.</p>
</td>
<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>
</td>
@ -181,12 +181,12 @@ example: <code>range</code> over channels.</p>
<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 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>
</div>

45
public/closures generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Closures</title>
<title>Go Em Exemplos: Closures</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -27,10 +27,11 @@
<tr>
<td class="docs">
<p>Go supports <a href="https://en.wikipedia.org/wiki/Anonymous_function"><em>anonymous functions</em></a>,
which can form <a href="https://en.wikipedia.org/wiki/Closure_(computer_science)"><em>closures</em></a>.
Anonymous functions are useful when you want to define
a function inline without having to name it.</p>
<p>Go suporta <a href="https://en.wikipedia.org/wiki/Anonymous_function"><em>funções anônimas</em></a>,
as quais podem formar
<a href="https://pt.wikipedia.org/wiki/Clausura_(ci%C3%AAncia_da_computa%C3%A7%C3%A3o)"><em>closures</em></a>.
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 class="code empty leading">
@ -44,7 +45,7 @@ a function inline without having to name it.</p>
</td>
<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>
</td>
@ -63,10 +64,10 @@ a function inline without having to name it.</p>
<tr>
<td class="docs">
<p>This function <code>intSeq</code> returns another function, which
we define anonymously in the body of <code>intSeq</code>. The
returned function <em>closes over</em> the variable <code>i</code> to
form a closure.</p>
<p>Esta função <code>intSeq</code> retorna outra função, que é
definida anonimamente no corpo de <code>intSeq</code>. A função
retornada <em>fecha sobre</em> (<em>closes over</em>) a variavel
<code>i</code> para formar um fechamento (closure).</p>
</td>
<td class="code leading">
@ -96,10 +97,10 @@ form a closure.</p>
<tr>
<td class="docs">
<p>We call <code>intSeq</code>, assigning the result (a function)
to <code>nextInt</code>. This function value captures its
own <code>i</code> value, which will be updated each time
we call <code>nextInt</code>.</p>
<p>Aqui, a execução da função <code>intSeq</code> (que retorna outra
função) é atribuída à variável <code>nextInt</code>.
Esta função captura o próprio valor de <code>i</code>, que
será atualizado a cada vez que é chamada <code>nextInt</code>.</p>
</td>
<td class="code leading">
@ -112,8 +113,8 @@ we call <code>nextInt</code>.</p>
<tr>
<td class="docs">
<p>See the effect of the closure by calling <code>nextInt</code>
a few times.</p>
<p>Veja o efeito do closure chamando <code>nextInt</code>
algumas vezes.</p>
</td>
<td class="code leading">
@ -128,8 +129,8 @@ a few times.</p>
<tr>
<td class="docs">
<p>To confirm that the state is unique to that
particular function, create and test a new one.</p>
<p>Para confirmar que o estado é único àquela variável
específica, ao criar outra e testar, o resultado é diverso.</p>
</td>
<td class="code">
@ -162,8 +163,8 @@ particular function, create and test a new one.</p>
<tr>
<td class="docs">
<p>The last feature of functions we&rsquo;ll look at for now is
recursion.</p>
<p>O último recurso de funções a ser apresentado
é a recursão.</p>
</td>
<td class="code empty">
@ -176,12 +177,12 @@ recursion.</p>
<p class="next">
Next example: <a href="recursion">Recursion</a>.
Próximo exemplo: <a href="recursion">Recursion</a>.
</p>
<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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<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">
</head>
<script>
@ -44,7 +44,7 @@ For example, <code>go run hello.go</code> uses <code>run</code> and
</td>
<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>
</td>
@ -156,12 +156,12 @@ with flags.</p>
<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 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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<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">
</head>
<script>
@ -44,7 +44,7 @@ command-line flag.</p>
</td>
<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>
</td>
@ -292,12 +292,12 @@ and show the help text again.</p>
<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 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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<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">
</head>
<script>
@ -46,7 +46,7 @@ subcommands that have their own flags.</p>
</td>
<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>
</td>
@ -246,12 +246,12 @@ way to parameterize programs.</p>
<p class="next">
Next example: <a href="environment-variables">Environment Variables</a>.
Próximo exemplo: <a href="environment-variables">Environment Variables</a>.
</p>
<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>
</div>

35
public/constants generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Constants</title>
<title>Go Em Exemplos: Constants</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -27,8 +27,8 @@
<tr>
<td class="docs">
<p>Go supports <em>constants</em> of character, string, boolean,
and numeric values.</p>
<p>Go suporta <em>constantes</em> de tipos strings, booleanos,
e numericos.</p>
</td>
<td class="code empty leading">
@ -42,7 +42,7 @@ and numeric values.</p>
</td>
<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>
</td>
@ -64,7 +64,7 @@ and numeric values.</p>
<tr>
<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 class="code leading">
@ -89,8 +89,8 @@ and numeric values.</p>
<tr>
<td class="docs">
<p>A <code>const</code> statement can appear anywhere a <code>var</code>
statement can.</p>
<p>A declaração <code>const</code> pode aparecer em qualquer
lugar que a declaração <code>var</code> também possa.</p>
</td>
<td class="code leading">
@ -103,8 +103,8 @@ statement can.</p>
<tr>
<td class="docs">
<p>Constant expressions perform arithmetic with
arbitrary precision.</p>
<p>Expressões com constantes são performadas
aritmeticamente com precisão arbitrária.</p>
</td>
<td class="code leading">
@ -118,8 +118,8 @@ arbitrary precision.</p>
<tr>
<td class="docs">
<p>A numeric constant has no type until it&rsquo;s given
one, such as by an explicit conversion.</p>
<p>Uma constante numérica não possui um tipo
até que seja atribuído um, como uma conversão explícita.</p>
</td>
<td class="code leading">
@ -132,10 +132,11 @@ one, such as by an explicit conversion.</p>
<tr>
<td class="docs">
<p>A number can be given a type by using it in a
context that requires one, such as a variable
assignment or function call. For example, here
<code>math.Sin</code> expects a <code>float64</code>.</p>
<p>Um tipo pode ser implicitamente atribuído a uma constante
numérica ao usá-la num contexto que requer um tipo,
como atribuição a uma variável ou uma chamada de função.
Por exemplo, a função <code>math.Sin</code> espera um valor de tipo
<code>float64</code>.</p>
</td>
<td class="code">
@ -169,12 +170,12 @@ assignment or function call. For example, here
<p class="next">
Next example: <a href="for">For</a>.
Próximo exemplo: <a href="for">For</a>.
</p>
<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>
</div>

10
public/context generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Context</title>
<title>Go Em Exemplos: Context</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -14,7 +14,7 @@
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 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">
<span class="kn">package</span> <span class="nx">main</span>
</pre>
@ -191,12 +191,12 @@ cancellation.</p>
<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 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>
</div>

8
public/defer generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Defer</title>
<title>Go Em Exemplos: Defer</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -44,7 +44,7 @@ purposes of cleanup. <code>defer</code> is often used where e.g.
</td>
<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>
</td>
@ -195,12 +195,12 @@ after being written.</p>
<p class="next">
Next example: <a href="recover">Recover</a>.
Próximo exemplo: <a href="recover">Recover</a>.
</p>
<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>
</div>

8
public/directories generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Directories</title>
<title>Go Em Exemplos: Directories</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -42,7 +42,7 @@
</td>
<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>
</td>
@ -333,12 +333,12 @@ recursively by <code>filepath.Walk</code>.</p>
<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 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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Embed Directive</title>
<title>Go Em Exemplos: Embed Directive</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -35,7 +35,7 @@ build time. Read more about the embed directive
</td>
<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">
<span class="kn">package</span> <span class="nx">main</span>
</pre>
@ -196,12 +196,12 @@ this example can only be run on your local machine.)</p>
<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 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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Environment Variables</title>
<title>Go Em Exemplos: Environment Variables</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -44,7 +44,7 @@ Let&rsquo;s look at how to set, get, and list environment variables.</p>
</td>
<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>
</td>
@ -172,12 +172,12 @@ program picks that value up.</p>
<p class="next">
Next example: <a href="http-client">HTTP Client</a>.
Próximo exemplo: <a href="http-client">HTTP Client</a>.
</p>
<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>
</div>

8
public/epoch generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Epoch</title>
<title>Go Em Exemplos: Epoch</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -44,7 +44,7 @@ Here&rsquo;s how to do it in Go.</p>
</td>
<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>
</td>
@ -156,12 +156,12 @@ parsing and formatting.</p>
<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 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>
</div>

8
public/errors generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Errors</title>
<title>Go Em Exemplos: Errors</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -48,7 +48,7 @@ non-error tasks.</p>
</td>
<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>
</td>
@ -282,12 +282,12 @@ on the Go blog for more on error handling.</p>
<p class="next">
Next example: <a href="goroutines">Goroutines</a>.
Próximo exemplo: <a href="goroutines">Goroutines</a>.
</p>
<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>
</div>

View File

@ -9,7 +9,7 @@
onkeydown = (e) => {
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">
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>
</div>

6
public/exit generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Exit</title>
<title>Go Em Exemplos: Exit</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -38,7 +38,7 @@ status.</p>
</td>
<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>
</td>
@ -161,7 +161,7 @@ the status in the terminal.</p>
<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>
</div>

8
public/file-paths generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: File Paths</title>
<title>Go Em Exemplos: File Paths</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -34,7 +34,7 @@ between operating systems; <code>dir/file</code> on Linux vs.
</td>
<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">
<span class="kn">package</span> <span class="nx">main</span>
</pre>
@ -235,12 +235,12 @@ be made relative to base.</p>
<p class="next">
Next example: <a href="directories">Directories</a>.
Próximo exemplo: <a href="directories">Directories</a>.
</p>
<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>
</div>

32
public/for generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: For</title>
<title>Go Em Exemplos: For</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -27,8 +27,8 @@
<tr>
<td class="docs">
<p><code>for</code> is Go&rsquo;s only looping construct. Here are
some basic types of <code>for</code> loops.</p>
<p><code>for</code> é a única ferramenta de repetição em Go.
Aqui estão algumas formas básicas de utilização.</p>
</td>
<td class="code empty leading">
@ -42,7 +42,7 @@ some basic types of <code>for</code> loops.</p>
</td>
<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>
</td>
@ -72,7 +72,7 @@ some basic types of <code>for</code> loops.</p>
<tr>
<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 class="code leading">
@ -89,7 +89,8 @@ some basic types of <code>for</code> loops.</p>
<tr>
<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 class="code leading">
@ -104,9 +105,8 @@ some basic types of <code>for</code> loops.</p>
<tr>
<td class="docs">
<p><code>for</code> without a condition will loop repeatedly
until you <code>break</code> out of the loop or <code>return</code> from
the enclosing function.</p>
<p><code>for</code> sem nenhuma condição será repetido indefinidamente,
até que <code>break</code> ou <code>return</code> sejam usados para interromper.</p>
</td>
<td class="code leading">
@ -122,8 +122,8 @@ the enclosing function.</p>
<tr>
<td class="docs">
<p>You can also <code>continue</code> to the next iteration of
the loop.</p>
<p>Também é possível utilizar o comando <code>continue</code>
para prosseguir para a próxima iteração do loop.</p>
</td>
<td class="code">
@ -166,9 +166,9 @@ the loop.</p>
<tr>
<td class="docs">
<p>We&rsquo;ll see some other <code>for</code> forms later when we look at
<code>range</code> statements, channels, and other data
structures.</p>
<p>Algumas outras formas de utilizar o <code>for</code> serão
mencionados na declarações <code>range</code>; e em outras
estruturas como channels.</p>
</td>
<td class="code empty">
@ -181,12 +181,12 @@ structures.</p>
<p class="next">
Next example: <a href="if-else">If/Else</a>.
Próximo exemplo: <a href="if-else">If/Else</a>.
</p>
<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>
</div>

37
public/functions generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Functions</title>
<title>Go Em Exemplos: Functions</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -27,8 +27,8 @@
<tr>
<td class="docs">
<p><em>Functions</em> are central in Go. We&rsquo;ll learn about
functions with a few different examples.</p>
<p><em>Functions</em> são centrais em Go. Serão demonstradas
funções com alguns exemplos diferentes.</p>
</td>
<td class="code empty leading">
@ -42,7 +42,7 @@ functions with a few different examples.</p>
</td>
<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>
</td>
@ -61,8 +61,7 @@ functions with a few different examples.</p>
<tr>
<td class="docs">
<p>Here&rsquo;s a function that takes two <code>int</code>s and returns
their sum as an <code>int</code>.</p>
<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>
</td>
<td class="code leading">
@ -75,9 +74,9 @@ their sum as an <code>int</code>.</p>
<tr>
<td class="docs">
<p>Go requires explicit returns, i.e. it won&rsquo;t
automatically return the value of the last
expression.</p>
<p>Go exige retornos explícitos. Por exemplo,
não será retornado automaticamente o valor
da última expressão</p>
</td>
<td class="code leading">
@ -91,10 +90,9 @@ expression.</p>
<tr>
<td class="docs">
<p>When you have multiple consecutive parameters of
the same type, you may omit the type name for the
like-typed parameters up to the final parameter that
declares the type.</p>
<p>Ao existir multiplos parâmetros consecutivos de um
mesmo tipo, é possível omitir o tipo dos parâmetros
até a declaração do último parâmetro daquele tipo.</p>
</td>
<td class="code leading">
@ -120,8 +118,8 @@ declares the type.</p>
<tr>
<td class="docs">
<p>Call a function just as you&rsquo;d expect, with
<code>name(args)</code>.</p>
<p>Para executar uma função é utilizada a
sintaxe <code>nomeDaFuncao(argumentos)</code>.</p>
</td>
<td class="code leading">
@ -164,8 +162,9 @@ declares the type.</p>
<tr>
<td class="docs">
<p>There are several other features to Go functions. One is
multiple return values, which we&rsquo;ll look at next.</p>
<p>Existem muitos outros recursos em Funções,
um dos quais é chamado de Retorno de Valores
Múltiplos que será apresentado no próximo exemplo.</p>
</td>
<td class="code empty">
@ -178,12 +177,12 @@ multiple return values, which we&rsquo;ll look at next.</p>
<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 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>
</div>

8
public/generics generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Generics</title>
<title>Go Em Exemplos: Generics</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -42,7 +42,7 @@
</td>
<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>
</td>
@ -233,12 +233,12 @@ automatically.</p>
<p class="next">
Next example: <a href="errors">Errors</a>.
Próximo exemplo: <a href="errors">Errors</a>.
</p>
<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>
</div>

8
public/goroutines generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Goroutines</title>
<title>Go Em Exemplos: Goroutines</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -41,7 +41,7 @@
</td>
<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>
</td>
@ -194,12 +194,12 @@ concurrent Go programs: channels.</p>
<p class="next">
Next example: <a href="channels">Channels</a>.
Próximo exemplo: <a href="channels">Channels</a>.
</p>
<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>
</div>

28
public/hello-world generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Hello World</title>
<title>Go Em Exemplos: Hello World</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -23,12 +23,12 @@
<tr>
<td class="docs">
<p>Our first program will print the classic &ldquo;hello world&rdquo;
message. Here&rsquo;s the full source code.</p>
<p>O nosso primeiro programa exibirá a mensagem &ldquo;hello world&rdquo;.
Aqui está o código completo.</p>
</td>
<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">
<span class="kn">package</span> <span class="nx">main</span>
</pre>
@ -65,8 +65,9 @@ message. Here&rsquo;s the full source code.</p>
<tr>
<td class="docs">
<p>To run the program, put the code in <code>hello-world.go</code> and
use <code>go run</code>.</p>
<p>Para rodar o programa, insira o código no arquivo
<code>hello-world.go</code> e em seguida, execute o comando
<code>go run</code>.</p>
</td>
<td class="code leading">
@ -79,8 +80,8 @@ use <code>go run</code>.</p>
<tr>
<td class="docs">
<p>Sometimes we&rsquo;ll want to build our programs into
binaries. We can do this using <code>go build</code>.</p>
<p>Por vezes é útil ter nossos programas em binário.
É possível fazer isso por meio do comando <code>go build</code></p>
</td>
<td class="code leading">
@ -94,7 +95,8 @@ binaries. We can do this using <code>go build</code>.</p>
<tr>
<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 class="code leading">
@ -107,8 +109,8 @@ binaries. We can do this using <code>go build</code>.</p>
<tr>
<td class="docs">
<p>Now that we can run and build basic Go programs, let&rsquo;s
learn more about the language.</p>
<p>Agora que conseguimos executar e gerar programas
em Go, vamos aprender mais sobre a linguagem.</p>
</td>
<td class="code empty">
@ -121,12 +123,12 @@ learn more about the language.</p>
<p class="next">
Next example: <a href="values">Values</a>.
Próximo exemplo: <a href="values">Values</a>.
</p>
<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>
</div>

8
public/http-client generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: HTTP Client</title>
<title>Go Em Exemplos: HTTP Client</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -34,7 +34,7 @@ HTTP requests.</p>
</td>
<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">
<span class="kn">package</span> <span class="nx">main</span>
</pre>
@ -155,12 +155,12 @@ settings.</p>
<p class="next">
Next example: <a href="http-server">HTTP Server</a>.
Próximo exemplo: <a href="http-server">HTTP Server</a>.
</p>
<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>
</div>

8
public/http-server generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: HTTP Server</title>
<title>Go Em Exemplos: HTTP Server</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -32,7 +32,7 @@
</td>
<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">
<span class="kn">package</span> <span class="nx">main</span>
</pre>
@ -196,12 +196,12 @@ router we&rsquo;ve just set up.</p>
<p class="next">
Next example: <a href="context">Context</a>.
Próximo exemplo: <a href="context">Context</a>.
</p>
<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>
</div>

52
public/if-else generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: If/Else</title>
<title>Go Em Exemplos: If/Else</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -27,8 +27,7 @@
<tr>
<td class="docs">
<p>Branching with <code>if</code> and <code>else</code> in Go is
straight-forward.</p>
<p>A condicional <code>if</code> e <code>else</code> em Go é bem direta.</p>
</td>
<td class="code empty leading">
@ -42,7 +41,7 @@ straight-forward.</p>
</td>
<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>
</td>
@ -72,16 +71,16 @@ straight-forward.</p>
<tr>
<td class="docs">
<p>Here&rsquo;s a basic example.</p>
<p>Aqui está um exemplo básico.</p>
</td>
<td class="code leading">
<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="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="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>
</pre>
</td>
@ -89,14 +88,14 @@ straight-forward.</p>
<tr>
<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 class="code leading">
<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="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>
</pre>
</td>
@ -104,20 +103,20 @@ straight-forward.</p>
<tr>
<td class="docs">
<p>A statement can precede conditionals; any variables
declared in this statement are available in the current
and all subsequent branches.</p>
<p>Declarações podem preceder as condições; qualquer
variável declarada na estrutura condicional ficará
disponível em todas as suas ramificações.</p>
</td>
<td class="code leading">
<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="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="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="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>
</pre>
@ -126,8 +125,9 @@ and all subsequent branches.</p>
<tr>
<td class="docs">
<p>Note that you don&rsquo;t need parentheses around conditions
in Go, but that the braces are required.</p>
<p>É importante lembrar que não é necessário envelopar
condicionais com parenteses em Go, no entanto,
as chaves {} são necessárias.</p>
</td>
<td class="code empty">
@ -147,17 +147,17 @@ in Go, but that the braces are required.</p>
<td class="code leading">
<pre class="chroma"><span class="gp">$</span> go run if-else.go
<span class="go">7 is odd
</span><span class="go">8 is divisible by 4
</span><span class="go">9 has 1 digit</span></pre>
<span class="go">7 é ímpar
</span><span class="go">8 é divisível por 4
</span><span class="go">9 possui 1 dígito</span></pre>
</td>
</tr>
<tr>
<td class="docs">
<p>There is no <a href="https://en.wikipedia.org/wiki/%3F:">ternary if</a>
in Go, so you&rsquo;ll need to use a full <code>if</code> statement even
for basic conditions.</p>
<p>Não há <a href="https://en.wikipedia.org/wiki/%3F:">operador ternário</a>
em Go, então é necessário utilizar <code>if</code>
mesmo para condições básicas.</p>
</td>
<td class="code empty">
@ -170,18 +170,18 @@ for basic conditions.</p>
<p class="next">
Next example: <a href="switch">Switch</a>.
Próximo exemplo: <a href="switch">Switch</a>.
</p>
<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>
</div>
<script>
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 src="site.js" async></script>
</body>

32
public/index.html generated
View File

@ -2,27 +2,27 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example</title>
<title>Go Em Exemplos</title>
<link rel=stylesheet href="site.css">
</head>
<body>
<div id="intro">
<h2><a href="./">Go by Example</a></h2>
<h2><a href="./">Go Em Exemplos</a></h2>
<p>
<a href="https://go.dev">Go</a> is an
open source programming language designed for
building simple, fast, and reliable software.
Please read the official
<a href="https://go.dev/doc/tutorial/getting-started">documentation</a>
to learn a bit about Go code, tools packages,
and modules.
<a href="https://go.dev">Go</a> é uma
linguagem de programação de código aberto construída para
gerar softwares simples, rápidos e confiáveis.
Leia a
<a href="https://go.dev/doc/tutorial/getting-started">documentação oficial</a>
para aprender mais sobre Go, suas ferramentas, pacotes
e módulos.
</p>
<p>
<em>Go by Example</em> is a hands-on introduction
to Go using annotated example programs. Check out
the <a href="hello-world">first example</a> or
browse the full list below.
<em>Go by Example</em> é uma intrudução prática
ao Go que utiliza exemplos de programas comentados.
Confira o <a href="hello-world">primeiro exemplo</a> ou
visualize a lista completa a seguir.
</p>
<ul>
@ -179,9 +179,9 @@
<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>
@ -190,7 +190,7 @@
</ul>
<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>
</div>

8
public/interfaces generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Interfaces</title>
<title>Go Em Exemplos: Interfaces</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -42,7 +42,7 @@ signatures.</p>
</td>
<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>
</td>
@ -222,12 +222,12 @@ these structs as arguments to <code>measure</code>.</p>
<p class="next">
Next example: <a href="struct-embedding">Struct Embedding</a>.
Próximo exemplo: <a href="struct-embedding">Struct Embedding</a>.
</p>
<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>
</div>

8
public/json generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: JSON</title>
<title>Go Em Exemplos: JSON</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -43,7 +43,7 @@ data types.</p>
</td>
<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>
</td>
@ -398,12 +398,12 @@ for more.</p>
<p class="next">
Next example: <a href="xml">XML</a>.
Próximo exemplo: <a href="xml">XML</a>.
</p>
<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>
</div>

8
public/line-filters generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Line Filters</title>
<title>Go Em Exemplos: Line Filters</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -47,7 +47,7 @@ pattern to write your own Go line filters.</p>
</td>
<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">
<span class="kn">package</span> <span class="nx">main</span>
</pre>
@ -189,12 +189,12 @@ lowercase lines.</p>
<p class="next">
Next example: <a href="file-paths">File Paths</a>.
Próximo exemplo: <a href="file-paths">File Paths</a>.
</p>
<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>
</div>

81
public/maps generated
View File

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

8
public/methods generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Methods</title>
<title>Go Em Exemplos: Methods</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -41,7 +41,7 @@
</td>
<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>
</td>
@ -182,12 +182,12 @@ naming related sets of methods: interfaces.</p>
<p class="next">
Next example: <a href="interfaces">Interfaces</a>.
Próximo exemplo: <a href="interfaces">Interfaces</a>.
</p>
<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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<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">
</head>
<script>
@ -27,9 +27,10 @@
<tr>
<td class="docs">
<p>Go has built-in support for <em>multiple return values</em>.
This feature is used often in idiomatic Go, for example
to return both result and error values from a function.</p>
<p>Go tem suporte nativo para <em>múltiplos valores de retorno</em>.
Esse recurso é utilizado frequentemente
em Go idiomático, por exemplo, para retornar
valores de resultado e de erro de uma função.</p>
</td>
<td class="code empty leading">
@ -43,7 +44,7 @@ to return both result and error values from a function.</p>
</td>
<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>
</td>
@ -62,8 +63,8 @@ to return both result and error values from a function.</p>
<tr>
<td class="docs">
<p>The <code>(int, int)</code> in this function signature shows that
the function returns 2 <code>int</code>s.</p>
<p>A expressão <code>(int, int)</code> na assinatura desta função
demonstra que a função retorna dois inteiros <code>int</code>.</p>
</td>
<td class="code leading">
@ -89,8 +90,8 @@ the function returns 2 <code>int</code>s.</p>
<tr>
<td class="docs">
<p>Here we use the 2 different return values from the
call with <em>multiple assignment</em>.</p>
<p>Aqui são utilizados ambos valores retornados
da função com <em>atribuição múltipla</em>.</p>
</td>
<td class="code leading">
@ -105,8 +106,8 @@ call with <em>multiple assignment</em>.</p>
<tr>
<td class="docs">
<p>If you only want a subset of the returned values,
use the blank identifier <code>_</code>.</p>
<p>Para utilizar apenas um dos valores retornados,
utiliza-se o identificador vazio <code>_</code>.</p>
</td>
<td class="code">
@ -138,8 +139,9 @@ use the blank identifier <code>_</code>.</p>
<tr>
<td class="docs">
<p>Accepting a variable number of arguments is another nice
feature of Go functions; we&rsquo;ll look at this next.</p>
<p>Aceitar um número variável de argumentos é outro
ótimo recurso de Go functions; será apresentado
no próximo exemplo.</p>
</td>
<td class="code empty">
@ -152,12 +154,12 @@ feature of Go functions; we&rsquo;ll look at this next.</p>
<p class="next">
Next example: <a href="variadic-functions">Variadic Functions</a>.
Próximo exemplo: <a href="variadic-functions">Variadic Functions</a>.
</p>
<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>
</div>

8
public/mutexes generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Mutexes</title>
<title>Go Em Exemplos: Mutexes</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -44,7 +44,7 @@ to safely access data across multiple goroutines.</p>
</td>
<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>
</td>
@ -236,12 +236,12 @@ management task using only goroutines and channels.</p>
<p class="next">
Next example: <a href="stateful-goroutines">Stateful Goroutines</a>.
Próximo exemplo: <a href="stateful-goroutines">Stateful Goroutines</a>.
</p>
<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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<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">
</head>
<script>
@ -44,7 +44,7 @@ non-blocking multi-way <code>select</code>s.</p>
</td>
<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>
</td>
@ -162,12 +162,12 @@ on both <code>messages</code> and <code>signals</code>.</p>
<p class="next">
Next example: <a href="closing-channels">Closing Channels</a>.
Próximo exemplo: <a href="closing-channels">Closing Channels</a>.
</p>
<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>
</div>

8
public/number-parsing generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Number Parsing</title>
<title>Go Em Exemplos: Number Parsing</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -42,7 +42,7 @@ in many programs; here&rsquo;s how to do it in Go.</p>
</td>
<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>
</td>
@ -200,12 +200,12 @@ bits.</p>
<p class="next">
Next example: <a href="url-parsing">URL Parsing</a>.
Próximo exemplo: <a href="url-parsing">URL Parsing</a>.
</p>
<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>
</div>

8
public/panic generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Panic</title>
<title>Go Em Exemplos: Panic</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -44,7 +44,7 @@ aren&rsquo;t prepared to handle gracefully.</p>
</td>
<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>
</td>
@ -171,12 +171,12 @@ to use error-indicating return values wherever possible.</p>
<p class="next">
Next example: <a href="defer">Defer</a>.
Próximo exemplo: <a href="defer">Defer</a>.
</p>
<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>
</div>

8
public/pointers generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Pointers</title>
<title>Go Em Exemplos: Pointers</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -43,7 +43,7 @@ within your program.</p>
</td>
<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>
</td>
@ -179,12 +179,12 @@ the memory address for that variable.</p>
<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 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>
</div>

8
public/random-numbers generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Random Numbers</title>
<title>Go Em Exemplos: Random Numbers</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -43,7 +43,7 @@ generation.</p>
</td>
<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>
</td>
@ -221,12 +221,12 @@ that Go can provide.</p>
<p class="next">
Next example: <a href="number-parsing">Number Parsing</a>.
Próximo exemplo: <a href="number-parsing">Number Parsing</a>.
</p>
<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>
</div>

57
public/range generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Range</title>
<title>Go Em Exemplos: Range</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -27,9 +27,10 @@
<tr>
<td class="docs">
<p><em>range</em> iterates over elements in a variety of data
structures. Let&rsquo;s see how to use <code>range</code> with some
of the data structures we&rsquo;ve already learned.</p>
<p><em>range</em> itera sobre elementos de uma variedade
de estrutura de dados. Aqui será demonstrado como
utilizá-lo com algumas das estruturas de dados já
apresentadas.</p>
</td>
<td class="code empty leading">
@ -43,7 +44,7 @@ of the data structures we&rsquo;ve already learned.</p>
</td>
<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>
</td>
@ -73,8 +74,8 @@ of the data structures we&rsquo;ve already learned.</p>
<tr>
<td class="docs">
<p>Here we use <code>range</code> to sum the numbers in a slice.
Arrays work like this too.</p>
<p>Aqui é utilizado o <code>range</code> para somar os números
de um slice. Funciona da mesma forma em arrays.</p>
</td>
<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="nx">sum</span> <span class="o">+=</span> <span class="nx">num</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>
</td>
</tr>
<tr>
<td class="docs">
<p><code>range</code> on arrays and slices provides both the
index and value for each entry. Above we didn&rsquo;t
need the index, so we ignored it with the
blank identifier <code>_</code>. Sometimes we actually want
the indexes though.</p>
<p><code>range</code> tanto em arrays quanto em slices fornece
chave e valor; ou índice e valor para cada entrada.
No exemplo acima não foi necessário o índice, então
foi ignorado com identificador vazio <code>_</code>.
Algumas vezes, entretanto, os índices serão necessários.</p>
</td>
<td class="code leading">
@ -104,7 +105,7 @@ the indexes though.</p>
<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">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>
</pre>
@ -113,7 +114,7 @@ the indexes though.</p>
<tr>
<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 class="code leading">
@ -129,7 +130,7 @@ the indexes though.</p>
<tr>
<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 class="code leading">
@ -144,18 +145,18 @@ the indexes though.</p>
<tr>
<td class="docs">
<p><code>range</code> on strings iterates over Unicode code
points. The first value is the starting byte index
of the <code>rune</code> and the second the <code>rune</code> itself.
See <a href="strings-and-runes">Strings and Runes</a> for more
details.</p>
<p><code>range</code> em strings itera sobre pontos de código Unicode.
O primeiro valor é o byte de índice de início da <code>rune</code>,
e o segundo, da própria <code>rune</code>.
Veja a seção <a href="strings-and-runes">Strings and Runes</a>
para mais detalhes.</p>
</td>
<td class="code">
<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="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="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="kt">rune</span><span class="p">)</span>
<span class="p">}</span>
<span class="p">}</span>
</pre>
@ -173,8 +174,8 @@ details.</p>
<td class="code">
<pre class="chroma"><span class="gp">$</span> go run range.go
<span class="go">sum: 9
</span><span class="go">index: 1
<span class="go">soma: 9
</span><span class="go">índice: 1
</span><span class="go">a -&gt; apple
</span><span class="go">b -&gt; banana
</span><span class="go">key: a
@ -188,18 +189,18 @@ details.</p>
<p class="next">
Next example: <a href="functions">Functions</a>.
Próximo exemplo: <a href="functions">Functions</a>.
</p>
<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>
</div>
<script>
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 src="site.js" async></script>
</body>

View File

@ -2,7 +2,7 @@
<html>
<head>
<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">
</head>
<script>
@ -44,7 +44,7 @@ values received from a channel.</p>
</td>
<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>
</td>
@ -140,12 +140,12 @@ values be received.</p>
<p class="next">
Next example: <a href="timers">Timers</a>.
Próximo exemplo: <a href="timers">Timers</a>.
</p>
<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>
</div>

8
public/rate-limiting generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Rate Limiting</title>
<title>Go Em Exemplos: Rate Limiting</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -45,7 +45,7 @@ channels, and <a href="tickers">tickers</a>.</p>
</td>
<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>
</td>
@ -247,12 +247,12 @@ then serve the remaining 2 with ~200ms delays each.</p>
<p class="next">
Next example: <a href="atomic-counters">Atomic Counters</a>.
Próximo exemplo: <a href="atomic-counters">Atomic Counters</a>.
</p>
<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>
</div>

8
public/reading-files generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Reading Files</title>
<title>Go Em Exemplos: Reading Files</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -43,7 +43,7 @@ reading files.</p>
</td>
<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>
</td>
@ -272,12 +272,12 @@ be scheduled immediately after <code>Open</code>ing with
<p class="next">
Next example: <a href="writing-files">Writing Files</a>.
Próximo exemplo: <a href="writing-files">Writing Files</a>.
</p>
<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>
</div>

8
public/recover generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Recover</title>
<title>Go Em Exemplos: Recover</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -60,7 +60,7 @@ does by default for HTTP servers.</p>
</td>
<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>
</td>
@ -181,12 +181,12 @@ panic and resumes in the deferred closure.</p>
<p class="next">
Next example: <a href="string-functions">String Functions</a>.
Próximo exemplo: <a href="string-functions">String Functions</a>.
</p>
<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>
</div>

8
public/recursion generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Recursion</title>
<title>Go Em Exemplos: Recursion</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -43,7 +43,7 @@ Here&rsquo;s a classic example.</p>
</td>
<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>
</td>
@ -167,12 +167,12 @@ knows which function to call with <code>fib</code> here.</p>
<p class="next">
Next example: <a href="pointers">Pointers</a>.
Próximo exemplo: <a href="pointers">Pointers</a>.
</p>
<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>
</div>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Regular Expressions</title>
<title>Go Em Exemplos: Regular Expressions</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -43,7 +43,7 @@ in Go.</p>
</td>
<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>
</td>
@ -329,12 +329,12 @@ the <a href="https://pkg.go.dev/regexp"><code>regexp</code></a> package docs.</p
<p class="next">
Next example: <a href="json">JSON</a>.
Próximo exemplo: <a href="json">JSON</a>.
</p>
<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>
</div>

8
public/select generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Select</title>
<title>Go Em Exemplos: Select</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -43,7 +43,7 @@ select is a powerful feature of Go.</p>
</td>
<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>
</td>
@ -169,12 +169,12 @@ concurrently.</p>
<p class="next">
Next example: <a href="timeouts">Timeouts</a>.
Próximo exemplo: <a href="timeouts">Timeouts</a>.
</p>
<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>
</div>

8
public/sha256-hashes generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: SHA256 Hashes</title>
<title>Go Em Exemplos: SHA256 Hashes</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -45,7 +45,7 @@ SHA256 hashes in Go.</p>
</td>
<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>
</td>
@ -185,12 +185,12 @@ you should carefully research
<p class="next">
Next example: <a href="base64-encoding">Base64 Encoding</a>.
Próximo exemplo: <a href="base64-encoding">Base64 Encoding</a>.
</p>
<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>
</div>

10
public/signals generated
View File

@ -2,14 +2,14 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Signals</title>
<title>Go Em Exemplos: Signals</title>
<link rel=stylesheet href="site.css">
</head>
<script>
onkeydown = (e) => {
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 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>
</td>
@ -199,12 +199,12 @@ causing the program to print <code>interrupt</code> and then exit.</p>
<p class="next">
Next example: <a href="exit">Exit</a>.
Próximo exemplo: <a href="exit">Exit</a>.
</p>
<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>
</div>

128
public/slices generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Slices</title>
<title>Go Em Exemplos: Slices</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -27,8 +27,9 @@
<tr>
<td class="docs">
<p><em>Slices</em> are an important data type in Go, giving
a more powerful interface to sequences than arrays.</p>
<p><em>Slices</em> é um importante tipo de dado em Go,
oferecendo uma interface mais completa do que
arrays para lidar com sequências.</p>
</td>
<td class="code empty leading">
@ -42,7 +43,7 @@ a more powerful interface to sequences than arrays.</p>
</td>
<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>
</td>
@ -72,25 +73,27 @@ a more powerful interface to sequences than arrays.</p>
<tr>
<td class="docs">
<p>Unlike arrays, slices are typed only by the
elements they contain (not the number of elements).
To create an empty slice with non-zero length, use
the builtin <code>make</code>. Here we make a slice of
<code>string</code>s of length <code>3</code> (initially zero-valued).</p>
<p>Diferente de arrays, slices são tipados apenas com
tipo dos elementos que armazenará (sem um tamanho).
Para criar um slice vazio, com tamanho não zero,
deve-se usar o comando nativo <code>make</code>. Aqui é feito
um slice de <code>string</code>, com tamanho 3
(inicialmente com valor padrão zero).</p>
</td>
<td class="code leading">
<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">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>
</td>
</tr>
<tr>
<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 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">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">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;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;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;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>
</td>
</tr>
<tr>
<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 class="code leading">
@ -120,12 +124,12 @@ the builtin <code>make</code>. Here we make a slice of
<tr>
<td class="docs">
<p>In addition to these basic operations, slices
support several more that make them richer than
arrays. One is the builtin <code>append</code>, which
returns a slice containing one or more new values.
Note that we need to accept a return value from
<code>append</code> as we may get a new slice value.</p>
<p>Em adição a estas operações básicas, slices
suportam muitas outras que as fazem mais úteis do que
arrays. Uma delas é a função nativa <code>append</code>, que
retorna a slice contendo um ou mais novos valores.
Note que é preciso aceitar o valor retornado da função
<code>append</code> para ter a slice atualizada.</p>
</td>
<td class="code leading">
@ -133,16 +137,16 @@ Note that we need to accept a return value from
<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;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>
</td>
</tr>
<tr>
<td class="docs">
<p>Slices can also be <code>copy</code>&rsquo;d. Here we create an
empty slice <code>c</code> of the same length as <code>s</code> and copy
into <code>c</code> from <code>s</code>.</p>
<p>Slices também podem ser copiadas com <code>copy</code>. Aqui
é criado uma slice vazia <code>c</code> do mesmo tamanho da
slice <code>s</code>. Então, a slice <code>s</code> é copiada para <code>c</code>.</p>
</td>
<td class="code leading">
@ -150,75 +154,78 @@ into <code>c</code> from <code>s</code>.</p>
<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="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>
</td>
</tr>
<tr>
<td class="docs">
<p>Slices support a &ldquo;slice&rdquo; operator with the syntax
<code>slice[low:high]</code>. For example, this gets a slice
of the elements <code>s[2]</code>, <code>s[3]</code>, and <code>s[4]</code>.</p>
<p>Slices suportam um operador &ldquo;slice&rdquo; com a sintaxe
<code>slice[índiceBaixo:índiceAlto]</code>. Por exemplo, o
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 class="code leading">
<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">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>
</td>
</tr>
<tr>
<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 class="code leading">
<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">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>
</td>
</tr>
<tr>
<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 class="code leading">
<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">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>
</td>
</tr>
<tr>
<td class="docs">
<p>We can declare and initialize a variable for slice
in a single line as well.</p>
<p>Também é possível declarar e inicializar um
slice em apenas uma linha.</p>
</td>
<td class="code leading">
<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">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>
</td>
</tr>
<tr>
<td class="docs">
<p>Slices can be composed into multi-dimensional data
structures. The length of the inner slices can
vary, unlike with multi-dimensional arrays.</p>
<p>Slices podem ser compsotas em estruturas
multi-dimensionais. O tamanho das slices internas
pode variar, diferente de arrays multi-dimensionais.</p>
</td>
<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="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>
</pre>
</td>
@ -244,33 +251,34 @@ vary, unlike with multi-dimensional arrays.</p>
<tr>
<td class="docs">
<p>Note that while slices are different types than arrays,
they are rendered similarly by <code>fmt.Println</code>.</p>
<p>Note que enquanto slices são tipos diferentes
de arrays, eles são exibidos de maneira similar
pelo comando <code>fmt.Println</code>.</p>
</td>
<td class="code leading">
<pre class="chroma">
<span class="gp">$</span> go run slices.go
<span class="go">emp: [ ]
</span><span class="go">set: [a b c]
</span><span class="go">get: c
<span class="go">vazio: [ ]
</span><span class="go">exibe slice: [a b c]
</span><span class="go">valor índice 2: c
</span><span class="go">len: 3
</span><span class="go">apd: [a b c d e f]
</span><span class="go">cpy: [a b c d e f]
</span><span class="go">sl1: [c d e]
</span><span class="go">sl2: [a b c d e]
</span><span class="go">sl3: [c d e f]
</span><span class="go">dcl: [g h i]
</span><span class="go">2d: [[0] [1 2] [2 3 4]]</span></pre>
</span><span class="go">slice com acréscimo: [a b c d e f]
</span><span class="go">slice copiada: [a b c d e f]
</span><span class="go">slice 1: [c d e]
</span><span class="go">slice 2: [a b c d e]
</span><span class="go">slice 3: [c d e f]
</span><span class="go">slice inicializada: [g h i]
</span><span class="go">bi-dimensional: [[0] [1 2] [2 3 4]]</span></pre>
</td>
</tr>
<tr>
<td class="docs">
<p>Check out this <a href="https://go.dev/blog/slices-intro">great blog post</a>
by the Go team for more details on the design and
implementation of slices in Go.</p>
<p>Veja esse <a href="https://go.dev/blog/slices-intro">post</a>
do time de Go para mais detalhes sobre o design e
implementação de slices na linguagem.</p>
</td>
<td class="code empty leading">
@ -281,8 +289,8 @@ implementation of slices in Go.</p>
<tr>
<td class="docs">
<p>Now that we&rsquo;ve seen arrays and slices we&rsquo;ll look at
Go&rsquo;s other key builtin data structure: maps.</p>
<p>Agora que vimos arrays e slices, passaremos a estudar
outra estrutura de dados nativa de Go: maps.</p>
</td>
<td class="code empty">
@ -295,18 +303,18 @@ Go&rsquo;s other key builtin data structure: maps.</p>
<p class="next">
Next example: <a href="maps">Maps</a>.
Próximo exemplo: <a href="maps">Maps</a>.
</p>
<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>
</div>
<script>
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 src="site.js" async></script>
</body>

8
public/sorting generated
View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: Sorting</title>
<title>Go Em Exemplos: Sorting</title>
<link rel=stylesheet href="site.css">
</head>
<script>
@ -43,7 +43,7 @@ builtins first.</p>
</td>
<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>
</td>
@ -147,12 +147,12 @@ slices and <code>true</code> as the result of our <code>AreSorted</code> test.</
<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 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>
</div>

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