_content/talks: add talks.golang.org content

Copied from golang.org/x/talks/content at a07c284b (Feb 8 2021)
and from golang.org/x/tools/cmd/present/static and templates
at 43b469a3 (Nov 17 2021).

Adds 80MB (uncompressed) to the repository and the
cmd/golangorg binary.

Change-Id: I4949e41bf6f3ccc28ea13303d79ed6931abe86e7
Reviewed-on: https://go-review.googlesource.com/c/website/+/365135
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/_content/talks/2012/goforc/adder.go b/_content/talks/2012/goforc/adder.go
new file mode 100644
index 0000000..1ebc71a
--- /dev/null
+++ b/_content/talks/2012/goforc/adder.go
@@ -0,0 +1,23 @@
+// +build ignore,OMIT
+
+package main
+
+import "fmt"
+
+// START1 OMIT
+func adder(delta int) func(x int) int {
+	f := func(x int) int { // HL
+		return x + delta // HL
+	} // HL
+	return f
+}
+
+// STOP1 OMIT
+
+func main() {
+	// START2 OMIT
+	var inc = adder(1)
+	fmt.Println(inc(0))
+	fmt.Println(adder(-1)(10))
+	// STOP2 OMIT
+}
diff --git a/_content/talks/2012/goforc/cat.go b/_content/talks/2012/goforc/cat.go
new file mode 100644
index 0000000..3979df1
--- /dev/null
+++ b/_content/talks/2012/goforc/cat.go
@@ -0,0 +1,24 @@
+// +build ignore,OMIT
+
+package main
+
+import (
+	"flag"
+	"io"
+	"os"
+)
+
+func main() {
+	flag.Parse()
+	for _, arg := range flag.Args() {
+		f, err := os.Open(arg)
+		if err != nil {
+			panic(err)
+		}
+		defer f.Close()
+		_, err = io.Copy(os.Stdout, f) // HL
+		if err != nil {
+			panic(err)
+		}
+	}
+}
diff --git a/_content/talks/2012/goforc/celsius.go b/_content/talks/2012/goforc/celsius.go
new file mode 100644
index 0000000..ffb4572
--- /dev/null
+++ b/_content/talks/2012/goforc/celsius.go
@@ -0,0 +1,19 @@
+// +build ignore,OMIT
+
+package main
+
+import "fmt"
+
+type Celsius float32
+type Fahrenheit float32
+
+func (t Celsius) String() string           { return fmt.Sprintf("%g°C", t) }
+func (t Fahrenheit) String() string        { return fmt.Sprintf("%g°F", t) }
+func (t Celsius) ToFahrenheit() Fahrenheit { return Fahrenheit(t*9/5 + 32) }
+
+func main() {
+	var t Celsius = 21
+	fmt.Println(t.String())
+	fmt.Println(t)
+	fmt.Println(t.ToFahrenheit())
+}
diff --git a/_content/talks/2012/goforc/channels.go b/_content/talks/2012/goforc/channels.go
new file mode 100644
index 0000000..a10c9cb
--- /dev/null
+++ b/_content/talks/2012/goforc/channels.go
@@ -0,0 +1,28 @@
+// +build ignore,OMIT
+
+package main
+
+func main() {
+	var value int
+
+	// START1 OMIT
+	// Declaring and initializing.
+	var c chan int
+	c = make(chan int)
+	// or
+	c := make(chan int) // HL
+	// STOP1 OMIT
+
+	// START2 OMIT
+	// Sending on a channel.
+	c <- 1 // HL
+	// STOP2 OMIT
+
+	// START3 OMIT
+	// Receiving from a channel.
+	// The "arrow" indicates the direction of data flow.
+	value = <-c // HL
+	// STOP3 OMIT
+
+	_ = value
+}
diff --git a/_content/talks/2012/goforc/communication1.go b/_content/talks/2012/goforc/communication1.go
new file mode 100644
index 0000000..4825227
--- /dev/null
+++ b/_content/talks/2012/goforc/communication1.go
@@ -0,0 +1,30 @@
+// +build ignore,OMIT
+
+package main
+
+import (
+	"fmt"
+	"time"
+)
+
+// START1 OMIT
+func main() {
+	c := make(chan string)
+	go f("three", 300*time.Millisecond, c)
+	for i := 0; i < 10; i++ {
+		fmt.Println("Received", <-c) // Receive expression is just a value. // HL
+	}
+	fmt.Println("Done.")
+}
+
+// STOP1 OMIT
+
+// START2 OMIT
+func f(msg string, delay time.Duration, c chan string) {
+	for i := 0; ; i++ {
+		c <- fmt.Sprintf("%s %d", msg, i) // Any suitable value can be sent. // HL
+		time.Sleep(delay)
+	}
+}
+
+// STOP2 OMIT
diff --git a/_content/talks/2012/goforc/communication2.go b/_content/talks/2012/goforc/communication2.go
new file mode 100644
index 0000000..20c815b
--- /dev/null
+++ b/_content/talks/2012/goforc/communication2.go
@@ -0,0 +1,32 @@
+// +build ignore,OMIT
+
+package main
+
+import (
+	"fmt"
+	"time"
+)
+
+// START1 OMIT
+func main() {
+	c := make(chan string)
+	go f("three", 300*time.Millisecond, c) // HL
+	go f("six", 600*time.Millisecond, c)   // HL
+	go f("nine", 900*time.Millisecond, c)  // HL
+	for i := 0; i < 10; i++ {
+		fmt.Println("Received", <-c)
+	}
+	fmt.Println("Done.")
+}
+
+// STOP1 OMIT
+
+// START2 OMIT
+func f(msg string, delay time.Duration, c chan string) {
+	for i := 0; ; i++ {
+		c <- fmt.Sprintf("%s %d", msg, i) // Any suitable value can be sent. // HL
+		time.Sleep(delay)
+	}
+}
+
+// STOP2 OMIT
diff --git a/_content/talks/2012/goforc/consts.go b/_content/talks/2012/goforc/consts.go
new file mode 100644
index 0000000..33cf221
--- /dev/null
+++ b/_content/talks/2012/goforc/consts.go
@@ -0,0 +1,26 @@
+// +build ignore,OMIT
+
+package main
+
+import "fmt"
+
+// START1 OMIT
+const (
+	MaxUInt = 1<<64 - 1
+	Pi      = 3.14159265358979323846264338327950288419716939937510582097494459
+	Pi2     = Pi * Pi
+	Delta   = 2.0
+)
+
+// STOP1 OMIT
+
+func main() {
+	// START2 OMIT
+	var x uint64 = MaxUInt
+	var pi2 float32 = Pi2
+	var delta int = Delta
+	// STOP2 OMIT
+	fmt.Println("x =", x)
+	fmt.Println("pi2 =", pi2)
+	fmt.Println("delta =", delta)
+}
diff --git a/_content/talks/2012/goforc/decls.go b/_content/talks/2012/goforc/decls.go
new file mode 100644
index 0000000..b49dd4f
--- /dev/null
+++ b/_content/talks/2012/goforc/decls.go
@@ -0,0 +1,25 @@
+// +build ignore,OMIT
+
+package main
+
+// START OMIT
+import "fmt"
+
+const digits = "0123456789abcdef"
+
+type Point struct {
+	x, y int
+	tag  string
+}
+
+var s [32]byte
+
+var msgs = []string{"Hello, 世界", "Ciao, Mondo"}
+
+func itoa(x, base int) string
+
+// STOP OMIT
+
+func main() {
+	fmt.Println() // use fmt
+}
diff --git a/_content/talks/2012/goforc/example0.go b/_content/talks/2012/goforc/example0.go
new file mode 100644
index 0000000..fa1d0f7
--- /dev/null
+++ b/_content/talks/2012/goforc/example0.go
@@ -0,0 +1,25 @@
+// +build ignore,OMIT
+
+package main
+
+import (
+	"fmt"
+	"time"
+)
+
+// START1 OMIT
+func main() {
+	f("Hello, World", 500*time.Millisecond)
+}
+
+// STOP1 OMIT
+
+// START2 OMIT
+func f(msg string, delay time.Duration) {
+	for i := 0; ; i++ {
+		fmt.Println(msg, i)
+		time.Sleep(delay)
+	}
+}
+
+// STOP2 OMIT
diff --git a/_content/talks/2012/goforc/example1.go b/_content/talks/2012/goforc/example1.go
new file mode 100644
index 0000000..ced6d0e
--- /dev/null
+++ b/_content/talks/2012/goforc/example1.go
@@ -0,0 +1,24 @@
+// +build ignore,OMIT
+
+package main
+
+import (
+	"fmt"
+	"time"
+)
+
+// START OMIT
+func main() {
+	go f("three", 300*time.Millisecond)
+	go f("six", 600*time.Millisecond)
+	go f("nine", 900*time.Millisecond)
+}
+
+// STOP OMIT
+
+func f(msg string, delay time.Duration) {
+	for i := 0; ; i++ {
+		fmt.Println(msg, i)
+		time.Sleep(delay)
+	}
+}
diff --git a/_content/talks/2012/goforc/example2.go b/_content/talks/2012/goforc/example2.go
new file mode 100644
index 0000000..3b8504f
--- /dev/null
+++ b/_content/talks/2012/goforc/example2.go
@@ -0,0 +1,26 @@
+// +build ignore,OMIT
+
+package main
+
+import (
+	"fmt"
+	"time"
+)
+
+// START OMIT
+func main() {
+	go f("three", 300*time.Millisecond)
+	go f("six", 600*time.Millisecond)
+	go f("nine", 900*time.Millisecond)
+	time.Sleep(3 * time.Second)
+	fmt.Println("Done.")
+}
+
+// STOP OMIT
+
+func f(msg string, delay time.Duration) {
+	for i := 0; ; i++ {
+		fmt.Println(msg, i)
+		time.Sleep(delay)
+	}
+}
diff --git a/_content/talks/2012/goforc/forloop.go b/_content/talks/2012/goforc/forloop.go
new file mode 100644
index 0000000..12975c4
--- /dev/null
+++ b/_content/talks/2012/goforc/forloop.go
@@ -0,0 +1,30 @@
+// +build ignore,OMIT
+
+package main
+
+import "fmt"
+
+var primes = [...]int{2, 3, 5, 7, 11, 13, 17, 19}
+
+func _() {
+	// START1 OMIT
+	for i := 0; i < len(primes); i++ {
+		fmt.Println(i, primes[i])
+	}
+	// STOP1 OMIT
+
+	// START2 OMIT
+	var sum int
+	for _, x := range primes {
+		sum += x
+	}
+	// STOP2 OMIT
+}
+
+func main() {
+	// START3 OMIT
+	for i, x := range primes {
+		fmt.Println(i, x)
+	}
+	// STOP3 OMIT
+}
diff --git a/_content/talks/2012/goforc/hello.go b/_content/talks/2012/goforc/hello.go
new file mode 100644
index 0000000..e4f48ab
--- /dev/null
+++ b/_content/talks/2012/goforc/hello.go
@@ -0,0 +1,9 @@
+// +build ignore,OMIT
+
+package main
+
+import "fmt"
+
+func main() {
+	fmt.Println("Hello, 世界")
+}
diff --git a/_content/talks/2012/goforc/interface.go b/_content/talks/2012/goforc/interface.go
new file mode 100644
index 0000000..02bc0f6
--- /dev/null
+++ b/_content/talks/2012/goforc/interface.go
@@ -0,0 +1,36 @@
+// +build ignore,OMIT
+
+package main
+
+import "fmt"
+
+type Point struct{ x, y int }
+
+func (p Point) String() string { return fmt.Sprintf("Point{%d, %d}", p.x, p.y) }
+
+type Celsius float32
+type Fahrenheit float32
+
+func (t Celsius) String() string           { return fmt.Sprintf("%g°C", t) }
+func (t Fahrenheit) String() string        { return fmt.Sprintf("%g°F", t) }
+func (t Celsius) ToFahrenheit() Fahrenheit { return Fahrenheit(t*9/5 + 32) }
+
+func main() {
+	// START OMIT
+	type Stringer interface {
+		String() string
+	}
+
+	var v Stringer // HL
+	var corner = Point{1, 1}
+	var boiling = Celsius(100)
+
+	v = corner
+	fmt.Println(v.String()) // dynamic dispatch
+	fmt.Println(v)
+
+	v = boiling.ToFahrenheit()
+	fmt.Println(v.String()) // dynamic dispatch
+	fmt.Println(v)
+	// STOP OMIT
+}
diff --git a/_content/talks/2012/goforc/point.go b/_content/talks/2012/goforc/point.go
new file mode 100644
index 0000000..2973d77
--- /dev/null
+++ b/_content/talks/2012/goforc/point.go
@@ -0,0 +1,22 @@
+// +build ignore,OMIT
+
+package main
+
+import "fmt"
+
+type Point struct{ x, y int }
+
+func PointToString(p Point) string {
+	return fmt.Sprintf("Point{%d, %d}", p.x, p.y)
+}
+
+func (p Point) String() string { // HL
+	return fmt.Sprintf("Point{%d, %d}", p.x, p.y)
+}
+
+func main() {
+	p := Point{3, 5}
+	fmt.Println(PointToString(p)) // static dispatch // HL
+	fmt.Println(p.String())       // static dispatch // HL
+	fmt.Println(p)
+}
diff --git a/_content/talks/2012/goforc/stmts.go b/_content/talks/2012/goforc/stmts.go
new file mode 100644
index 0000000..ae6a5c7
--- /dev/null
+++ b/_content/talks/2012/goforc/stmts.go
@@ -0,0 +1,35 @@
+// +build ignore,OMIT
+
+package main
+
+import "fmt"
+
+const digits = "0123456789abcdef"
+
+func itoa(x, base int) string {
+	// START OMIT
+	t := x
+	switch {
+	case x == 0:
+		return "0"
+	case x < 0:
+		t = -x
+	}
+	var s [32]byte
+	i := len(s)
+	for t != 0 { // Look, ma, no ()'s!
+		i--
+		s[i] = digits[t%base]
+		t /= base
+	}
+	if x < 0 {
+		i--
+		s[i] = '-'
+	}
+	return string(s[i:])
+	// STOP OMIT
+}
+
+func main() {
+	fmt.Println(itoa(-42, 2))
+}
diff --git a/_content/talks/2012/goforc/vars.go b/_content/talks/2012/goforc/vars.go
new file mode 100644
index 0000000..101eaa7
--- /dev/null
+++ b/_content/talks/2012/goforc/vars.go
@@ -0,0 +1,20 @@
+// +build ignore,OMIT
+
+package main
+
+// START1 OMIT
+var i int
+var p, q *Point
+var threshold float64 = 0.75
+
+// STOP1 OMIT
+
+// START2 OMIT
+var i = 42       // type of i is int
+var z = 1 + 2.3i // type of z is complex128
+// STOP2 OMIT
+
+func _() int {
+	i := 42 // type of i is int
+	return &i
+}
diff --git a/_content/talks/2012/goforc/worker1.go b/_content/talks/2012/goforc/worker1.go
new file mode 100644
index 0000000..585af16
--- /dev/null
+++ b/_content/talks/2012/goforc/worker1.go
@@ -0,0 +1,62 @@
+// +build ignore,OMIT
+
+package main
+
+import "fmt"
+import "time"
+
+// START1 OMIT
+func main() {
+	start := time.Now()
+
+	in := make(chan int)    // Channel on which work orders are received.
+	out := make(chan []int) // Channel on which results are returned.
+	go producer(in)
+	go worker(in, out) // Launch one worker. // HL
+	consumer(out, 100)
+
+	fmt.Println(time.Since(start))
+}
+
+// STOP1 OMIT
+
+// START2 OMIT
+func worker(in chan int, out chan []int) {
+	for {
+		order := <-in           // Receive a work order. // HL
+		result := factor(order) // Do some work. // HL
+		out <- result           // Send the result back. // HL
+	}
+}
+
+// STOP2 OMIT
+
+// START3 OMIT
+func producer(out chan int) {
+	for order := 0; ; order++ {
+		out <- order // Produce a work order. // HL
+	}
+}
+
+func consumer(in chan []int, n int) {
+	for i := 0; i < n; i++ {
+		result := <-in // Consume a result. // HL
+		fmt.Println("Consumed", result)
+	}
+}
+
+// STOP3 OMIT
+
+// factor returns a list containing x and its prime factors.
+func factor(x int) (list []int) {
+	list = append(list, x)
+	for f := 2; x >= f; f++ {
+		for x%f == 0 {
+			x /= f
+			list = append(list, f)
+			// Slow down so we can see what happens.
+			time.Sleep(50 * time.Millisecond)
+		}
+	}
+	return
+}
diff --git a/_content/talks/2012/goforc/worker2.go b/_content/talks/2012/goforc/worker2.go
new file mode 100644
index 0000000..f995e9b
--- /dev/null
+++ b/_content/talks/2012/goforc/worker2.go
@@ -0,0 +1,64 @@
+// +build ignore,OMIT
+
+package main
+
+import "fmt"
+import "time"
+
+func main() {
+	start := time.Now()
+
+	// START1 OMIT
+	in := make(chan int)
+	out := make(chan []int)
+	go producer(in)
+	// Launch 10 workers. // HL
+	for i := 0; i < 10; i++ { // HL
+		go worker(in, out) // HL
+	} // HL
+	consumer(out, 100)
+	// STOP1 OMIT
+
+	fmt.Println(time.Since(start))
+}
+
+// START2 OMIT
+func worker(in chan int, out chan []int) {
+	for {
+		order := <-in           // Receive a work order. // HL
+		result := factor(order) // Do some work. // HL
+		out <- result           // Send the result back. // HL
+	}
+}
+
+// STOP2 OMIT
+
+// START3 OMIT
+func producer(out chan int) {
+	for order := 0; ; order++ {
+		out <- order // Produce a work order. // HL
+	}
+}
+
+func consumer(in chan []int, n int) {
+	for i := 0; i < n; i++ {
+		result := <-in // Consume a result. // HL
+		fmt.Println("Consumed", result)
+	}
+}
+
+// STOP3 OMIT
+
+// factor returns a list containing x and its prime factors.
+func factor(x int) (list []int) {
+	list = append(list, x)
+	for f := 2; x >= f; f++ {
+		for x%f == 0 {
+			x /= f
+			list = append(list, f)
+			// Slow down so we can see what happens.
+			time.Sleep(50 * time.Millisecond)
+		}
+	}
+	return
+}