Tangible Bytes

A Web Developer’s Blog

Golang : Glibc Not Found

I’ve written some Go code and in development it worked fine but now I need it to run on an old server and I get this error

./my-code: /lib64/libc.so.6: version `GLIBC_2.32’ not found (required by ./my-code)

Read more ...

Unstructured JSON to Golang

I really like the way Go imports json into its own data structures.

You just define a struct, annotate it to map the JSON field names to the struct field names (taking care to follow the Go convention of using Capitalised initials where the field is public).

There are also some great tools to automatically generate the struct from JSON

eg Convert JSON to Go struct

But where I got stuck was with JSON that is flexible and doesn’t match something I can directly make in Go.

Read more ...

Golang Prometheus Exporter Raspberry Pi

I have solar panels that are over 10 years old and I wanted to check if performance is degrading

I used an Open Source tool (SBFSpot) to grab some data from the inverter over bluetooth and so it has to be physically near the inverter and runs on a Raspberry Pi

So far so good - I have nice graphs at https://pvoutput.org

But I really wanted grafana graphs it is such a powerful dataviz tool

For that I needed to get the data to Prometheus

Read more ...

Unicode

A couple of things about UTF-8 have eluded me for a while …

I knew that the first bit of ASCII (the bit people agreed on) is the same in ASCII and UTF-8

I knew that the rest of Unicode needs 2 or 3 bytes

But I wasn’t clear how you could tell how many bytes needed to be read at a time

And mostly I didn’t need to because the computer does it all for me - but those bits of vagueness can catch you out and so I went down the rabbit hole and it turns out to be fairly short.

Read more ...

Writing Golang

I’ve really enjoyed learning Golang lately, the tour is a great place to start and I found using VSCode as an IDE really helped with automatic formatting and highlighting of errors.

Best things about Go so far for me are

Read more ...

Wildcard Proxy

I have a client who need to spin up webservers on demand to quickly test code and content, they use Docker to host these sites.

Currently they expose each site an a different port - which needs to be configured both within the container so that it can perform appropriate redirects, and by the user needing to get to the right site.

I’m automating the spin up process and wanted to make this a bit smoother.

I like to use wildcard DNS for ephemeral servers such as these.

A wildcard DNS record is a record in a DNS zone that will match requests for non-existent domain names.

A wildcard DNS record is specified by using a * as the leftmost label (part) of a domain name, e.g. *.example.com.

wikipedia

I just point this address at my Docker server and then any name like website1.testsites.example.com will resolve to my docker host.

Read more ...