8000 not sure what these changes were · Abhicodeitout/GolangTraining@1c491d5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c491d5

Browse files
committed
not sure what these changes were
1 parent a342bfc commit 1c491d5

File tree

38 files changed

+148
-120
lines changed

38 files changed

+148
-120
lines changed

03_variables/03_less-emphasis/07_all-together/variables.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package main
22

33
import "fmt"
44

5-
var a = "this is stored in the variable a" // package scope
6-
var b, c string = "stored in b", "stored in c" // package scope
7-
var d string // package scope
5+
var a = "this is stored in the variable a" // package scope
6+
var b, c string = "stored in b", "stored in c" // package scope
7+
var d string // package scope
88

99
func main() {
1010

1111
d = "stored in d" // declaration above; assignment here; package scope
12-
var e = 42 // function scope - subsequent variables have func scope:
12+
var e = 42 // function scope - subsequent variables have func scope:
1313
f := 43
1414
g := "stored in g"
1515
h, i := "stored in h", "stored in i"

04_scope/05_same-package/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import "fmt"
44

5-
func main(){
5+
func main() {
66
fmt.Println(x)
77
}
88

10_for-loop/07_rune-loop_UTF8/01/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ A byte is 8 bits.
2828
[]byte deals with bytes, that is, only 1 byte (8 bits) at a time.
2929
3030
[]int32 allows us to store the value of 4 bytes, that is, 4 bytes * 8 bits per byte = 32 bits.
31-
*/
31+
*/

14_functions/05_return-naming/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Avoid using named returns.
1818
1919
Occasionally named returns are useful. Read this article for more information:
2020
https://www.goinggo.net/2013/10/functions-and-naked-returns-in-go.html
21-
*/
21+
*/

14_functions/11_closure/05/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ func wrapper() func() int {
1313
func main() {
1414
incrementA := wrapper()
1515
incrementB := wrapper()
16-
fmt.Println("A:",incrementA())
17-
fmt.Println("A:",incrementA())
18-
fmt.Println("B:",incrementB())
19-
fmt.Println("B:",incrementB())
20-
fmt.Println("B:",incrementB())
16+
fmt.Println("A:", incrementA())
17+
fmt.Println("A:", incrementA())
18+
fmt.Println("B:", incrementB())
19+
fmt.Println("B:", incrementB())
20+
fmt.Println("B:", incrementB())
2121
}
2222

2323
/*

16_exercise-solutions/03_variadic-greatest/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ if you only have negative numbers
4444
you need largest to be something less than zero
4545
4646
Thanks to Ricardo G for this code improvement!
47-
*/
47+
*/

19_map/14_hash-table/03_words-in-buckets/01_slice-bucket/main.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ func main() {
2222
// Create slice of slice of string to hold slices of words
2323
buckets := make([][]string, 12)
2424

25-
26-
// code here has been updated from the recording
27-
// see below for explanation
28-
25+
// code here has been updated from the recording
26+
// see below for explanation
2927

3028
// Loop over the words
3129
for scanner.Scan() {
@@ -54,7 +52,6 @@ func hashBucket(word string, buckets int) int {
5452
// return len(word) % buckets
5553
}
5654

57-
5855
/*
5956
UPDATED CODE
6057
Up above, the code has been updated from the recording

22_go-routines/09_channels/04_pass-return-channels/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ func puller(c chan int) chan int {
3232
close(out)
3333
}()
3434
return out
35-
}
35+
}

22_go-routines/09_channels/05_channel-direction/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ func puller(c <-chan int) <-chan int {
3838
The optional <- operator specifies the channel direction, send or receive.
3939
If no direction is given, the channel is bidirectional.
4040
https://golang.org/ref/spec#Channel_types
41-
*/
41+
*/

22_go-routines/09_channels/06_refactor/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ func puller(c <-chan int) <-chan int {
3131
close(out)
3232
}()
3333
return out
34-
}
34+
}

22_go-routines/09_channels/07_incrementor/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ func puller(c chan int) chan int {
3535
close(out)
3636
}()
3737
return out
38-
}
38+
}

22_go-routines/12_channels_pipeline/02_sq-output/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ func main() {
99
}
1010
}
1111

12-
13-
14-
1512
func gen(nums ...int) chan int {
1613
out := make(chan int)
1714
go func() {

22_go-routines/13_channels_fan-out_fan-in/10_van-sickle_fan-out_fan-in/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ func fact(n int) int {
6767
This code was provided by my friend, Mike Van Sickle
6868
He is an awesome programmer, an awesome Go programmer, and an awesome teacher
6969
Check out his courses on pluralsight to learn more about Go!
70-
*/
70+
*/
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package main
22

33
import (
4-
"os"
54
"fmt"
5+
"os"
66
)
77

88
func main() {
@@ -11,10 +11,8 @@ func main() {
1111
fmt.Println("err happened", err)
1212
// log.Println("err happened", err)
1313
// log.Fatalln(err)
14-
// panic(err)
14+
// panic(err)
1515
}
1616
}
1717

1818
// Println formats using the default formats for its operands and writes to standard output.
19-
20-

23_error-handling/02_err-not-nil/02_log-println/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package main
22

33
import (
4-
"os"
54
"log"
5+
"os"
66
)
77

88
func main() {
@@ -11,7 +11,7 @@ func main() {
1111
// fmt.Println("err happened", err)
1212
log.Println("err happened", err)
1313
// log.Fatalln(err)
14-
// panic(err)
14+
// panic(err)
1515
}
1616
}
1717

23_error-handling/02_err-not-nil/03_log-set-output/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package main
22

33
import (
4-
"os"
5-
"log"
64
"fmt"
5+
"log"
6+
"os"
77
)
88

99
func init() {
@@ -20,7 +20,7 @@ func main() {
2020
// fmt.Println("err happened", err)
2121
log.Println("err happened", err)
2222
// log.Fatalln(err)
23-
// panic(err)
23+
// panic(err)
2424
}
2525
}
2626

23_error-handling/02_err-not-nil/04_log-fatalln/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package main
22

33
import (
4-
"os"
54
"log"
5+
"os"
66
)
77

88
func main() {
@@ -11,7 +11,7 @@ func main() {
1111
// fmt.Println("err happened", err)
1212
// log.Println("err happened", err)
1313
log.Fatalln(err)
14-
// panic(err)
14+
// panic(err)
1515
}
1616
}
1717

23_error-handling/02_err-not-nil/05_panic/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ func main() {
1010
// fmt.Println("err happened", err)
1111
// log.Println("err happened", err)
1212
// log.Fatalln(err)
13-
panic(err)
13+
panic(err)
1414
}
1515
}
16-
17-

23_error-handling/03_custom-errors/01_errors-new/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ func Sqrt(f float64) (float64, error) {
1818
}
1919
// implementation
2020
return 42, nil
21-
}
21+
}

23_error-handling/03_custom-errors/02_errors-new_var/main.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package main
22

33
import (
44
"errors"
5-
"log"
65
"fmt"
6+
"log"
77
)
88

99
var ErrNorgateMath = errors.New("norgate math: square root of negative number")
@@ -27,12 +27,3 @@ func Sqrt(f float64) (float64, error) {
2727
// see use of errors.New in standard library:
2828
// http://golang.org/src/pkg/bufio/bufio.go
2929
// http://golang.org/src/pkg/io/io.go
30-
31-
32-
33-
34-
35-
36-
37-
38-

23_error-handling/03_custom-errors/03_fmt-errorf/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package main
22

33
import (
4-
"log"
54
"fmt"
5+
"log"
66
)
77

88
func main() {
@@ -18,4 +18,4 @@ func Sqrt(f float64) (float64, error) {
1818
}
1919
// implementation
2020
return 42, nil
21-
}
21+
}

23_error-handling/03_custom-errors/04_fmt-errorf_var/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package main
22

33
import (
4-
"log"
54
"fmt"
5+
"log"
66
)
77

88
func main() {
@@ -19,4 +19,4 @@ func Sqrt(f float64) (float64, error) {
1919
}
2020
// implementation
2121
return 42, nil
22-
}
22+
}

23_error-handling/03_custom-errors/05_custom-type/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package main
22

33
import (
4-
"log"
54
"fmt"
5+
"log"
66
)
77

88
type NorgateMathError struct {
9-
lat, long string
10-
err error
9+
lat, long string
10+
err error
1111
}
1212

1313
func (n *NorgateMathError) Error() string {

25_code-walk/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ func main() {
103103
fmt.Printf("Wins, losses staying at k =% 4d: %s\n",
104104
k+1, ratioString(wins[k], games-wins[k]))
105105
}
106-
}
106+
}

25_code-walk/with-comments/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ func main() {
118118
fmt.Printf("Wins, losses staying at k =% 4d: %s\n",
119119
k+1, ratioString(wins[k], games-wins[k]))
120120
}
121-
}
121+
}

26_QUESTIONS-FROM-STUDENTS/01-package-scope/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ package main
22

33
import "fmt"
44

5-
func main(){
5+
func main() {
66
fmt.Println(x)
77
}

26_QUESTIONS-FROM-STUDENTS/04_goroutines_closing-chan/01_broken-code/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ func fanIn(input1, input2 <-chan string) <-chan string {
4545
close(c)
4646
}()
4747
return c
48-
}
48+
}

26_QUESTIONS-FROM-STUDENTS/04_goroutines_closing-chan/02_fixed-code/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ func fanIn(input1, input2 <-chan string) <-chan string {
8383

8484
go func(x <-chan string) {
8585
for n := range x {
86-
c <-n
86+
c <- n
8787
}
8888
done <- true
8989
}(input1)
9090

9191
go func(x <-chan string) {
9292
for n := range x {
93-
c <-n
93+
c <- n
9494
}
9595
done <- true
9696
}(input2)
@@ -111,4 +111,4 @@ func fanIn(input1, input2 <-chan string) <-chan string {
111111
// program flow comes to here and this func returns
112112
// the channel c
113113
return c
114-
}
114+
}

26_QUESTIONS-FROM-STUDENTS/06_performance-ramifications/main.go renamed to 26_QUESTIONS-FROM-STUDENTS/06_performance-ramifications/01_called/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ package main
22

33
import (
44
"fmt"
5+
"time"
56
)
67

78
func main() {
8-
9+
start := time.Now()
910
in := gen()
1011

1112
f := factorial(in)
1213

1314
for n := range f {
1415
fmt.Println(n)
1516
}
17+
18+
fmt.Println(time.Since(start))
1619
}
1720

1821
func gen() <-chan int {

0 commit comments

Comments
 (0)
0