mirror of
https://github.com/Pungyeon/clean-go-article.git
synced 2024-11-23 06:04:05 +00:00
Update README.md
Co-Authored-By: Aleksandr Hovhannisyan <aleksandrhovhannisyan@gmail.com>
This commit is contained in:
parent
0f5b9126e8
commit
3605215928
|
@ -1204,7 +1204,7 @@ func main() {
|
|||
|
||||
We are no longer triggering a panic and can now use the `NullWriter` as a `Writer`. This initialisation process is not much different from having properties that are initialised as `nil`, as discussed previously. Therefore, logically, we should try to handle them in a similar way. However, this is where embedded interfaces become a little difficult to work with. In a previous section, it was explained that the best way to handle potential `nil` values is to make the property in question private and create a public *getter* method. This way, we could ensure that our property is, in fact, not `nil`. Unfortunately, this is simply not possible with embedded interfaces, as they are by nature always public.
|
||||
|
||||
Another concern raised by using embedded interfaces, is the potential confusion caused by partially overwritten interface methods:
|
||||
Another concern raised by using embedded interfaces is the potential confusion caused by partially overwritten interface methods:
|
||||
|
||||
```go
|
||||
type MyReadCloser struct {
|
||||
|
|
Loading…
Reference in a new issue