Tag: go

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

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

cobra: unable to redefine ‘h’ shorthand

“Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files” I’m currently using Cobra in the MediaWiki CLI project and recently came across an error while trying to auto-generate docs. I’m not actually trying to redefine this flag, but it looks like by…

By addshore January 15, 2022 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