Installing GOLD

In a new directory, download gold, the GOLD file manager:

Make it executable, then run it:

chmod +x gold
./gold install

This generates the following files:

the GOLD file manager ./gold
base functions for GOLD ./lib/
GOLD’s configuration options $HOME/.config/gold
Directory for writing .awk files $HOME/opt/gold/awk

gold has the following command line options:

gold help print help text
gold install ensure base files exist
gold make update all .awk files for all the .golds
gold zap delete all .awk files
gold oks run all unit tests, return 0 if no “FAIL”s
gold run gold make, then run gawk -f for command line args

Note that a file can be executed without using gold. After running gold make, then the command

gawk -f XXX.awk

will run For convenience, the command gold go XXX runs make (to update all the .awk files) before running gawk -f XXX.


To test if your install worked, then in the same as directory as gold:

  • create a file ./lib/
  • add in some GOLD unit tests, as follows1.
# vim: nospell filetype=awk ts=2 sw=2 sts=2  et :
#--------- --------- --------- --------- --------- ---------

@include "gold"

function _gold1(f) {
  is(f, length("word"), 4) # passing test
  is(f, 10 > 1, 1)         # a pass test
function _gold2(f) {
  is(f, length("word"), 1) # failing test

Now run

../gold goldok

If this work wells, then we should see that two unit tests pass, and one fails:

#--- gold -----------------------
#TEST:  PASSED  _gold1  4       4
#TEST:  PASSED  _gold1  1       1
#TEST:  FAILED  _gold2  1       4


  1. A GOLD unit test function has a first argument f (the describes the test group) and calls the function is(f,want,got) to check that want equals got. This is called via BEGIN{tests(group,listOfTests)}