摘要:
Package imagedefines theImageinterface:package imagetype Image interface { ColorModel() color.Model Bounds() Rectangle At(x, y int) color.Col... 阅读全文
摘要:
Implement the following types and define ServeHTTP methods on them. Register them to handle specific paths in your web server.type String stringtype S... 阅读全文
摘要:
Package httpserves HTTP requests using any value that implementshttp.Handler:package httptype Handler interface { ServeHTTP(w ResponseWriter, r *Re... 阅读全文
摘要:
Copy yourSqrtfunction from the earlier exercises and modify it to return anerrorvalue.Sqrtshould return a non-nil error value when given a negative nu... 阅读全文
摘要:
An error is anything that can describe itself as an error string. The idea is captured by the predefined, built-in interface type,error, with its sing... 阅读全文
摘要:
A type implements an interface by implementing the methods.There is no explicit declaration of intent.Implicit interfaces decouple implementation pack... 阅读全文
摘要:
An interface type is defined by a set of methods.A value of interface type can hold any value that implements those methods.Note:The code on the left ... 阅读全文
摘要:
Methods can be associated with a named type or a pointer to a named type.We just saw twoAbsmethods. One on the*Vertexpointer type and the other on the... 阅读全文
摘要:
In fact, you can define a method onanytype you define in your package, not just structs.You cannot define a method on a type from another package, or ... 阅读全文
摘要:
Go does not have classes. However, you can define methods on struct types.Themethod receiverappears in its own argument list between thefunckeyword an... 阅读全文