Skip to main content

Category: Software Development

Detecting MIME Types in Go

Introduction Knowing the type of a file you’re working with is not just a matter of curiosity — it’s often a necessity. This is especially true when you’re deciding whether or not a particular operation can be carried out on that file. Go, with its comprehensive standard library, offers a straightforward approach to identifying a file’s MIME type, ensuring that developers have the tools they need to make informed decisions about file manipulation.

Validating URLs with Go

Introduction In this post, we’ll take a quick look at URL validation using Golang. It’s common to implement URL validation as a task within a HTTP request pipeline, typically as middleware. There are many different definitions of “validation”. For the purpose of this article, we will simply validate that a URL conforms to a particular text pattern. I often see people (mistakenly) use URL and URI interchangeably. URL is actually is a sub-type of URI.

Using try/catch/finally Blocks in PowerShell

Despite being a great language, PowerShell is not impervious to errors. Errors that occur within your code can stop it’s execution or even cause unexpected changes in the resources that your script is managing. Learning to handle these errors gracefully is the foundation of defensive coding. Today, we’ll take a quick look at how PowerShell handles errors with Try-Catch-Finally blocks. They allow you to gracefully handle errors and perform cleanup operations, ensuring that your script doesn’t crash when the unexpected occurs.

Golang: When Identical Strings are Not Equal

This will be a quick and dirty post, so please forgive any spelling/grammar mistakes. I was writing a little CLI tool in Golang to track todo items. Just a dumb little app to help hone my skills a bit, but still something useful that serves a purpose to me. I don’t write a ton of code at work (mostly just scripting/pipelines when I do), so I’m constantly working on something like this in my spare time.

Handling Graceful Shutdown in a .NET App Hosted in Kubernetes

I was recently involved with troubleshooting some API’s hosted in Kubernetes throwing http/502’s. This was incredibly difficult to diagnose because it seemingly happened at random, and I had never encountered anything like this. Being that I had never dealt with this in the past, and I (nor my team) was able to figure it out within a reasonable amount of time, I turned to google. My searches resulted in various blogs and SO posts of other people experiencing similar issues, but none of their resolutions worked for us.

Building a Golang App with Github Actions

In this article, we’ll take a quick look at building a Golang app with Github actions. This process can be applied to just about any app written in any language though. We’ll cover the following: What are github actions? Setting up the workflow to build, test, and deploy a binary Github Actions is a cross-platform CI/CD pipeline that allows you to build, test, package, and release your software. Actions can be triggered manually or based on events that happen within your Github repo.

Chaining YAML Pipelines in Azure Devops

In this article, we’ll take a quick look at chaining two pipelines together in Azure Devops, so that the completion of one pipeline, triggers the other to run. Microsoft documentation is leaps and bounds ahead of where it used to be. However, I still feel like there is a lot of room for improvement, as it took me a while to figure this out. Our two pipelines will exist in the same repository.

Update Azure Devops SPN Secret

If you need to update the secret for a service principal in Azure Devops, prior to it expiring, you may be surprised to find that this cannot be done via the Azure Portal. In this article, I’ll show you two methods for updating a secret for a service principal prior to expiration. Update the secret via the Azure Devops Portal: Go to “Service Connections” in the Azure Devops portal Find the SPN you want to update, then click “Manage Service Principal” Then on the service principal page, click Certificates & Secrets Create a “New Client Secret”, take note of the value Delete the ‘old’ secret Return to the Service Connection in the Azure Devops portal Click Edit - click the verify button.

Use “replace” in go.mod to Point to a Local Module

If you want to the local version of a dependency in Go rather than one in a remote repository, use the replace keyword. The replace line goes above your require statements, like so: module github.com/rnemeth90/foo replace github.com/rnemeth90/bar => /Users/rnemeth90/Projects/bar require ( github.com/rnemeth90/bar v1.0.0 ) Now when you compile this module go build or go install, it will use your local code rather than the remote dependency. According to the docs, you do need to make sure that the code you’re pointing to also has a go.

Powershell for Devops - Querying REST APIs with Powershell

This will be a short post on querying REST APIs with Powershell. It’s hard to argue that REST APIs are the predominant technology for interacting with networked services. They provide a gateway for interacting with a 3rd party (or self-hosted) product without having to go through the exercise of a more complicated integration. REST APIs communicate in a common format, typically JSON. However, most will allow us to choose the response format by specifying an option in the ‘Accept’ header.