Golang Code
Home
Tags
About
RSS
Search
Golang Code
A Library of Go Snippets
Search
2020
Jun 29
Validating an Email Address
May 22
Take a Screenshot of a Webpage with Headless Chrome
May 10
URL Encode a String
Apr 17
Exit an Application, With or Without an Error Code
Mar 29
Connect to PostgreSQL and Run a Query
Mar 13
How to: Handle Errors within Wait Groups
Feb 22
Mock S3 Uploads in Go Tests
Jan 25
Argon2 Password Hashing
Jan 11
Perform Sentiment Analysis on Sentences
2019
Dec 7
Foreach Loops: The Go Way
Oct 26
Build a Basic Web Scraper in Go
Oct 25
Get the IP Address of a HTTP Request
Sep 29
Convert iota List to String in JSON
Sep 24
How to Run a Single Test
Sep 19
Generate a PDF in Go
Aug 26
JSON Web Tokens: Authenticating your API
Aug 16
Check Element Exists in a Slice
Aug 8
Read a File to String
Jul 23
Timeout a Function Call (with Goroutines & Channels)
Jul 4
Find Common Colours in an Image
Jun 29
How to Check If a String Starts With ...
Jun 9
Working with POST Request Data
Jun 7
Go Get: Install All Packages
Jun 1
Sublime Text Workflow: Auto Build & Format
May 3
JSON Encode - Pretty Print
Feb 24
Basic Docker Setup for HTTP Server (using docker-compose)
Feb 16
Check If a Date/Time Has Been Set with IsZero
Feb 2
Is Long/Lat within Polygon from GeoJson
Jan 28
Convert Interface to Type: Type Assertion
Jan 19
Run Code Once on First Load (Concurrency Safe)
Jan 14
Disable Log Output During Tests
Jan 10
Sending a Slack Message (without a library)
2018
Dec 21
Create a Basic HTTPS Server (using TLS)
Nov 4
Waiting for Goroutines to Finish with a WaitGroup
Oct 25
Parsing Dates from a String and Formatting
Oct 6
Run System Commands & Binary Files
Aug 10
Sorting an Array of Numbered String Values
Jul 6
Creating & Writing to Temp Files
Jun 30
Encode and Decode Strings using Base 64
Jun 20
HTTP Get Request with Timeout
Jun 8
Get the HTTP Method from a Request
May 29
AWS Lambda PDF Generator
May 5
Substring: How to Split a String
Mar 30
Apply Middleware to Your Route Handlers
Mar 24
Generating a SHA256 HMAC Hash
Feb 9
Converting a PDF to JPG (using ImageMagick)
Feb 3
Creating, Wrapping and Handling Errors
Jan 21
Struct Tags for Encoding/Decoding Data
Jan 20
Convert uint64 to a String
2017
Dec 30
Print The Current Memory Usage
Dec 17
While True: Looping in Go
Dec 7
How Long Does a Function Take: Measuring Execution Time
Dec 4
How Detect Content Type of a File
Nov 5
Handle Ctrl+C (Signal Interrupt) Close in the Terminal
Nov 3
Part 2) Download Large Files with Progress Reports
Nov 2
Part 1) Download a File (from a URL)
Nov 1
Check If a File Exists Before Using It
Oct 20
Search and Replace in a String
Sep 28
Set a HTTP Cookie Response Header
Sep 14
Read a CSV File into a Struct
Aug 20
Uploading a File to AWS S3
Aug 10
Generating a Random Number
Aug 7
Print a Variable's Type (e.g. Int, String, Float)
Aug 7
Converting an Int to a String
Aug 6
HTTP Response Status Codes
Aug 6
Passing Data between Go Routines with Channels
Jul 10
Get and Set Environment Variables
Jun 8
Unzip Files in Go
Jun 8
Create Zip Files in Go
Jun 6
Cross Platform File Paths
Jun 1
How to Run Go Tests with Coverage Percentage
May 30
How to Check if a String is a URL
May 27
Updating Go on Ubuntu/Linux
May 3
Sleeping in Go – How to Pause Execution
May 2
Detect if Code is Running On Windows (at Runtime)
Apr 26
Get the Current Username, Name and Home Dir (Cross Platform)
Apr 14
Remove all Non-Alphanumeric Characters from a String (with help from regexp)
Apr 9
Get a URL Parameter from a Request
2016
Jun 10
Convert io.ReadCloser to a String
May 22
Serve Static Assets (using the Mux Router)
Mar 31
Fizz-Buzz Test in Go
Mar 24
MySQL Database Insert & Get Last Insert ID
Mar 22
Multi-line Strings
2015
Aug 30
Anonymous Functions (aka Closures)
Aug 30
Basic Go Routines (like Threading)
Aug 5
Find the Length of an Array/Slice
Aug 3
Write data to a CSV file
Aug 2
Passing Arguments into your Application
Aug 2
Writing to a File
Aug 2
Using Constants
Aug 2
Get the Current Unix Time
Aug 1
Attach a Logger to your Router
Aug 1
JSON Decode into Objects
Aug 1
JSON Encode an Array of Objects
Aug 1
Using HTML Templates from a Folder (Complied)
Jul 30
Hello world! How to Start any Go Application