diff --git a/examples/atomic-counters/atomic-counters.hash b/examples/atomic-counters/atomic-counters.hash index 199e3b1..c1b531a 100644 --- a/examples/atomic-counters/atomic-counters.hash +++ b/examples/atomic-counters/atomic-counters.hash @@ -1,2 +1,2 @@ -ce8821f1f4fd99d554ad6cde52403dd3b69bb70a -8p48eFFxDZ +a4190094ea0405b5f2733101beb97939a1d43aee +KDr9EMMPMgi diff --git a/examples/closures/closures.hash b/examples/closures/closures.hash index a1f8255..fa66f0f 100644 --- a/examples/closures/closures.hash +++ b/examples/closures/closures.hash @@ -1,2 +1,2 @@ -2e062d01989caada16c4b22ff6a35cd58e4eb819 -gQtEWkhWyp +e304df67e760dda93ffe434aca58aea4a6c94f19 +zb93qzV6iN3 diff --git a/examples/collection-functions/collection-functions.hash b/examples/collection-functions/collection-functions.hash index cab1518..4c45952 100644 --- a/examples/collection-functions/collection-functions.hash +++ b/examples/collection-functions/collection-functions.hash @@ -1,2 +1,2 @@ -ed54b3fc0512ccace0f3d0b74975c9bcd2e7a8a2 -3PNdke3Wia +d961fc0e0074aed46cfd1516efdadea78781af56 +BJB_npWH516 diff --git a/examples/json/json.hash b/examples/json/json.hash index 8d238b0..c9282a5 100644 --- a/examples/json/json.hash +++ b/examples/json/json.hash @@ -1,2 +1,2 @@ -dee52e022a957b97c53fb2d2835653ef507502be -WxRgpycMaH +43e8d66fb862ea224994ca766e5689a96016f7ca +UGeNKd-cw34 diff --git a/examples/mutexes/mutexes.hash b/examples/mutexes/mutexes.hash index a175d8e..aea2025 100644 --- a/examples/mutexes/mutexes.hash +++ b/examples/mutexes/mutexes.hash @@ -1,2 +1,2 @@ -b62f93a169c2d9141b2f7edceb840ede59598bd7 -tWqg2zQSVpb +ca257d9594a6219d5803193132e999a32dc8c856 +IRewFKz2OPN diff --git a/examples/sorting-by-functions/sorting-by-functions.hash b/examples/sorting-by-functions/sorting-by-functions.hash index 91f67df..fbf46ed 100644 --- a/examples/sorting-by-functions/sorting-by-functions.hash +++ b/examples/sorting-by-functions/sorting-by-functions.hash @@ -1,2 +1,2 @@ -cec0da0bd98abd7f66fcd38122e4405f757161bc -N6GbEgBffd +a5bcb1620c62f89f8253d7d2a2580b5ae48771b6 +4b7_qiGp33y diff --git a/examples/stateful-goroutines/stateful-goroutines.hash b/examples/stateful-goroutines/stateful-goroutines.hash index c2233b3..f88cfa8 100644 --- a/examples/stateful-goroutines/stateful-goroutines.hash +++ b/examples/stateful-goroutines/stateful-goroutines.hash @@ -1,2 +1,2 @@ -c306add52c0752f0b3099eb669364fc4bdb74be1 -P4SrrlosMp +ff8b7e93a43c284ada17f4387cc5dfeafa3ee316 +dlfBGF-qff6 diff --git a/examples/variables/variables.hash b/examples/variables/variables.hash index 8e7c623..ae31cd9 100644 --- a/examples/variables/variables.hash +++ b/examples/variables/variables.hash @@ -1,2 +1,2 @@ -8c74aae4850358073926dba5d98aa402f9968251 -Zv45CSMaiD +f7a75d8fb2525099e9de6c5a5916e2411c5f3489 +1FnG0dJfxs8 diff --git a/public/atomic-counters b/public/atomic-counters index fb7e27e..0afd46e 100644 --- a/public/atomic-counters +++ b/public/atomic-counters @@ -44,7 +44,7 @@ counters accessed by multiple goroutines.
package main
var ops uint64 = 0
+ var ops uint64
package main
func intSeq() func() int {
i := 0
return func() int {
- i += 1
+ i++
return i
}
}
diff --git a/public/collection-functions b/public/collection-functions
index 7d71950..0d2e11a 100644
--- a/public/collection-functions
+++ b/public/collection-functions
@@ -73,7 +73,7 @@ helper function.
package main
Returns the first index of the target string t
, or
+
Index returns the first index of the target string t
, or
-1 if no match is found.
Returns true
if the target string t is in the
+
Include returns true
if the target string t is in the
slice.
Returns true
if one of the strings in the slice
+
Any returns true
if one of the strings in the slice
satisfies the predicate f
.
f
.
Returns true
if all of the strings in the slice
+
All returns true
if all of the strings in the slice
satisfy the predicate f
.
f
.
Returns a new slice containing all strings in the +
Filter returns a new slice containing all strings in the
slice that satisfy the predicate f
.
f
.
Returns a new slice containing the results of applying +
Map returns a new slice containing the results of applying
the function f
to each string in the original slice.
package main
type Response1 struct {
+ type response1 struct {
Page int
Fruits []string
}
-type Response2 struct {
+type response2 struct {
Page int `json:"page"`
Fruits []string `json:"fruits"`
}
@@ -190,7 +190,7 @@ use those names as the JSON keys.
res1D := &Response1{
+ res1D := &response1{
Page: 1,
Fruits: []string{"apple", "peach", "pear"}}
res1B, _ := json.Marshal(res1D)
@@ -204,13 +204,13 @@ use those names as the JSON keys.
You can use tags on struct field declarations
to customize the encoded JSON key names. Check the
-definition of Response2
above to see an example
+definition of response2
above to see an example
of such tags.
- res2D := &Response2{
+ res2D := &response2{
Page: 1,
Fruits: []string{"apple", "peach", "pear"}}
res2B, _ := json.Marshal(res2D)
@@ -313,7 +313,7 @@ data.
str := `{"page": 1, "fruits": ["apple", "peach"]}`
- res := Response2{}
+ res := response2{}
json.Unmarshal([]byte(str), &res)
fmt.Println(res)
fmt.Println(res.Fruits[0])
diff --git a/public/mutexes b/public/mutexes
index 83935b9..7940e38 100644
--- a/public/mutexes
+++ b/public/mutexes
@@ -42,7 +42,7 @@ to safely access data across multiple goroutines.
-
+
package main
@@ -113,8 +113,8 @@ operations we do.
- var readOps uint64 = 0
- var writeOps uint64 = 0
+ var readOps uint64
+ var writeOps uint64
diff --git a/public/sorting-by-functions b/public/sorting-by-functions
index f610b59..710700f 100644
--- a/public/sorting-by-functions
+++ b/public/sorting-by-functions
@@ -43,7 +43,7 @@ in Go.
-
+
package main
@@ -66,14 +66,14 @@ in Go.
In order to sort by a custom function in Go, we need a
-corresponding type. Here we’ve created a ByLength
+corresponding type. Here we’ve created a byLength
type that is just an alias for the builtin []string
type.
- type ByLength []string
+ type byLength []string
@@ -92,13 +92,13 @@ we use len(s[i])
and len(s[j])
here.
- func (s ByLength) Len() int {
+ func (s byLength) Len() int {
return len(s)
}
-func (s ByLength) Swap(i, j int) {
+func (s byLength) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
-func (s ByLength) Less(i, j int) bool {
+func (s byLength) Less(i, j int) bool {
return len(s[i]) < len(s[j])
}
@@ -110,7 +110,7 @@ we use len(s[i])
and len(s[j])
here.
With all of this in place, we can now implement our
custom sort by casting the original fruits
slice to
-ByLength
, and then use sort.Sort
on that typed
+byLength
, and then use sort.Sort
on that typed
slice.
@@ -118,7 +118,7 @@ slice.
func main() {
fruits := []string{"peach", "banana", "kiwi"}
- sort.Sort(ByLength(fruits))
+ sort.Sort(byLength(fruits))
fmt.Println(fruits)
}
diff --git a/public/stateful-goroutines b/public/stateful-goroutines
index fdf3e10..aa0579e 100644
--- a/public/stateful-goroutines
+++ b/public/stateful-goroutines
@@ -46,7 +46,7 @@ by exactly 1 goroutine.
-
+
package main
@@ -117,8 +117,8 @@ goroutine to respond.
- var readOps uint64 = 0
- var writeOps uint64 = 0
+ var readOps uint64
+ var writeOps uint64
diff --git a/public/variables b/public/variables
index 222135d..856f4c5 100644
--- a/public/variables
+++ b/public/variables
@@ -41,7 +41,7 @@ calls.
-
+
package main
@@ -79,7 +79,7 @@ calls.
- var a string = "initial"
+ var a = "initial"
fmt.Println(a)