mirror of
https://github.com/Pungyeon/clean-go-article.git
synced 2024-11-23 06:04:05 +00:00
update readme, fix formatting
This commit is contained in:
parent
3011efee29
commit
7e2ba16f20
|
@ -833,8 +833,8 @@ func (cache *KVCache) Add(key, value string) {
|
|||
This code is absolutely fine. However, the danger is that our `App` can be initialised incorrectly, without initialising the `Cache` property within. Should the following code be invoked, our application will panic:
|
||||
|
||||
```go
|
||||
app := App{}
|
||||
app.Cache.Add("panic", "now")
|
||||
app := App{}
|
||||
app.Cache.Add("panic", "now")
|
||||
```
|
||||
|
||||
The `Cache` property has never been initialised and is therefore a `nil` pointer. Thus, invoking the `Add` method like we did here will cause a panic, with the following message:
|
||||
|
|
Loading…
Reference in a new issue