« Back to home

Reflection in Go and modifying struct values

Recently I found myself wanting to write some code to load values into a Go object. The obvious approach is reflection. However, the Go documentation on reflection is somewhat impenetrable, and the accompanying article on The Laws of Reflection only has a single skimpy example involving structs right at the end. After some trial and error I came up with some robust code to demonstrate examining a struct and altering its fields.…

Read more »

"Stand back! I know regular expressions!"

For the last few days I’ve been taking part in the Advent of Code. Each day there are a couple of small programming problems to solve in your choice of language. There’s a Reddit community where people discuss the problems and their solutions. After solving the Day 5 problems pretty quickly, I went to the discussions and was a bit surprised to find that everyone was talking about regular expressions.…

Read more »

Go: Preliminary verdict

So, how do I feel about Go, now that I know it better? The good On the whole, I like it. Some high points: It’s reasonably terse, and there’s not much syntax to remember. Like Ruby, you can do a lot in not much code, and unlike (say) Java there isn’t really a big need for an IDE. It inherits from Modula-2 a focus on compile-time efficiency. No header files, a compact grammar, and rigid dependency declaration make for rapid compilation times.…

Read more »

Go

Back when I was 17, I thought C was the greatest programming language in the world. I had started programming in BASIC, messed with assembly language, then discovered Pascal. Both BASIC and Pascal were interpreted, at least in the implementations I had, so C was my first compiled language. Being able to produce machine code without writing assembler was a revelation. Sure, C had rough edges here and there — the type declarations often needed careful thought to decode — but it did the job like nothing else.…

Read more »