my-go-examples
my-go-examples is a place to keep my go code snippets and examples.
GO EXAMPLES
-
GOROUTINES
-
An example of concurrency and message passing via channels in go.
-
An example of concurrency using a waitgroup.
-
An example of concurrency using a worker pool with goroutines and channels.
-
An example of a gorouting asynchronously sending data (via a channel) to a function that
uses the latest data (if available) and does not wait.
-
-
MESSAGING
-
Protocol buffers serialize structured data, useful for messaging.
-
protobuf-NATS-publish-subscribe
Sends a protobuf msg over NATS from a client to a server using publish and subscribe.
-
protobuf-NATS-request-response
Sends a protobuf msg over NATS from a client to a server using request and response.
-
-
API
-
Using http package to GET or POST (update via json).
-
OAuth-2.0-google-cloud-storage-api
Using OAuth 2.0 to access a users google-cloud-storage (based on scopes) via googles api.
-
OAuth-2.0-google-cloud-storage-api-over-NATS
Using OAuth 2.0 (frontend and backend via protobuf over NATS) to
access a users google cloud storage (based on scopes) via googles api. -
Send and track an email using mailgun over their go client api
-
something-youttube-content-id-api
TBD
-
something-youttube-data-api-v3
TBD
-
TBD
-
Adding REST to the simple-webserver.
-
-
WEBSERVER
-
Using the http package to build a simple webserver.
-
-
DATABASE
-
read/write from/to a table.
-
-
BASIC PROGRAMMING
-
Encode a struct to json and decode back to a struct.
-
Testing a function with complex inputs and outputs.
-
A helloween theme is used for gomock on an interface for unit testing.
-
Reading a file a few different ways.
-
An example of a Singly Linked List (i.e. using just a head pointer).
-
An example of a pointer to a struct.*
-
An example of structs, methods and interfaces.
-
A function calling itself to make a fibonacci series.
-
Logging and error handling.
-
TESTED USING CONCOURSE
A Concourse CI Pipeline will automate unit testing and update the GitHub WebPage.
A ci/.credentials.yml file needs to be created for your slack_url and repo_github_token.
Use fly to upload the the pipeline file ci/pipline.yml to Concourse:
fly -t ci set-pipeline -p my-go-examples -c ci/pipeline.yml --load-vars-from ci/.credentials.ymlCONCOURSE RESOURCES IN PIPELINE
my-go-examples also contains a few extra concourse resources:
- A resource (resource-slack-alert) uses a docker image
that will notify slack on your progress. - A resource (resource-repo-status) use a docker image
that will update your git status for that particular commit.
The above resources can be removed from the pipeline.
