Tag: golang

Reading from USB COM port in go

If you want an easy copy and paste, no nonsense way to print the output of a COM PORT to the terminal in go, then have a look at the code at the bottom of this post. Firstly, the go.bug.st/serial/enumerator package provides a very nice interface for getting details of connected devices, and includes more…

By addshore July 30, 2024 0

Scanning for iBeacon advertisements in Go

I spent some time this evening faffing around trying to make a Raspberry Pi turn into a device that could detect nearby iBeacons, filtered by signal strength to find the closest, to basically create a kind of iBeacon scanner that spat out the UUID, minor and major values. Eventually, I gave up on the Raspberry…

By addshore January 10, 2024 0

Autoreload go code on code change

For developers, the ability to autoreload code upon any changes is nothing short of a game-changer. It not only streamlines the development process but also fosters an environment of continuous improvement and experimentation. There are so many packages for languages such as JavaScript for such a behaviour, but I struggled to easily find a simple-to-use…

By addshore September 22, 2023 0

Automatic cobra command registration with fx

Cobra is a popular Go package for creating CLIs. It provides a lot of functionality for creating commands, subcommands, and flags. However, it can be tedious to manually register all of your commands. fx is a Go package that provides a dependency injection framework. It can be used to automatically register your application components, including…

By addshore September 9, 2023 3

A copy-paste go SQL mock for GORM

When it comes to writing robust and reliable tests for your Go applications, having a well-structured and efficient testing setup is crucial. One common challenge in testing Go applications is dealing with database interactions. To ensure that your code functions correctly, it’s essential to create a controlled environment for database operations during testing. In this…

By addshore September 8, 2023 0

mwcli CI in Wikimedia GitLab (docker in docker)

mwcli is a golang CLI tool that I have been working on over the past year to replace the mediawiki-docker-dev development environment that I accidently created a few years back (among other things). I didn’t start the CLI, but I did this mediawiki-docker-dev like functionality. As some point through the development journey it became clear…

By addshore November 1, 2021 4

dockerit v0.0.5 (Easier than docker run)

dockerit is a small CLI tool that I have been working on during the start of 2021. It’s intended to make running one off commands and CLI tooling easier in docker. Rather than having to write a long string of parameters for docker run, instead you can just use dockerit. This applies to both CLI…

By addshore February 20, 2021 0

Go Docker SDK, Raw Terminal Ctrl+C handling

I spent my weekend in working on a new project called dockerit. It’s a simple wrapper around Docker written in Go and making use of the Docker SDK. One of the biggest sticking points for me, being fairly new with the Golang world, was trying to pass stdin stdout and stderr between the container and…

By addshore January 10, 2021 5

Simple Go defer code example

In Go, a defer statement will execute a function call just before the function it is called from returns. I found that most of the examples of a Go defer call online seemed to do complicated things with numbers. So here is a nice simple example with just text output. Example You can run this…

By addshore January 10, 2021 1