Improving links (http -> https) (#425)
This commit is contained in:
parent
25d2811293
commit
da13e2fbe7
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
go-version: [1.18.0]
|
||||
go-version: [1.18.3]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
@ -55,7 +55,7 @@ $ tools/upload
|
||||
This work is copyright Mark McGranaghan and licensed under a
|
||||
[Creative Commons Attribution 3.0 Unported License](http://creativecommons.org/licenses/by/3.0/).
|
||||
|
||||
The Go Gopher is copyright [Renée French](http://reneefrench.blogspot.com/) and licensed under a
|
||||
The Go Gopher is copyright [Renée French](https://reneefrench.blogspot.com/) and licensed under a
|
||||
[Creative Commons Attribution 3.0 Unported License](http://creativecommons.org/licenses/by/3.0/).
|
||||
|
||||
|
||||
@ -66,12 +66,12 @@ Contributor translations of the Go by Example site are available in:
|
||||
* [Chinese](https://gobyexample-cn.github.io/) by [gobyexample-cn](https://github.com/gobyexample-cn)
|
||||
* [Czech](http://gobyexamples.sweb.cz/) by [martinkunc](https://github.com/martinkunc/gobyexample-cz)
|
||||
* [French](http://le-go-par-l-exemple.keiruaprod.fr) by [keirua](https://github.com/keirua/gobyexample)
|
||||
* [Italian](http://gobyexample.it) by the [Go Italian community](https://github.com/golangit/gobyexample-it)
|
||||
* [Italian](https://gobyexample.it) by the [Go Italian community](https://github.com/golangit/gobyexample-it)
|
||||
* [Japanese](http://spinute.org/go-by-example) by [spinute](https://github.com/spinute)
|
||||
* [Korean](https://mingrammer.com/gobyexample/) by [mingrammer](https://github.com/mingrammer)
|
||||
* [Russian](https://gobyexample.com.ru/) by [badkaktus](https://github.com/badkaktus)
|
||||
* [Spanish](http://goconejemplos.com) by the [Go Mexico community](https://github.com/dabit/gobyexample)
|
||||
* [Ukrainian](http://butuzov.github.io/gobyexample/) by [butuzov](https://github.com/butuzov/gobyexample)
|
||||
* [Ukrainian](https://butuzov.github.io/gobyexample/) by [butuzov](https://github.com/butuzov/gobyexample)
|
||||
|
||||
### Thanks
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Go provides built-in support for [base64
|
||||
// encoding/decoding](http://en.wikipedia.org/wiki/Base64).
|
||||
// encoding/decoding](https://en.wikipedia.org/wiki/Base64).
|
||||
|
||||
package main
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
cd00d89ad0a31e48d6a2e2adc2e8d65b0f70dc73
|
||||
S7ff3UgzNlG
|
||||
47f0317643bc5107af6fae64cb0fdad1260ead37
|
||||
yztzkirFEvv
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Go supports [_anonymous functions_](http://en.wikipedia.org/wiki/Anonymous_function),
|
||||
// which can form <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)"><em>closures</em></a>.
|
||||
// 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.
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
6713bdbb6de0d7d484422517dd77316c8b9f0a7a
|
||||
66Lgw9iIIch
|
||||
6514e124c8127250a2eecfadc9708181e51f9603
|
||||
NpgpzS8ZG8y
|
||||
|
@ -1,4 +1,4 @@
|
||||
// [_Command-line arguments_](http://en.wikipedia.org/wiki/Command-line_interface#Arguments)
|
||||
// [_Command-line arguments_](https://en.wikipedia.org/wiki/Command-line_interface#Arguments)
|
||||
// are a common way to parameterize execution of programs.
|
||||
// For example, `go run hello.go` uses `run` and
|
||||
// `hello.go` arguments to the `go` program.
|
||||
|
@ -1,2 +1,2 @@
|
||||
d60d1c9cb5dbbb748cf3b692334076951cea7d59
|
||||
oSxtj7v_v1K
|
||||
ad871e829d1457d97d0f1c1af77e39f6942ac5a5
|
||||
UYCEvh9d2Zb
|
||||
|
@ -1,4 +1,4 @@
|
||||
// [_Command-line flags_](http://en.wikipedia.org/wiki/Command-line_interface#Command-line_option)
|
||||
// [_Command-line flags_](https://en.wikipedia.org/wiki/Command-line_interface#Command-line_option)
|
||||
// are a common way to specify options for command-line
|
||||
// programs. For example, in `wc -l` the `-l` is a
|
||||
// command-line flag.
|
||||
|
@ -1,2 +1,2 @@
|
||||
08e716a5ee3b5f74ef826d7b5ce157cb3b44c4f7
|
||||
-zzqphwtdJq
|
||||
9cca50e58f488570cc8e92dde37582ea5ee04bf3
|
||||
IUPZlYSigc3
|
||||
|
@ -1,6 +1,6 @@
|
||||
// [Environment variables](http://en.wikipedia.org/wiki/Environment_variable)
|
||||
// [Environment variables](https://en.wikipedia.org/wiki/Environment_variable)
|
||||
// are a universal mechanism for [conveying configuration
|
||||
// information to Unix programs](http://www.12factor.net/config).
|
||||
// information to Unix programs](https://www.12factor.net/config).
|
||||
// Let's look at how to set, get, and list environment variables.
|
||||
|
||||
package main
|
||||
|
@ -1,2 +1,2 @@
|
||||
bee983e7820d64dec5331dc706c08f6135b5c632
|
||||
KuD8tDyB4lQ
|
||||
f480d3803659977183a4bc5c14da26c80b1d31fe
|
||||
2jmwXM264NC
|
||||
|
@ -1,6 +1,6 @@
|
||||
// A common requirement in programs is getting the number
|
||||
// of seconds, milliseconds, or nanoseconds since the
|
||||
// [Unix epoch](http://en.wikipedia.org/wiki/Unix_time).
|
||||
// [Unix epoch](https://en.wikipedia.org/wiki/Unix_time).
|
||||
// Here's how to do it in Go.
|
||||
|
||||
package main
|
||||
|
@ -1,2 +1,2 @@
|
||||
54e66c2e84334f2adbf87aaeb62065111c5644ea
|
||||
iG_EcjJp4ss
|
||||
a67ae165a1f00c205a344327d9d638f4eb931b5c
|
||||
lRmD1EWHHPz
|
||||
|
@ -6,5 +6,5 @@ f2 failed: 42 - can't work with it
|
||||
42
|
||||
can't work with it
|
||||
|
||||
# See this [great post](http://blog.golang.org/2011/07/error-handling-and-go.html)
|
||||
# See this [great post](https://go.dev/blog/error-handling-and-go)
|
||||
# on the Go blog for more on error handling.
|
||||
|
@ -5,7 +5,7 @@
|
||||
// completely replace the current Go process with another
|
||||
// (perhaps non-Go) one. To do this we'll use Go's
|
||||
// implementation of the classic
|
||||
// <a href="http://en.wikipedia.org/wiki/Exec_(operating_system)"><code>exec</code></a>
|
||||
// <a href="https://en.wikipedia.org/wiki/Exec_(operating_system)"><code>exec</code></a>
|
||||
// function.
|
||||
|
||||
package main
|
||||
|
@ -1,2 +1,2 @@
|
||||
18867a0e743aaadb2aba0a0c7b1ca8098a1aa95c
|
||||
nI-HMuCI2lG
|
||||
568ae983493addff02d2ce8df57f41daf537f077
|
||||
s9qg7olf1dM
|
||||
|
@ -17,7 +17,7 @@ func main() {
|
||||
// object and calling its `Get` method; it uses the
|
||||
// `http.DefaultClient` object which has useful default
|
||||
// settings.
|
||||
resp, err := http.Get("http://gobyexample.com")
|
||||
resp, err := http.Get("https://gobyexample.com")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
fbc80f8cfcd34e9daa3c52c23f6720f6ef7019dc
|
||||
kHCcVLoz7nd
|
||||
1497e193431e4740f593039f613773daaf97772e
|
||||
vFW_el7oHMk
|
||||
|
@ -3,6 +3,6 @@ $ go run if-else.go
|
||||
8 is divisible by 4
|
||||
9 has 1 digit
|
||||
|
||||
# There is no [ternary if](http://en.wikipedia.org/wiki/%3F:)
|
||||
# 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.
|
||||
|
@ -7,4 +7,4 @@ $ go run interfaces.go
|
||||
31.41592653589793
|
||||
|
||||
# To learn more about Go's interfaces, check out this
|
||||
# [great blog post](http://jordanorelli.tumblr.com/post/32665860244/how-to-use-interfaces-in-go).
|
||||
# [great blog post](https://jordanorelli.tumblr.com/post/32665860244/how-to-use-interfaces-in-go).
|
||||
|
@ -16,6 +16,6 @@ apple
|
||||
|
||||
|
||||
# We've covered the basic of JSON in Go here, but check
|
||||
# out the [JSON and Go](http://blog.golang.org/2011/01/json-and-go.html)
|
||||
# blog post and [JSON package docs](http://golang.org/pkg/encoding/json/)
|
||||
# out the [JSON and Go](https://go.dev/blog/json)
|
||||
# blog post and [JSON package docs](https://pkg.go.dev/encoding/json)
|
||||
# for more.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// _Maps_ are Go's built-in [associative data type](http://en.wikipedia.org/wiki/Associative_array)
|
||||
// _Maps_ are Go's built-in [associative data type](https://en.wikipedia.org/wiki/Associative_array)
|
||||
// (sometimes called _hashes_ or _dicts_ in other languages).
|
||||
|
||||
package main
|
||||
|
@ -1,2 +1,2 @@
|
||||
9e0e4535c99668b460c7175f8ff2edc2ccf58bec
|
||||
agK2Ro2i-Lu
|
||||
22d147fe9402f9ff210f12b9810811c07f4d64ca
|
||||
ulCzODwCde_0
|
||||
|
@ -1,6 +1,6 @@
|
||||
// In the previous example we saw how to manage simple
|
||||
// counter state using [atomic operations](atomic-counters).
|
||||
// For more complex state we can use a [_mutex_](http://en.wikipedia.org/wiki/Mutual_exclusion)
|
||||
// For more complex state we can use a [_mutex_](https://en.wikipedia.org/wiki/Mutual_exclusion)
|
||||
// to safely access data across multiple goroutines.
|
||||
|
||||
package main
|
||||
|
@ -1,2 +1,2 @@
|
||||
3688453f408d8c7cc6db91ab7fd5e0ac06ade7ea
|
||||
tDqeib2-yZA
|
||||
a437476f37f1f797e1bab491b3f2ac9b386f6700
|
||||
Kr_cdza5vyz
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Go supports <em><a href="http://en.wikipedia.org/wiki/Pointer_(computer_programming)">pointers</a></em>,
|
||||
// Go supports <em><a href="https://en.wikipedia.org/wiki/Pointer_(computer_programming)">pointers</a></em>,
|
||||
// allowing you to pass references to values and records
|
||||
// within your program.
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
c727916063ddc3e99199cd24bfbde37ff301c0b4
|
||||
oimmXypnAcs
|
||||
7f9855cfb983efc07415117e2be734f55a6bb64b
|
||||
OlWCLpxAyBz
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Go's `math/rand` package provides
|
||||
// [pseudorandom number](http://en.wikipedia.org/wiki/Pseudorandom_number_generator)
|
||||
// [pseudorandom number](https://en.wikipedia.org/wiki/Pseudorandom_number_generator)
|
||||
// generation.
|
||||
|
||||
package main
|
||||
|
@ -1,2 +1,2 @@
|
||||
102041ca421268afbd4b4e7687386bb65a8c7965
|
||||
PGklfJzErTN
|
||||
f0f88939692a32975d902c94066537a6ba5ab96f
|
||||
RaoKyUd9tgC
|
||||
|
@ -7,6 +7,6 @@ $ go run random-numbers.go
|
||||
5,87
|
||||
|
||||
|
||||
# See the [`math/rand`](http://golang.org/pkg/math/rand/)
|
||||
# See the [`math/rand`](https://pkg.go.dev/math/rand)
|
||||
# package docs for references on other random quantities
|
||||
# that Go can provide.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// [_Rate limiting_](http://en.wikipedia.org/wiki/Rate_limiting)
|
||||
// [_Rate limiting_](https://en.wikipedia.org/wiki/Rate_limiting)
|
||||
// is an important mechanism for controlling resource
|
||||
// utilization and maintaining quality of service. Go
|
||||
// elegantly supports rate limiting with goroutines,
|
||||
|
@ -1,2 +1,2 @@
|
||||
c7063265708287744ea172ed9ed1390043140718
|
||||
GXjXHfnKFXg
|
||||
4f327f5bd5ac199ae5590652563ea6ca4ce7eff5
|
||||
lqf7pC2FUeT
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Go supports
|
||||
// <a href="http://en.wikipedia.org/wiki/Recursion_(computer_science)"><em>recursive functions</em></a>.
|
||||
// <a href="https://en.wikipedia.org/wiki/Recursion_(computer_science)"><em>recursive functions</em></a>.
|
||||
// Here's a classic example.
|
||||
|
||||
package main
|
||||
|
@ -1,2 +1,2 @@
|
||||
9ac9b5af828c33eb20dd322fd1a991334242c4b3
|
||||
7hD-3-bIuSp
|
||||
cdbd1a6957b3e2d7d9baa9efe4581ba4f8f3e753
|
||||
MBTKk9VpAiK
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Go offers built-in support for [regular expressions](http://en.wikipedia.org/wiki/Regular_expression).
|
||||
// Go offers built-in support for [regular expressions](https://en.wikipedia.org/wiki/Regular_expression).
|
||||
// Here are some examples of common regexp-related tasks
|
||||
// in Go.
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
5c3bcf9f8c61fc074143f766c4517e445a6d9b0f
|
||||
htCqJrLdh9Q
|
||||
7fd60a9497546cb5c84242276ed79aecbde7e950
|
||||
fI2YIfYsCaL
|
||||
|
@ -14,4 +14,4 @@ a <fruit>
|
||||
a PEACH
|
||||
|
||||
# For a complete reference on Go regular expressions check
|
||||
# the [`regexp`](http://golang.org/pkg/regexp/) package docs.
|
||||
# the [`regexp`](https://pkg.go.dev/regexp) package docs.
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Sometimes we'd like our Go programs to intelligently
|
||||
// handle [Unix signals](http://en.wikipedia.org/wiki/Unix_signal).
|
||||
// handle [Unix signals](https://en.wikipedia.org/wiki/Unix_signal).
|
||||
// For example, we might want a server to gracefully
|
||||
// shutdown when it receives a `SIGTERM`, or a command-line
|
||||
// tool to stop processing input if it receives a `SIGINT`.
|
||||
|
@ -1,2 +1,2 @@
|
||||
cd15508731199185f3205692af0f80cbdee4fcd7
|
||||
LauPuRo3v9l
|
||||
739d6c0e33656817de5701412fe266c51730b532
|
||||
RKLAbvblJMQ
|
||||
|
@ -13,7 +13,7 @@ sl3: [c d e f]
|
||||
dcl: [g h i]
|
||||
2d: [[0] [1 2] [2 3 4]]
|
||||
|
||||
# Check out this [great blog post](http://blog.golang.org/2011/01/go-slices-usage-and-internals.html)
|
||||
# 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.
|
||||
|
||||
|
@ -20,7 +20,7 @@ func main() {
|
||||
// package, not methods on the string object itself,
|
||||
// we need pass the string in question as the first
|
||||
// argument to the function. You can find more
|
||||
// functions in the [`strings`](http://golang.org/pkg/strings/)
|
||||
// functions in the [`strings`](https://pkg.go.dev/strings)
|
||||
// package docs.
|
||||
p("Contains: ", s.Contains("test", "es"))
|
||||
p("Count: ", s.Count("test", "t"))
|
||||
|
@ -1,2 +1,2 @@
|
||||
e52d4023b8102ba47f3f97e67e47da1bfe393e6c
|
||||
mdta6dlNB6e
|
||||
a8fc7e03fd17f6d432adf2f0e991461630ce4350
|
||||
DSKkoyx9Rcy
|
||||
|
@ -1,4 +1,4 @@
|
||||
// [_Variadic functions_](http://en.wikipedia.org/wiki/Variadic_function)
|
||||
// [_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.
|
||||
|
@ -1,2 +1,2 @@
|
||||
560aaef6ce8867710f3ef609b1bb2317377a71bf
|
||||
Ua6kZOMabBp
|
||||
dd2e819d49c1110c7eb7dc198b62e0994e0ba93e
|
||||
7_-i75JEsmM
|
||||
|
2
public/arrays
generated
2
public/arrays
generated
@ -42,7 +42,7 @@ specific length.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/TaahifSGSwU"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<a href="https://go.dev/play/p/TaahifSGSwU"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/atomic-counters
generated
2
public/atomic-counters
generated
@ -46,7 +46,7 @@ counters</em> accessed by multiple goroutines.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/j-14agntvEO"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
4
public/base64-encoding
generated
4
public/base64-encoding
generated
@ -27,7 +27,7 @@
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>Go provides built-in support for <a href="http://en.wikipedia.org/wiki/Base64">base64
|
||||
<p>Go provides built-in support for <a href="https://en.wikipedia.org/wiki/Base64">base64
|
||||
encoding/decoding</a>.</p>
|
||||
|
||||
</td>
|
||||
@ -42,7 +42,7 @@ encoding/decoding</a>.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/S7ff3UgzNlG"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/channel-buffering
generated
2
public/channel-buffering
generated
@ -46,7 +46,7 @@ those values.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/3BRCdRnRszb"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/channel-directions
generated
2
public/channel-directions
generated
@ -44,7 +44,7 @@ the program.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/mjNJDHwUH4R"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/channel-synchronization
generated
2
public/channel-synchronization
generated
@ -45,7 +45,7 @@ you may prefer to use a <a href="waitgroups">WaitGroup</a>.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/Nw-1DzIGk5f"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/channels
generated
2
public/channels
generated
@ -44,7 +44,7 @@ goroutine.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/MaLY7AiAkHM"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/closing-channels
generated
2
public/closing-channels
generated
@ -43,7 +43,7 @@ completion to the channel’s receivers.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/vCvRjcMq7p3"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
6
public/closures
generated
6
public/closures
generated
@ -27,8 +27,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>Go supports <a href="http://en.wikipedia.org/wiki/Anonymous_function"><em>anonymous functions</em></a>,
|
||||
which can form <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)"><em>closures</em></a>.
|
||||
<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>
|
||||
|
||||
@ -44,7 +44,7 @@ a function inline without having to name it.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/66Lgw9iIIch"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
4
public/command-line-arguments
generated
4
public/command-line-arguments
generated
@ -27,7 +27,7 @@
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p><a href="http://en.wikipedia.org/wiki/Command-line_interface#Arguments"><em>Command-line arguments</em></a>
|
||||
<p><a href="https://en.wikipedia.org/wiki/Command-line_interface#Arguments"><em>Command-line arguments</em></a>
|
||||
are a common way to parameterize execution of programs.
|
||||
For example, <code>go run hello.go</code> uses <code>run</code> and
|
||||
<code>hello.go</code> arguments to the <code>go</code> program.</p>
|
||||
@ -44,7 +44,7 @@ For example, <code>go run hello.go</code> uses <code>run</code> and
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/oSxtj7v_v1K"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
4
public/command-line-flags
generated
4
public/command-line-flags
generated
@ -27,7 +27,7 @@
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p><a href="http://en.wikipedia.org/wiki/Command-line_interface#Command-line_option"><em>Command-line flags</em></a>
|
||||
<p><a href="https://en.wikipedia.org/wiki/Command-line_interface#Command-line_option"><em>Command-line flags</em></a>
|
||||
are a common way to specify options for command-line
|
||||
programs. For example, in <code>wc -l</code> the <code>-l</code> is a
|
||||
command-line flag.</p>
|
||||
@ -44,7 +44,7 @@ command-line flag.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/-zzqphwtdJq"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/command-line-subcommands
generated
2
public/command-line-subcommands
generated
@ -46,7 +46,7 @@ subcommands that have their own flags.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/DkvdHKK-XCv"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/constants
generated
2
public/constants
generated
@ -42,7 +42,7 @@ and numeric values.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/Vw-pXSfo9_b"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/context
generated
2
public/context
generated
@ -36,7 +36,7 @@ across API boundaries and goroutines.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/0_bu1o8rIBO"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma">
|
||||
<span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
|
2
public/defer
generated
2
public/defer
generated
@ -44,7 +44,7 @@ purposes of cleanup. <code>defer</code> is often used where e.g.
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/5SDVfc_jxbg"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/directories
generated
2
public/directories
generated
@ -42,7 +42,7 @@
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/cICbVSX51zI"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/embed-directive
generated
2
public/embed-directive
generated
@ -35,7 +35,7 @@ build time. Read more about the embed directive
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/p6JB_5z1IBJ"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<a href="https://go.dev/play/p/p6JB_5z1IBJ"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<pre class="chroma">
|
||||
<span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
|
6
public/environment-variables
generated
6
public/environment-variables
generated
@ -27,8 +27,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p><a href="http://en.wikipedia.org/wiki/Environment_variable">Environment variables</a>
|
||||
are a universal mechanism for <a href="http://www.12factor.net/config">conveying configuration
|
||||
<p><a href="https://en.wikipedia.org/wiki/Environment_variable">Environment variables</a>
|
||||
are a universal mechanism for <a href="https://www.12factor.net/config">conveying configuration
|
||||
information to Unix programs</a>.
|
||||
Let’s look at how to set, get, and list environment variables.</p>
|
||||
|
||||
@ -44,7 +44,7 @@ Let’s look at how to set, get, and list environment variables.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/KuD8tDyB4lQ"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
4
public/epoch
generated
4
public/epoch
generated
@ -29,7 +29,7 @@
|
||||
<td class="docs">
|
||||
<p>A common requirement in programs is getting the number
|
||||
of seconds, milliseconds, or nanoseconds since the
|
||||
<a href="http://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
|
||||
<a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
|
||||
Here’s how to do it in Go.</p>
|
||||
|
||||
</td>
|
||||
@ -44,7 +44,7 @@ Here’s how to do it in Go.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/iG_EcjJp4ss"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
4
public/errors
generated
4
public/errors
generated
@ -48,7 +48,7 @@ non-error tasks.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/NiJOpCPO3L0"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
@ -268,7 +268,7 @@ assertion.</p>
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>See this <a href="http://blog.golang.org/2011/07/error-handling-and-go.html">great post</a>
|
||||
<p>See this <a href="https://go.dev/blog/error-handling-and-go">great post</a>
|
||||
on the Go blog for more on error handling.</p>
|
||||
|
||||
</td>
|
||||
|
4
public/execing-processes
generated
4
public/execing-processes
generated
@ -34,7 +34,7 @@ a running Go process. Sometimes we just want to
|
||||
completely replace the current Go process with another
|
||||
(perhaps non-Go) one. To do this we’ll use Go’s
|
||||
implementation of the classic
|
||||
<a href="http://en.wikipedia.org/wiki/Exec_(operating_system)"><code>exec</code></a>
|
||||
<a href="https://en.wikipedia.org/wiki/Exec_(operating_system)"><code>exec</code></a>
|
||||
function.</p>
|
||||
|
||||
</td>
|
||||
@ -49,7 +49,7 @@ function.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/nI-HMuCI2lG"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<a href="https://go.dev/play/p/s9qg7olf1dM"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/exit
generated
2
public/exit
generated
@ -38,7 +38,7 @@ status.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/b9aYzlENkb__R"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/file-paths
generated
2
public/file-paths
generated
@ -34,7 +34,7 @@ between operating systems; <code>dir/file</code> on Linux vs.
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/5h3lUytvmyO"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma">
|
||||
<span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
|
2
public/for
generated
2
public/for
generated
@ -42,7 +42,7 @@ some basic types of <code>for</code> loops.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/2-4H-ArwHHS"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/functions
generated
2
public/functions
generated
@ -42,7 +42,7 @@ functions with a few different examples.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/-o49-dQfGbK"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/generics
generated
2
public/generics
generated
@ -42,7 +42,7 @@
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/YulcAofh266"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<a href="https://go.dev/play/p/YulcAofh266"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/goroutines
generated
2
public/goroutines
generated
@ -41,7 +41,7 @@
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/I7scqRijEJt"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/hello-world
generated
2
public/hello-world
generated
@ -28,7 +28,7 @@ message. Here’s the full source code.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/NeviD0awXjt"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma">
|
||||
<span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
|
6
public/http-clients
generated
6
public/http-clients
generated
@ -34,7 +34,7 @@ HTTP requests.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/kHCcVLoz7nd"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma">
|
||||
<span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
@ -79,7 +79,7 @@ settings.</p>
|
||||
<td class="code leading">
|
||||
|
||||
<pre class="chroma">
|
||||
<span class="nx">resp</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">http</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="s">"http://gobyexample.com"</span><span class="p">)</span>
|
||||
<span class="nx">resp</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">http</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="s">"https://gobyexample.com"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
|
||||
<span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
|
||||
<span class="p">}</span>
|
||||
@ -166,7 +166,7 @@ settings.</p>
|
||||
</div>
|
||||
<script>
|
||||
var codeLines = [];
|
||||
codeLines.push('package main\u000A');codeLines.push('import (\u000A \"bufio\"\u000A \"fmt\"\u000A \"net/http\"\u000A)\u000A');codeLines.push('func main() {\u000A');codeLines.push(' resp, err :\u003D http.Get(\"http://gobyexample.com\")\u000A if err !\u003D nil {\u000A panic(err)\u000A }\u000A defer resp.Body.Close()\u000A');codeLines.push(' fmt.Println(\"Response status:\", resp.Status)\u000A');codeLines.push(' scanner :\u003D bufio.NewScanner(resp.Body)\u000A for i :\u003D 0; scanner.Scan() \u0026\u0026 i \u003C 5; i++ {\u000A fmt.Println(scanner.Text())\u000A }\u000A');codeLines.push(' if err :\u003D scanner.Err(); err !\u003D nil {\u000A panic(err)\u000A }\u000A}\u000A');codeLines.push('');
|
||||
codeLines.push('package main\u000A');codeLines.push('import (\u000A \"bufio\"\u000A \"fmt\"\u000A \"net/http\"\u000A)\u000A');codeLines.push('func main() {\u000A');codeLines.push(' resp, err :\u003D http.Get(\"https://gobyexample.com\")\u000A if err !\u003D nil {\u000A panic(err)\u000A }\u000A defer resp.Body.Close()\u000A');codeLines.push(' fmt.Println(\"Response status:\", resp.Status)\u000A');codeLines.push(' scanner :\u003D bufio.NewScanner(resp.Body)\u000A for i :\u003D 0; scanner.Scan() \u0026\u0026 i \u003C 5; i++ {\u000A fmt.Println(scanner.Text())\u000A }\u000A');codeLines.push(' if err :\u003D scanner.Err(); err !\u003D nil {\u000A panic(err)\u000A }\u000A}\u000A');codeLines.push('');
|
||||
</script>
|
||||
<script src="site.js" async></script>
|
||||
</body>
|
||||
|
2
public/http-servers
generated
2
public/http-servers
generated
@ -32,7 +32,7 @@
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/s3xMMt9Ytry"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma">
|
||||
<span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
|
4
public/if-else
generated
4
public/if-else
generated
@ -42,7 +42,7 @@ straight-forward.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/QlMkcwHvmns"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<a href="https://go.dev/play/p/QlMkcwHvmns"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
@ -155,7 +155,7 @@ in Go, but that the braces are required.</p>
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>There is no <a href="http://en.wikipedia.org/wiki/%3F:">ternary if</a>
|
||||
<p>There is no <a href="https://en.wikipedia.org/wiki/%3F:">ternary if</a>
|
||||
in Go, so you’ll need to use a full <code>if</code> statement even
|
||||
for basic conditions.</p>
|
||||
|
||||
|
2
public/index.html
generated
2
public/index.html
generated
@ -9,7 +9,7 @@
|
||||
<div id="intro">
|
||||
<h2><a href="./">Go by Example</a></h2>
|
||||
<p>
|
||||
<a href="http://go.dev">Go</a> is an
|
||||
<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
|
||||
|
4
public/interfaces
generated
4
public/interfaces
generated
@ -42,7 +42,7 @@ signatures.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/XJASG4MxBQr"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
@ -209,7 +209,7 @@ these structs as arguments to <code>measure</code>.</p>
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>To learn more about Go’s interfaces, check out this
|
||||
<a href="http://jordanorelli.tumblr.com/post/32665860244/how-to-use-interfaces-in-go">great blog post</a>.</p>
|
||||
<a href="https://jordanorelli.tumblr.com/post/32665860244/how-to-use-interfaces-in-go">great blog post</a>.</p>
|
||||
|
||||
</td>
|
||||
<td class="code empty">
|
||||
|
6
public/json
generated
6
public/json
generated
@ -43,7 +43,7 @@ data types.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/JOQpRGJWAxR"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
@ -383,8 +383,8 @@ stream JSON encodings directly to <code>os.Writer</code>s like
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>We’ve covered the basic of JSON in Go here, but check
|
||||
out the <a href="http://blog.golang.org/2011/01/json-and-go.html">JSON and Go</a>
|
||||
blog post and <a href="http://golang.org/pkg/encoding/json/">JSON package docs</a>
|
||||
out the <a href="https://go.dev/blog/json">JSON and Go</a>
|
||||
blog post and <a href="https://pkg.go.dev/encoding/json">JSON package docs</a>
|
||||
for more.</p>
|
||||
|
||||
</td>
|
||||
|
2
public/line-filters
generated
2
public/line-filters
generated
@ -47,7 +47,7 @@ pattern to write your own Go line filters.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/kNcupWRsYPP"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma">
|
||||
<span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
|
4
public/maps
generated
4
public/maps
generated
@ -27,7 +27,7 @@
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p><em>Maps</em> are Go’s built-in <a href="http://en.wikipedia.org/wiki/Associative_array">associative data type</a>
|
||||
<p><em>Maps</em> are Go’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>
|
||||
|
||||
</td>
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/agK2Ro2i-Lu"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/methods
generated
2
public/methods
generated
@ -41,7 +41,7 @@
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/4wmDCAydC1e"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/multiple-return-values
generated
2
public/multiple-return-values
generated
@ -43,7 +43,7 @@ to return both result and error values from a function.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/vZdUvLB1WbK"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
4
public/mutexes
generated
4
public/mutexes
generated
@ -29,7 +29,7 @@
|
||||
<td class="docs">
|
||||
<p>In the previous example we saw how to manage simple
|
||||
counter state using <a href="atomic-counters">atomic operations</a>.
|
||||
For more complex state we can use a <a href="http://en.wikipedia.org/wiki/Mutual_exclusion"><em>mutex</em></a>
|
||||
For more complex state we can use a <a href="https://en.wikipedia.org/wiki/Mutual_exclusion"><em>mutex</em></a>
|
||||
to safely access data across multiple goroutines.</p>
|
||||
|
||||
</td>
|
||||
@ -44,7 +44,7 @@ to safely access data across multiple goroutines.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/tDqeib2-yZA"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<a href="https://go.dev/play/p/Kr_cdza5vyz"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/non-blocking-channel-operations
generated
2
public/non-blocking-channel-operations
generated
@ -44,7 +44,7 @@ non-blocking multi-way <code>select</code>s.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/TFv6-7OVNVq"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/number-parsing
generated
2
public/number-parsing
generated
@ -42,7 +42,7 @@ in many programs; here’s how to do it in Go.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/ZAMEid6Fpmu"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/panic
generated
2
public/panic
generated
@ -44,7 +44,7 @@ aren’t prepared to handle gracefully.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/9-2vCvRuhmE"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
4
public/pointers
generated
4
public/pointers
generated
@ -27,7 +27,7 @@
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>Go supports <em><a href="http://en.wikipedia.org/wiki/Pointer_(computer_programming)">pointers</a></em>,
|
||||
<p>Go supports <em><a href="https://en.wikipedia.org/wiki/Pointer_(computer_programming)">pointers</a></em>,
|
||||
allowing you to pass references to values and records
|
||||
within your program.</p>
|
||||
|
||||
@ -43,7 +43,7 @@ within your program.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/oimmXypnAcs"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
6
public/random-numbers
generated
6
public/random-numbers
generated
@ -28,7 +28,7 @@
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>Go’s <code>math/rand</code> package provides
|
||||
<a href="http://en.wikipedia.org/wiki/Pseudorandom_number_generator">pseudorandom number</a>
|
||||
<a href="https://en.wikipedia.org/wiki/Pseudorandom_number_generator">pseudorandom number</a>
|
||||
generation.</p>
|
||||
|
||||
</td>
|
||||
@ -43,7 +43,7 @@ generation.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/PGklfJzErTN"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<a href="https://go.dev/play/p/RaoKyUd9tgC"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
@ -200,7 +200,7 @@ produces the same sequence of random numbers.</p>
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>See the <a href="http://golang.org/pkg/math/rand/"><code>math/rand</code></a>
|
||||
<p>See the <a href="https://pkg.go.dev/math/rand"><code>math/rand</code></a>
|
||||
package docs for references on other random quantities
|
||||
that Go can provide.</p>
|
||||
|
||||
|
2
public/range
generated
2
public/range
generated
@ -43,7 +43,7 @@ of the data structures we’ve already learned.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/kRsyWNmLFLz"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/range-over-channels
generated
2
public/range-over-channels
generated
@ -44,7 +44,7 @@ values received from a channel.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/yQMclmwOYs9"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
4
public/rate-limiting
generated
4
public/rate-limiting
generated
@ -27,7 +27,7 @@
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p><a href="http://en.wikipedia.org/wiki/Rate_limiting"><em>Rate limiting</em></a>
|
||||
<p><a href="https://en.wikipedia.org/wiki/Rate_limiting"><em>Rate limiting</em></a>
|
||||
is an important mechanism for controlling resource
|
||||
utilization and maintaining quality of service. Go
|
||||
elegantly supports rate limiting with goroutines,
|
||||
@ -45,7 +45,7 @@ channels, and <a href="tickers">tickers</a>.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/GXjXHfnKFXg"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/reading-files
generated
2
public/reading-files
generated
@ -43,7 +43,7 @@ reading files.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/DF2Wo8nDKaF"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/recover
generated
2
public/recover
generated
@ -60,7 +60,7 @@ does by default for HTTP servers.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/Sk-SVdofEIZ"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
4
public/recursion
generated
4
public/recursion
generated
@ -28,7 +28,7 @@
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>Go supports
|
||||
<a href="http://en.wikipedia.org/wiki/Recursion_(computer_science)"><em>recursive functions</em></a>.
|
||||
<a href="https://en.wikipedia.org/wiki/Recursion_(computer_science)"><em>recursive functions</em></a>.
|
||||
Here’s a classic example.</p>
|
||||
|
||||
</td>
|
||||
@ -43,7 +43,7 @@ Here’s a classic example.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/7hD-3-bIuSp"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
6
public/regular-expressions
generated
6
public/regular-expressions
generated
@ -27,7 +27,7 @@
|
||||
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>Go offers built-in support for <a href="http://en.wikipedia.org/wiki/Regular_expression">regular expressions</a>.
|
||||
<p>Go offers built-in support for <a href="https://en.wikipedia.org/wiki/Regular_expression">regular expressions</a>.
|
||||
Here are some examples of common regexp-related tasks
|
||||
in Go.</p>
|
||||
|
||||
@ -43,7 +43,7 @@ in Go.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/htCqJrLdh9Q"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
@ -316,7 +316,7 @@ text with a given function.</p>
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>For a complete reference on Go regular expressions check
|
||||
the <a href="http://golang.org/pkg/regexp/"><code>regexp</code></a> package docs.</p>
|
||||
the <a href="https://pkg.go.dev/regexp"><code>regexp</code></a> package docs.</p>
|
||||
|
||||
</td>
|
||||
<td class="code empty">
|
||||
|
2
public/select
generated
2
public/select
generated
@ -43,7 +43,7 @@ select is a powerful feature of Go.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/FzONhs4-tae"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/sha256-hashes
generated
2
public/sha256-hashes
generated
@ -45,7 +45,7 @@ SHA256 hashes in Go.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/IHM1lZVm_Jm"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
4
public/signals
generated
4
public/signals
generated
@ -28,7 +28,7 @@
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>Sometimes we’d like our Go programs to intelligently
|
||||
handle <a href="http://en.wikipedia.org/wiki/Unix_signal">Unix signals</a>.
|
||||
handle <a href="https://en.wikipedia.org/wiki/Unix_signal">Unix signals</a>.
|
||||
For example, we might want a server to gracefully
|
||||
shutdown when it receives a <code>SIGTERM</code>, or a command-line
|
||||
tool to stop processing input if it receives a <code>SIGINT</code>.
|
||||
@ -46,7 +46,7 @@ Here’s how to handle signals in Go with channels.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/LauPuRo3v9l"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<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" />
|
||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
</td>
|
||||
|
2
public/site.css
generated
2
public/site.css
generated
@ -1,4 +1,4 @@
|
||||
/* CSS reset: http://meyerweb.com/eric/tools/css/reset/ */
|
||||
/* CSS reset: https://meyerweb.com/eric/tools/css/reset/ */
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user