Underscores in Imports
Underscores in Imports Underscores in Go serve a few purposes. In U+005F, “_” is a letter (as a string). You may also see them as [ “_” ] in between successive digits and a base prefix. In this case, it’s to improve the readability of the code. You may also see them in function names, e.g., imaginary_lit.
The underscore is quite a versatile tool. They even have their place in defining the kind of action that will take place in a function. ⌘ Read more
Struct Tags with Underscore Before Function Names
In the Go world, an underscore (_) before an expression is called a blank identifier. As you may already know, identifiers—user-defined program components, e.g., name of a function, variable, or package—in Go must be preceded by an underscore or a letter (a-z or A-Z). If they aren’t, you’ll receive the compile- time error which essentially means Go cannot read the syntax of your code (you didn’t write your code correctly … ⌘ Read more
Validating an Email Address ⌘ Read more…
Take a Screenshot of a Webpage with Headless Chrome ⌘ Read more…
URL Encode a String ⌘ Read more…
Exit an Application, With or Without an Error Code ⌘ Read more…
Connect to PostgreSQL and Run a Query ⌘ Read more…
How to: Handle Errors within Wait Groups ⌘ Read more…
Mock S3 Uploads in Go Tests ⌘ Read more…
Argon2 Password Hashing ⌘ Read more…
Perform Sentiment Analysis on Sentences ⌘ Read more…
Foreach Loops: The Go Way ⌘ Read more…
Build a Basic Web Scraper in Go ⌘ Read more…
Get the IP Address of a HTTP Request ⌘ Read more…
Convert iota List to String in JSON ⌘ Read more…
How to Run a Single Test ⌘ Read more…
Generate a PDF in Go ⌘ Read more…
JSON Web Tokens: Authenticating your API ⌘ Read more…
Check Element Exists in a Slice ⌘ Read more…
Read a File to String ⌘ Read more…
Timeout a Function Call (with Goroutines & Channels) ⌘ Read more…
Find Common Colours in an Image ⌘ Read more…
How to Check If a String Starts With … ⌘ Read more…
Working with POST Request Data ⌘ Read more…
Go Get: Install All Packages ⌘ Read more…
Sublime Text Workflow: Auto Build & Format ⌘ Read more…
JSON Encode - Pretty Print ⌘ Read more…
Basic Docker Setup for HTTP Server (using docker-compose) ⌘ Read more…
Check If a Date/Time Has Been Set with IsZero ⌘ Read more…
Is Long/Lat within Polygon from GeoJson ⌘ Read more…
Convert Interface to Type: Type Assertion ⌘ Read more…
Run Code Once on First Load (Concurrency Safe) ⌘ Read more…
Disable Log Output During Tests ⌘ Read more…
Sending a Slack Message (without a library) ⌘ Read more…
Create a Basic HTTPS Server (using TLS) ⌘ Read more…
Waiting for Goroutines to Finish with a WaitGroup ⌘ Read more…
Parsing Dates from a String and Formatting ⌘ Read more…
Run System Commands & Binary Files ⌘ Read more…
Sorting an Array of Numbered String Values ⌘ Read more…
Creating & Writing to Temp Files ⌘ Read more…
Encode and Decode Strings using Base 64 ⌘ Read more…
HTTP Get Request with Timeout ⌘ Read more…
Get the HTTP Method from a Request ⌘ Read more…
AWS Lambda PDF Generator ⌘ Read more…
Substring: How to Split a String ⌘ Read more…
Apply Middleware to Your Route Handlers ⌘ Read more…
Generating a SHA256 HMAC Hash ⌘ Read more…
Converting a PDF to JPG (using ImageMagick) ⌘ Read more…
Creating, Wrapping and Handling Errors ⌘ Read more…
Struct Tags for Encoding/Decoding Data ⌘ Read more…
Convert uint64 to a String ⌘ Read more…
Print The Current Memory Usage ⌘ Read more…
While True: Looping in Go ⌘ Read more…
How Long Does a Function Take: Measuring Execution Time ⌘ Read more…
How Detect Content Type of a File ⌘ Read more…
Handle Ctrl+C (Signal Interrupt) Close in the Terminal ⌘ Read more…
Part 2) Download Large Files with Progress Reports ⌘ Read more…
Part 1) Download a File (from a URL) ⌘ Read more…
Check If a File Exists Before Using It ⌘ Read more…
Search and Replace in a String ⌘ Read more…
Set a HTTP Cookie Response Header ⌘ Read more…
Read a CSV File into a Struct ⌘ Read more…
Uploading a File to AWS S3 ⌘ Read more…
Generating a Random Number ⌘ Read more…
Print a Variable’s Type (e.g. Int, String, Float) ⌘ Read more…
Converting an Int to a String ⌘ Read more…
HTTP Response Status Codes ⌘ Read more…
Passing Data between Go Routines with Channels ⌘ Read more…
About ⌘ Read more…
Search ⌘ Read more…
Privacy Policy ⌘ Read more…
Get and Set Environment Variables ⌘ Read more…
Unzip Files in Go ⌘ Read more…
Create Zip Files in Go ⌘ Read more…
Cross Platform File Paths ⌘ Read more…
How to Run Go Tests with Coverage Percentage ⌘ Read more…
How to Check if a String is a URL ⌘ Read more…
Updating Go on Ubuntu/Linux ⌘ Read more…
Sleeping in Go – How to Pause Execution ⌘ Read more…
Detect if Code is Running On Windows (at Runtime) ⌘ Read more…
Get the Current Username, Name and Home Dir (Cross Platform) ⌘ Read more…
Remove all Non-Alphanumeric Characters from a String (with help from regexp) ⌘ Read more…
Get a URL Parameter from a Request ⌘ Read more…
Add Line Numbers to Log Output ⌘ Read more…
Convert io.ReadCloser to a String ⌘ Read more…
How to Install Go on Ubuntu 18.04/20.04 ⌘ Read more…
Serve Static Assets (using the Mux Router) ⌘ Read more…
Fizz-Buzz Test in Go ⌘ Read more…
MySQL Database Insert & Get Last Insert ID ⌘ Read more…
Multi-line Strings ⌘ Read more…
Anonymous Functions (aka Closures) ⌘ Read more…
Basic Go Routines (like Threading) ⌘ Read more…
Find the Length of an Array/Slice ⌘ Read more…
Write data to a CSV file ⌘ Read more…
Passing Arguments into your Application ⌘ Read more…
Writing to a File ⌘ Read more…
Using Constants ⌘ Read more…
Get the Current Unix Time ⌘ Read more…
Attach a Logger to your Router ⌘ Read more…
JSON Decode into Objects ⌘ Read more…