Go Recipes: Difference between revisions
Jump to navigation
Jump to search
Line 53: | Line 53: | ||
* Using channels to monitor the amount of time a program is running and time it out, signals: "Go in Action" Section 7.1 Runner (page 179), [https://github.com/NovaOrdis/playground/blob/master/go/go-in-action/runner playground/go/go-in-action/runner] | * Using channels to monitor the amount of time a program is running and time it out, signals: "Go in Action" Section 7.1 Runner (page 179), [https://github.com/NovaOrdis/playground/blob/master/go/go-in-action/runner playground/go/go-in-action/runner] | ||
* Pooling "Go in Action" Section 7.2 page 188 | |||
* Workers "Go in Action" Section 7.3 page 198 | |||
=Conventions and Idioms= | =Conventions and Idioms= | ||
* Name factory functions <tt>New</tt>. The factory functions should return a value or a pointer depending on the [[Go_Concepts_-_The_Type_System#Primitive_vs._Non-Primitive_Nature|primitive nature of the type]]. | * Name factory functions <tt>New</tt>. The factory functions should return a value or a pointer depending on the [[Go_Concepts_-_The_Type_System#Primitive_vs._Non-Primitive_Nature|primitive nature of the type]]. |
Revision as of 18:53, 21 April 2016
Internal
Files
- Reading a file with os primitives: playground/go/files/read-file.go
- Readinga file with io/ioutil primitives: playground/go/files/read-file-2.go
- Writing a file with os primitives: playground/go/files/write-file.go
- Writing a file with io/ioutil primitives: playground/go/files/write-file-2.go
- Reading a directory with os primitives: playground/go/files/read-dir.go
- Walking a directory with path/filepath primitives: playground/go/files/walk-dir.go
Network
- TCP client and server with net primitives: playground/go/network/tcp-server.go, playground/go/network/tcp-client.go,
- HTTP server with net/http primitives: playground/go/network/http-server.go
- HTTP client with net/http and ioutil primitives: playground/go/network/http-client.go More HTTP details in "Go in Action" page 65.
- RPC - Introducing Go page 89
Command Line Parsing
Concurrency
- Unbuffered channel: playground/go/concurrency/unbuffered-channel.go
- Using a waitGroup to wait for goroutines to finish before exiting main(): playground/go/concurrency/waitGroup.go
Logging
Sleeping
Miscellaneous
- Using channels to monitor the amount of time a program is running and time it out, signals: "Go in Action" Section 7.1 Runner (page 179), playground/go/go-in-action/runner
- Pooling "Go in Action" Section 7.2 page 188
- Workers "Go in Action" Section 7.3 page 198
Conventions and Idioms
- Name factory functions New. The factory functions should return a value or a pointer depending on the primitive nature of the type.