A first stab at gene expression

In the last post I talked a bit about how I might approach expressing genes in SnailLife Go, and how this worked in the PHP prototype of the simulation. I gave a rough example of how I’m thinking of handling gene expression - via “expresser” interfaces that organs are to implement. I got as far as having my outer shell organ implement SizeA1Expresser, but nothing actually happened yet. Something happens now.

Continue Reading »

Brainstorming the SnailLife gene system

In the original PHP prototype of SnailLife there exists a very rudimentary genetics system. Snails had what I called “visual traits” and “functional traits”. Visual traits had genes associated with them. The genes were all stored in the snail’s table and each gene had two “alleles”. During breeding I’d make virtual Punnett Squares of sorts to pass on genes from parents to offspring. But the system was inflexible - each allele for each gene and each gene type were hard coded in the snails table.

Continue Reading »

Building a snail one organ at a time

I think enough of the SnailLife Go infrastructure is ready now for me to start digging into the snail itself. In the PHP draft of SnailLife, I started with a basic concept of a snail “Here’s a snail. All it has is a name, size, and speed” and then made it more and more complex. By the end I had a model that had organs, genes, a reproductive system, macro/micro nutrient requirements, locomotion, a brain with memories, mood, etc.

Continue Reading »

Are YOU experiencing shady output from your Go debugger? Try these things!

A couple of days ago I noticed some unreliable output when stepping through the SnailLife server. I use GoLand and Delve debugger, but in the course of looking into this I picked up some tips from trial and error plus from some very helpful people which I think might be useful regardless of the debugger you use. First, the repro. Fedora 28 Go version 1.11 rc1 Delve version 1.

Continue Reading »

Quick and Dirty Function Timing in Go

When I want to do some rough timing comparisons or get a quick idea of what part of Thing X is taking so long I sometimes just time a few functions. I used to do this by getting st := time.Now() at the beginning of the function and then time.Since(st) at the end. It recently hit me that the same thing could be achieved with less duplication and messiness to clean up (when removing the timings) with something like this:

Continue Reading »

go-sql-driver and MySQL 8

I should know better than to use a latest tag in a Docker image. I’d never do this at work, so why did I do it in my hobby project? I blame Go’s nature of dealing with package versioning (that is, the lack thereof) for putting me in the “let’s use latest!” mindset (and yes I know they’re working on it). Anyway, I should know better, but here we are, writing this post.

Continue Reading »

Some SnailLife Go client testing notes

I’ve started working on client tests, which have been getting very neglected compared to the server. I figured I’d write some quick notes on what I’ve done so far before continuing, before I forget. The first thing I’m choosing to focus on testing is interaction with the server. I’m already testing my API on the server side, but I also want to make sure I’m sending correct requests and handling responses correctly from the client.

Continue Reading »

Testing SnailLife Go repositories

Every SnailLife model struct has a repository struct to go with it. Since all repos are implementing the same Repository interface I wanted to reuse most of the code for testing them, but also allow for custom repo-specific tests. For example,OwnerRepo does some stuff that StableRepo does not - like optionally retrieving stables belonging to an owner. For now I am going about it as follows, but any feedback or suggestions for a better way are more than welcome.

Continue Reading »

Excluding mocks from coverage reports

I noticed that my coverage reports were including mock packages. To get rid of this instead of running go test like this: go test -race -coverpkg=./... -coverprofile allcoverage1.10rc.out ./... I am now running it like this: CVPKG=$(go list ./... | grep -v mocks | tr '\n' ',') go test -race -coverpkg $CVPKG -coverprofile allcoverage1.10rc.out ./... go list ./... lists all packages in my project; we pipe that through grep -v mocks to exclude mocks; we then pipe that output to tr '\n' ',' to replace newlines (each package is listed on a new line) with commas.

Continue Reading »

Testing SnailLife Go on Go 1.10

This is quick braindump of getting SnailLife Go building and testing on Go 1.10. A few days ago I decided to start building and testing SnailLife Go on Go 1.10 RC 1 (now RC 2). It took a bit of wrangling, but after updating my local environment and finding the best image to use for GitLab CI, I now have it building on Go 1.9 and 1.10 rc 2.

Continue Reading »