mirror of
https://github.com/Pungyeon/clean-go-article.git
synced 2024-11-23 14:14:05 +00:00
add the valid return signature for the getStringResult() function
This commit is contained in:
parent
d94be4024a
commit
115b35d60c
|
@ -423,7 +423,7 @@ Basically, we create a new structure named `RMQChannel` that contains the `amqp.
|
||||||
We'll use this idea of wrapping functions to introduce more clean and safe code later when discussing `interface{}`.
|
We'll use this idea of wrapping functions to introduce more clean and safe code later when discussing `interface{}`.
|
||||||
|
|
||||||
### Variable Scope
|
### Variable Scope
|
||||||
Now, let's take a step back and revisit the idea of writing smaller functions. This has another nice side effect that we didn't cover in the previous chapter: Writing smaller functions can typically eliminate reliance on mutable variables that leak into the global scope.
|
Now, let's take a step back and revisit the idea of writing smaller functions. This has another nice side effect that we didn't cover in the previous chapter: Writing smaller functions can typically eliminate reliance on mutable variables that leak into the global scope.
|
||||||
|
|
||||||
Global variables are problematic and don't belong in clean code; they make it very difficult for programmers to understand the current state of a variable. If a variable is global and mutable, then by definition, its value can be changed by any part of the codebase. At no point can you guarantee that this variable is going to be a specific value... And that's a headache for everyone. This is yet another example of a trivial problem that's exacerbated when the codebase expands.
|
Global variables are problematic and don't belong in clean code; they make it very difficult for programmers to understand the current state of a variable. If a variable is global and mutable, then by definition, its value can be changed by any part of the codebase. At no point can you guarantee that this variable is going to be a specific value... And that's a headache for everyone. This is yet another example of a trivial problem that's exacerbated when the codebase expands.
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ func main() {
|
||||||
case 64:
|
case 64:
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(val)
|
fmt.Println(val)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -475,7 +475,7 @@ func getStringResult(num int) (string, error) {
|
||||||
case 64:
|
case 64:
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
return ""
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in a new issue