This commit is contained in:
Lasse Martin Jakobsen 2019-07-02 16:14:41 +02:00 committed by GitHub
parent 1f5e6b3f04
commit efe7d709b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1236,7 +1236,7 @@ func Println(v ...interface{}) {
} }
``` ```
In this case, `Println` isn't just accepting a single `interface{}`; rather, the function accepts a <em>slice</em> of types that implement the empty `interface{}`. As there are no methods associated with the empty `interface{}`, <em>all</em> types are accepted, even making it possible to feed `Println` with a slice of different types. This is a very common pattern when handling string conversation (both from and to a string). Good examples of this come from the `json` standard library package: In this case, `Println` isn't just accepting a single `interface{}`; rather, the function accepts a <em>slice</em> of types that implement the empty `interface{}`. As there are no methods associated with the empty `interface{}`, <em>all</em> types are accepted, even making it possible to feed `Println` with a slice of different types. This is a very common pattern when handling string conversion (both from and to a string). Good examples of this come from the `json` standard library package:
```go ```go
func InsertItemHandler(w http.ResponseWriter, r *http.Request) { func InsertItemHandler(w http.ResponseWriter, r *http.Request) {