File tree Expand file tree Collapse file tree 10 files changed +13
-13
lines changed
testing/web_server/handlers Expand file tree Collapse file tree 10 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -101,5 +101,5 @@ func Unmarshal(data []byte, v interface{}) error {
101
101
// that's gonna create a cascading effect all the way through our code. We are no longer protected
102
102
// by the decoupling of the error interface.
103
103
104
- // This sometime has to happen. Can we do something differnt not to lose the decoupling. This is
104
+ // This sometime has to happen. Can we do something different not to lose the decoupling. This is
105
105
// where the idea of behavior as context comes in.
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ func (c *AppError) Error() string {
37
37
func main () {
38
38
// Make the function call and validate the error.
39
39
40
- // firtCall calls secondCall calls thirdCall then results in AppError.
40
+ // firstCall calls secondCall calls thirdCall then results in AppError.
41
41
// Start down the call stack, in thirdCall, where the error occurs. The is the root of the
42
42
// error. We return it up the call stack in our traditional error interface value.
43
43
// Back to secondCall, we get the interface value and there is a concrete type stored inside
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import (
15
15
// publisher is an interface to allow this package to mock the pubsub package.
16
16
// When we are writing our applications, declare our own interface that map out all the APIs call
17
17
// we need for the APIs. The concrete types APIs in the previous files satisfy it out of the box.
18
- // We can write the entire application with mocking decoupling from conrete implementations.
18
+ // We can write the entire application with mocking decoupling from concrete implementations.
19
19
type publisher interface {
20
20
Publish (key string , v interface {}) error
21
21
Subscribe (key string ) error
Original file line number Diff line number Diff line change 1
1
// Constant are not variables.
2
- // Contants have a parallel type system all to themselves. The minimum precision for constant is
2
+ // Constants have a parallel type system all to themselves. The minimum precision for constant is
3
3
// 256 bit. They are considered to be mathematically exact.
4
4
// Constants only exist at complied time.
5
5
@@ -14,7 +14,7 @@ func main() {
14
14
15
15
// Constant can be typed or untyped.
16
16
// When it is untyped, we consider it as a kind.
17
- // They are implicitly converted by the complier .
17
+ // They are implicitly converted by the compiler .
18
18
19
19
// Untyped Constants.
20
20
const ui = 12345 // kind: integer
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ type reader interface {
37
37
// It is a concrete type because it has the method read below. It is identical to the method in
38
38
// the reader interface. Because of this, we can say the concrete type file implements the reader
39
39
// interface using a value receiver.
40
- // There is no fancy syntax. The complier can automatically recognize the implementation here.
40
+ // There is no fancy syntax. The compiler can automatically recognize the implementation here.
41
41
42
42
// ------------
43
43
// Relationship
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ func main() {
79
79
// This is a second way we can define users. We can use an existing type and use it as a base for
80
80
// another type. These are two different types. There is no relationship here.
81
81
// However, when we try use it as a key, like: u := make(map[users]int)
82
- // the complier says we cannot use that: "invalid map key type users"
82
+ // the compiler says we cannot use that: "invalid map key type users"
83
83
// The reason is: whatever we use for the key, the value must be comparable. We have to use it
84
84
// in some sort of boolean expression in order for the map to create a hash value for it.
85
85
}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ func (u user) notify() {
18
18
}
19
19
20
20
// changeEmail implements a method with a pointer receiver: u of type pointer user
21
- // Using the pointer reciever , the method operates on shared access.
21
+ // Using the pointer receiver , the method operates on shared access.
22
22
func (u * user ) changeEmail (email string ) {
23
23
u .email = email
24
24
}
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ func increment2(inc *int) {
86
86
}
87
87
88
88
// stayOnStack shows how the variable does not escape.
89
- // Since we know the size of the user value at compiled time, the complier will put this on a stack
89
+ // Since we know the size of the user value at compiled time, the compiler will put this on a stack
90
90
// frame.
91
91
func stayOnStack () user {
92
92
// In the stayOnStack stack frame, create a value and initialize it.
@@ -152,7 +152,7 @@ func escapeToHeap() *user {
152
152
// cost.
153
153
154
154
// Because stack can grow, no Goroutine can have a pointer to some other Goroutine stack.
155
- // There would be too much overhead for complier to keep track of every pointer. The latency will
155
+ // There would be too much overhead for compiler to keep track of every pointer. The latency will
156
156
// be insane.
157
157
// -> The stack for a Goroutine is only for that Goroutine only. It cannot be shared between
158
158
// Goroutine.
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ func main() {
149
149
// The length is slice3 is 2 and capacity is 6.
150
150
// Parameters are [starting_index : (starting_index + length)]
151
151
// By looking at the output, we can see that they are sharing the same backing array.
152
- // Thes slice headers get to stay on the stack when we use these value semantics. Only the
152
+ // These slice headers get to stay on the stack when we use these value semantics. Only the
153
153
// backing array that needed to be on the heap.
154
154
slice3 := slice2 [2 :4 ]
155
155
@@ -212,7 +212,7 @@ func main() {
212
212
213
213
// Append a new value to the slice. This line of code raises a red flag.
214
214
// We have x is a slice with length 7, capacity 7. Since the length and capacity is the same,
215
- // append doubles its size then copy values over. x nows points to diffrent memeory block and
215
+ // append doubles its size then copy values over. x nows points to different memory block and
216
216
// has a length of 8, capacity of 14.
217
217
x = append (x , 800 )
218
218
Original file line number Diff line number Diff line change 11
11
// our API. More interestingly, Examples are not only for documentation but they can also be tests.
12
12
// For them to be tests, we need to add a comment at the end of the functions: one is Output and
13
13
// one is expected output. If we change the expected output to be something wrong then, the
14
- // complier will tell us when we run the test. Below is an example.
14
+ // compiler will tell us when we run the test. Below is an example.
15
15
16
16
// Example tests are really powerful. They give users examples how to use the API and validate that
17
17
// the APIs and examples are working.
You can’t perform that action at this time.
0 commit comments