mirror of
https://github.com/Pungyeon/clean-go-article.git
synced 2024-11-23 14:14:05 +00:00
Update README.md
Co-Authored-By: Aleksandr H <aleksandrhovhannisyan@gmail.com>
This commit is contained in:
parent
828fd65cfa
commit
cf168cce6e
|
@ -1068,7 +1068,7 @@ func NewNullWriter() io.Writer {
|
|||
|
||||
The above function ensures that the `NullWriter` struct implements the `Writer` interface. If we were to delete the `Write` method from `NullWriter`, we would get a compilation error. This is a good way of ensuring that our code behaves as expected and that we can rely on the compiler as a safety net in case we try to write invalid code.
|
||||
|
||||
In certain cases, it might not be desirable to write a constructor, or perhaps we would like for our constructor to return the concrete type, rather than the interface. As an example, the `NullWriter` struct has no properties to populate on initialisation and therefore writing a constructor is a little redundant. Therefore, we can use the less verbose method of checking interface compatibility:
|
||||
In certain cases, it might not be desirable to write a constructor, or perhaps we would like for our constructor to return the concrete type, rather than the interface. As an example, the `NullWriter` struct has no properties to populate on initialisation, so writing a constructor is a little redundant. Therefore, we can use the less verbose method of checking interface compatibility:
|
||||
|
||||
```go
|
||||
type Writer interface {
|
||||
|
|
Loading…
Reference in a new issue