A place to keep my go examples.
Table of Contents
- ARCHITECTURES
- BLOCKCHAIN
- SCRAPING
- CGO
- C CODE
- CLIENT/SERVER
- gRPC
- HTTP
- TCP/IP
- CLOUD SERVICE PROVIDERS
- GOOGLE CLOUD PLATFORM
- MICROSOFT AZURE
- COMMON GO
- ERROR REPORTING
- FLAGS
- LOGGING
- MY GENERIC GO TEMPLATE
- TESTING
- CRYPTOGRAPHY
- ASYMMETRIC CRYPTOGRAPHY
- HASHING
- SYMMETRIC CRYPTOGRAPHY
- DATABASES
- NON-RELATIONAL
- RELATIONAL
- FUNCTIONS, METHODS AND INTERFACES
- FUNCTIONS
- METHODS
- INTERFACES
- GO RUNTIME
- GOROUTINES
- INTERACT GO RUNTIME
- INTERACT HOST OS
- INPUT/OUTPUT
- IO READER
- IO WRITER
- IN-PROCESS COMMUNICATION
- SHARED MEMORY
- MESSAGE PASSING
- INTER-PROCESS COMMUNICATION (IPC)
- SHARED MEMORY
- MESSAGE PASSING
- IoT
- RASPBERRY PI
- MODULES AND PACKAGES
- LOCAL PACKAGES
- REMOTE PACKAGES
Documentation and Reference
- My go cheat sheet
- my-go-packages
- my-go-tools
- This repos github webpage built with concourse
-
BLOCKCHAIN
-
Demonstrates a bitcoin ledger in a blockchain using the unspent transaction output model.
-
create-bitcoin-address-from-ecdsa-publickey
Create a bitcoin address from your ecdsa public key using the
crypto/ecdsa
standard package. -
single-node-blockchain-with-REST
A simple single node sha256 blockchain with a REST JSON API (to view (GET) the blockchain and add (POST) a block).
-
-
WEB SCRAPING
- [web scrape twitter for ???]
-
C CODE
-
A very simple example to show you how to write a c function in go.
-
A c function in go using stdio.h for printf.
-
-
gRPC
- Coming soon.
-
HTTP
- Coming soon.
-
TCP/IP
- Coming soon.
-
GOOGLE CLOUD PLATFORM
- Coming soon.
-
MICROSOFT AZURE
- Coming soon.
-
ERROR REPORTING
-
Error Handling using the standard
error
package.
-
-
FLAGS
-
The standard
flag
package makes it easy to implement command-line flag parsing.
-
-
LOGGING
-
Logging using
logrus
package.
-
-
MY GENERIC GO TEMPLATE
-
A simple go template with flags, logging & error handling.
-
-
TESTING
- Coming soon.
-
ASYMMETRIC CRYPTOGRAPHY (Great for digital signatures (verify sender) and receiving encrypted data)
- Coming soon.
-
HASHING (Great for getting fingerprints)
- Coming soon.
-
SYMMETRIC CRYPTOGRAPHY (Using the same key to encrypt and decrypt)
- Coming soon.
-
NON-RELATIONAL
- Coming soon.
-
RELATIONAL
- Coming soon.
-
FUNCTIONS
-
Using functions to calculate the area of a rectangle and circle.
-
Using functions to calculate the area of a rectangle and circle by passing pointers.
-
-
METHODS
-
Using methods to calculate the area of a rectangle and circle.
-
Using methods to calculate the area of a rectangle and circle by passing pointers.
-
Using methods to calculate the area of a rectangle and circle by passing pointers and using pointer receivers.
-
-
INTERFACES
-
Using an interface to calculate the area of a rectangle and circle.
-
Using an interface to calculate the area of a rectangle and circle by passing pointers.
-
Using an interface to calculate the area of a rectangle and circle by passing pointers and using pointer receivers.
-
Using an interface to calculate and manipulate simple 2D and 3D geometric shapes.
-
-
GO ROUTINES
-
Concurrency across multiples cores. You can play around with workers, threads, cpus/cores and nice to find the fastest performance. It will find the total number of prime numbers within a range.
-
Concurrency using a waitgroup (waiting for a collection of goroutines to finish).
-
Concurrency using worker pools.
-
-
INTERACT GO RUNTIME
-
simple-go-runtime-interactions
A few go runtime interactions using the
runtime
package.
-
-
INTERACT HOST OS
-
Run a few os commands using the
exec
package. -
A few os interactions using the
syscall
package.
-
-
IO READER
-
Read data (a stream of bytes) from a string, buffer, file, stdin and a pipe to a buffer using the standard
io
package. -
Read data (a stream of bytes) from a buffer to a buffer using the standard
io
package. -
Read a file (*os.File) to a buffer.
-
Read user input (os.Stdin) to a buffer (using Read method) and string (using Fscan).
-
-
IO WRITER
-
Write data (a stream of bytes) to a buffer, file, stdout and a pipe from a buffer using the standard
io
package. -
Write data (a stream of bytes) to a buffer from a buffer using the standard
io
package.
-
-
SHARED MEMORY
-
ASYNCHRONOUS
- Coming soon.
-
SYNCHRONOUS
-
A pipe provides a uni-directional communication channel. This is a very simple example of an unnamed pipe.
-
This is a more robust example of an unnamed pipe showing multiple reads.
-
This example of an unnamed pipe connects an io.Writer and io.Reader.
-
-
-
MESSAGE PASSING
-
ASYNCHRONOUS
-
Buffered channels are uni-directional, asynchronous with no blocking.
-
-
SYNCHRONOUS
-
Unbuffered channels are uni-directional, synchronous with blocking.
-
-
-
SHARED MEMORY
-
ASYNCHRONOUS
- Coming soon.
-
SYNCHRONOUS
-
Sending data over a named-pipe (FIFO) from one process to another process.
-
-
-
MESSAGE PASSING
-
OPERATING SYSTEM
-
ASYNCHRONOUS
-
tbd.
-
tbd.
-
tbd.
-
-
SYNCHRONOUS
-
tbd.
-
-
-
NETWORK
-
ASYNCHRONOUS
-
tbd.
-
tbd.
-
-
SYNCHRONOUS
-
tbd.
-
tbd.
-
-
-
-
RASPBERRY PI
-
blink-led-raspberry-pi-gpio-periph
GPIO OUTPUT - Blink an LED via a Raspberry Pi GPIO using the
periph.io/...
packages. -
push-button-raspberry-pi-gpio-periph
GPIO INPUT - Push a button via a Raspberry Pi GPIO using the
periph.io/...
packages. -
toggle-led-with-button-raspberry-pi-gpio-periph
Toggle an LED with a button push via a Raspberry Pi GPIO using the
periph.io/...
packages.
-
-
LOCAL PACKAGES
-
A go module with a local package.
-
-
REMOTE PACKAGES
-
A go module with a remote (public) package.
-