// _range_ iterates over elements in a variety of data
// structures. Let's see how to use `range` with some
// of the data structures we've already learned.
package main
import "fmt"
func main() {| package main | |
| import ( | |
| "database/sql" | |
| "log" | |
| ) | |
| func main() { | |
| db, err := sql.Open("VENDOR_HERE", "YOUR_DSN_HERE") | |
| handleError(err) |
gRPC uses a set of well defined status codes as part of the RPC API. All
RPCs started at a client return a status object composed of an integer
code and a string message. The server-side can choose the status it
returns for a given RPC.
The gRPC client and server-side implementations may also generate and
return status on their own when errors happen. Only a subset of
the pre-defined status codes are generated by the gRPC libraries. This
Inside a package, any comment immediately preceding a top-level declaration serves as a doc comment for that declaration. Every exported (capitalized) name in a program should have a doc comment.
// Compile parses a regular expression and returns, if successful,
// a Regexp that can be used to match against text.
func Compile(str string) (*Regexp, error) {A single doc comment can introduce a group of related constants or variables.
// Error codes returned by failures to parse an expression.By convention, one-method interfaces are named by the method name plus an -er suffix or similar modification to construct an agent noun: Reader, Writer, Formatter, CloseNotifier etc.
There are a number of such names and it's productive to honor them and the function names they capture. Read, Write, Close, Flush, String and so on have canonical signatures and meanings. To avoid confusion, don't give your method one of those names unless it has the same signature and meaning. Conversely, if your type implements a method with the same meaning as a method on a well-known type, give it the same name and signature; call your string-converter method String not ToString.
// Like a C for
for init; condition; post { }
// Like a C while
for condition { }
// Like a C for(;;)
for { }