Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition
/ functions
Functions
795 in github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition
⨍
Functions
795
◇
Types & classes
269
↓ 2 callers
Method
Init
Init sets the ordinal value can only be done once
chapter10/atomic/ordinal.go:23
↓ 2 callers
Function
LoadFile
LoadFile unmarshalls a json file into a config struct
chapter2/envvar/config.go:27
↓ 2 callers
Function
Logger
Logger is one of our 'middleware' decorators
chapter7/decorator/middleware.go:10
↓ 2 callers
Function
NewFSM
NewFSM creates a new FSM with start state of "first"
chapter11/consensus/fsm.go:17
↓ 2 callers
Function
NewMockAsyncProducer
(ctrl *gomock.Controller)
chapter12/asynckafka/producer/mocks_test.go:22
↓ 2 callers
Function
OriginalError
OriginalError returns the error original error
chapter4/log/error.go:7
↓ 2 callers
Function
PassThroughError
PassThroughError calls OriginalError and forwards the error along after wrapping.
chapter4/log/error.go:13
↓ 2 callers
Function
Patch
Patch sets the value pointed to by the given destination to the given value, and returns a function to restore it to its original value. The value mu
chapter9/mocking/patch.go:18
↓ 2 callers
Function
Process
Process switches on operation type Then does work
chapter10/state/process.go:7
↓ 2 callers
Function
Process
Process dispatches work to the worker pool channel
chapter10/pool/work.go:30
↓ 2 callers
Method
Process
Process does the encoding then pushes the result onto Res
chapter12/goflow/components.go:15
↓ 2 callers
Method
ProcessRequest
ProcessRequest modifies the request in accordnance with Proxy settings
chapter8/proxy/process.go:11
↓ 2 callers
Function
ProcessResponse
Process response grabs results and errors from a producer asynchronously
chapter12/asynckafka/producer/producer.go:11
↓ 2 callers
Function
Query
Query grabs a new connection creates tables, and later drops them and issues some queries
chapter6/database/query.go:13
↓ 2 callers
Function
Query
Query grabs a new connection and issues some queries printing the results
chapter6/dbinterface/query.go:11
↓ 2 callers
Function
ReadCSV
ReadCSV gives shows some examples of processing CSV that is passed in as an io.Reader
chapter1/csvformat/read_csv.go:20
↓ 2 callers
Function
ReadItems
ReadItems returns our list of items in a thread-safe way
chapter14/fastweb/items.go:24
↓ 2 callers
Method
Respond
Respond switches on Content Type to determine the response
chapter8/negotiate/respond.go:8
↓ 2 callers
Method
Restore
Restore restores some previous state.
chapter9/mocking/patch.go:10
↓ 2 callers
Method
Set
Set sets a value to a key, then returns the value
chapter8/grpcjson/internal/keyvalue.go:26
↓ 2 callers
Function
SetID
SetID updates context with the id then increments it
chapter8/middleware/context.go:18
↓ 2 callers
Function
Setup
Setup initializes our ClientInterface
chapter7/decorator/config.go:10
↓ 2 callers
Function
Setup
Setup return an oauth2Config configured to talk to github, you need environment variables set for your id and secret
chapter7/oauthcli/config.go:15
↓ 2 callers
Function
Setup
Setup initializes a mongo client
chapter11/orchestrate/config.go:13
↓ 2 callers
Function
Setup
Setup initializes a mongo client
chapter6/mongodb/config.go:12
↓ 2 callers
Function
Setup
Setup configures the db along with pools number of connections and more
chapter6/pools/pools.go:13
↓ 2 callers
Function
Setup
Setup sets some values
chapter10/context/values.go:13
↓ 2 callers
Method
SetupMenu
SetupMenu initializes the base flags
chapter2/cmdargs/cmdargs.go:37
↓ 2 callers
Method
String
()
chapter8/grpcjson/keyvalue/keyvalue.pb.go:84
↓ 2 callers
Method
String
()
chapter2/flags/custom.go:13
↓ 2 callers
Method
Successes
()
chapter12/asynckafka/producer/mocks_test.go:70
↓ 2 callers
Method
ToJSON
ToJSON dumps the JSONData struct to a JSON format bytes.Buffer
chapter2/confformat/json.go:18
↓ 2 callers
Method
ToTOML
ToTOML dumps the TOMLData struct to a TOML format bytes.Buffer
chapter2/confformat/toml.go:18
↓ 2 callers
Method
ToYAML
ToYAML dumps the YAMLData struct to a YAML format bytes.Buffer
chapter2/confformat/yaml.go:18
↓ 2 callers
Method
Transition
Transition will move a state to the next state if able
chapter11/consensus/state.go:33
↓ 2 callers
Method
Version
Version prints the current version that is stored as a const
chapter2/cmdargs/cmdargs.go:69
↓ 2 callers
Function
WithField
WithField adds a log field to the context
chapter4/context/log.go:34
↓ 2 callers
Function
WithField
WithField exports the logs withfield connected to our global log
chapter4/global/global.go:40
↓ 2 callers
Function
WithFields
WithFields adds many log fields to the context
chapter4/context/log.go:39
↓ 2 callers
Function
WordCount
WordCount takes a file and returns a map with each word as a key and it's number of appearances as a value
chapter2/pipes/pipes.go:13
↓ 2 callers
Method
Work
Work is how to dispatch a worker, they are assigned a job here
chapter10/pipeline/worker.go:26
↓ 2 callers
Function
Worker
Worker loops forever and is part of the worker pool
chapter10/pool/worker.go:23
↓ 2 callers
Function
callRequestRouted
Call twirp.ServerHooks.RequestRouted if the hook is available
chapter7/twirp/rpc/greeter/greeter.twirp.go:719
↓ 2 callers
Function
callResponsePrepared
Call twirp.ServerHooks.ResponsePrepared if the hook is available
chapter7/twirp/rpc/greeter/greeter.twirp.go:727
↓ 2 callers
Function
compareWork
(wr WorkRequest)
chapter10/pool/crypto.go:14
↓ 2 callers
Function
errorFromResponse
errorFromResponse builds a twirp.Error from a non-200 HTTP response. If the response has a valid serialized Twirp error, then it's returned. If not, t
chapter7/twirp/rpc/greeter/greeter.twirp.go:495
↓ 2 callers
Function
gatherLocation
(ctx context.Context)
chapter4/context/collect.go:35
↓ 2 callers
Function
gatherName
(ctx context.Context)
chapter4/context/collect.go:31
↓ 2 callers
Function
hashWork
(wr WorkRequest)
chapter10/pool/crypto.go:5
↓ 2 callers
Function
newRequest
newRequest makes an http.Request from a client, adding common headers.
chapter7/twirp/rpc/greeter/greeter.twirp.go:446
↓ 2 callers
Method
queryMessages
(ctx context.Context, limit int)
chapter13/appengine/message.go:27
↓ 2 callers
Method
storeMessage
(ctx context.Context, message string)
chapter13/appengine/message.go:16
↓ 2 callers
Function
toString
ToString is an example of taking an io.Reader and consuming it all, then returning a string
chapter1/bytestrings/buffer.go:32
↓ 2 callers
Function
twirpErrorFromIntermediary
twirpErrorFromIntermediary maps HTTP errors from non-twirp sources to twirp errors. The mapping is similar to gRPC: https://github.com/grpc/grpc/blob/
chapter7/twirp/rpc/greeter/greeter.twirp.go:535
↓ 2 callers
Function
urlBase
urlBase helps ensure that addr specifies a scheme. If it is unparsable as a URL, it returns addr unchanged.
chapter7/twirp/rpc/greeter/greeter.twirp.go:412
↓ 2 callers
Function
withoutRedirects
The standard library will, by default, redirect requests (including POSTs) if it gets a 302 or 303 response, and also 301s in go1.8. It redirects by m
chapter7/twirp/rpc/greeter/greeter.twirp.go:602
↓ 2 callers
Function
writeError
writeError writes Twirp errors in the response and triggers hooks.
chapter7/twirp/rpc/greeter/greeter.twirp.go:373
↓ 1 callers
Function
AddItems
AddItems modifies our array
chapter14/fastweb/handlers.go:18
↓ 1 callers
Function
AddMoviesFromText
AddMoviesFromText uses the CSV parser with a string
chapter1/csvformat/read_csv.go:59
↓ 1 callers
Function
Apex
Apex has a number of useful tricks
chapter4/structured/apex.go:31
↓ 1 callers
Function
ApplyMiddleware
ApplyMiddleware will apply all middleware, the last arguments will be the outer wrap for context passing purposes
chapter8/middleware/middleware.go:14
↓ 1 callers
Method
AsyncClose
()
chapter12/asynckafka/producer/mocks_test.go:32
↓ 1 callers
Function
Authenticate
Authenticate grabs oauth scopes using a generated service_account.json file from https://console.firebase.google.com/project/go-cookbook/settings/serv
chapter13/firebase/auth.go:14
↓ 1 callers
Function
Base64Example
Base64Example demonstrates using the base64 package
chapter3/encoding/base64.go:12
↓ 1 callers
Function
Base64ExampleEncoder
Base64ExampleEncoder shows similar examples with encoders/decoders
chapter3/encoding/base64.go:33
↓ 1 callers
Function
BaseEncoding
BaseEncoding shows encoding and decoding with normal types
chapter3/nulls/base.go:23
↓ 1 callers
Function
BasicErrors
BasicErrors demonstrates some ways to create errors
chapter4/basicerrors/basicerrors.go:19
↓ 1 callers
Function
CapitalizerExample
CapitalizerExample creates two files, writes to one then calls Capitalizer() on both
chapter1/filedirs/files.go:33
↓ 1 callers
Method
Cause
()
chapter7/twirp/rpc/greeter/greeter.twirp.go:578
↓ 1 callers
Method
Commit
()
chapter6/dbinterface/transaction.go:18
↓ 1 callers
Function
Config
Config creates num in-memory raft nodes and connects them
chapter11/consensus/config.go:9
↓ 1 callers
Function
ConvertPenniesToDollarString
ConvertPenniesToDollarString takes a penny amount as an int64 and returns a dollar string representation
chapter3/currency/pennies.go:9
↓ 1 callers
Function
ConvertStringDollarsToPennies
ConvertStringDollarsToPennies takes a dollar amount as a string, i.e. 1.00, 55.12 etc and converts it into an int64
chapter3/currency/dollars.go:12
↓ 1 callers
Function
Copy
Copy copies data from in to out first directly, then using a buffer. It also writes to stdout
chapter1/interfaces/interfaces.go:11
↓ 1 callers
Function
CounterHandler
CounterHandler will update a counter each time it's called
chapter11/metrics/handler.go:11
↓ 1 callers
Function
Coverage
Coverage is a simple function with some brancing conditions
chapter9/coverage/coverage.go:6
↓ 1 callers
Function
Crawl
Crawl collects responses from a list of urls that are passed in. It waits for all requests to complete before returning.
chapter10/waitgroup/process.go:12
↓ 1 callers
Function
DefaultGetGolang
DefaultGetGolang uses the default client to get golang.org
chapter7/client/exec.go:22
↓ 1 callers
Function
Dispatch
Dispatch creates numWorker workers, returns a cancel functionand channels for adding work and responses, cancel must be called
chapter10/pool/worker.go:10
↓ 1 callers
Function
DoOps
DoOps takes a client, then fetches google.com
chapter7/client/exec.go:10
↓ 1 callers
Function
DoSomeStuff
(d DoStuffer)
chapter9/mocking/exec.go:9
↓ 1 callers
Method
DoStuff
(input string)
chapter9/mocking/mock.go:5
↓ 1 callers
Function
EmptyStruct
EmptyStruct demonstrates serialize and deserialize for an Empty struct with tags
chapter3/tags/tags.go:18
↓ 1 callers
Function
Examples
Examples demonstrates some of the functions in the math package
chapter3/math/math.go:10
↓ 1 callers
Function
Exec
Exec creates a client, calls google.com then prints the response
chapter7/decorator/exec.go:7
↓ 1 callers
Function
Exec
Exec creates an API Client and uses its GetGoogle method, then prints the result
chapter7/rest/exec.go:7
↓ 1 callers
Function
Exec
Exec creates then queries an Example
chapter11/orchestrate/exec.go:17
↓ 1 callers
Function
Exec
Exec creates a consul entry then queries it
chapter11/discovery/exec.go:6
↓ 1 callers
Function
Exec
Exec creates then queries an Example
chapter6/mongodb/exec.go:17
↓ 1 callers
Function
Exec
Exec takes a new connection creates tables, and later drops them and issues some queries
chapter6/database/exec.go:12
↓ 1 callers
Function
Exec
Exec replaces the Exec from the previous recipe
chapter6/dbinterface/exec.go:5
↓ 1 callers
Function
Exec
Exec performs some redis operations
chapter6/redis/exec.go:11
↓ 1 callers
Function
Exec
Exec sets two random timers and prints a different context value for whichever fires first
chapter10/context/exec.go:13
↓ 1 callers
Function
ExecWithTimeout
ExecWithTimeout will timeout trying to get the current time
chapter6/pools/timeout.go:10
↓ 1 callers
Function
FetchAll
FetchAll grabs a list of urls
chapter7/async/exec.go:4
↓ 1 callers
Function
Fib
Fib prints the nth digit of the fibonacci sequence it will return 1 for anything < 0 as well... it's calculated recursively and use big.Int since int6
chapter3/math/fib.go:17
↓ 1 callers
Function
Filter
Filter is a functional filter. It takes a list of WorkWith and a WorkWith Function that returns a bool for each "true" element we return it to the res
chapter3/collections/collections.go:14
↓ 1 callers
Function
FinalDestination
FinalDestination deals with the error and doesn't forward it
chapter4/log/error.go:22
↓ 1 callers
Method
Fire
Fire will trigger whenever you log
chapter4/structured/logrus.go:12
↓ 1 callers
Function
FromContext
FromContext takes an entry and a context then returns an entry populated from the context object
chapter4/context/log.go:26
← previous
next →
101–200 of 795, ranked by callers