Up to Main Index                           Up to Journal for October, 2019

                     JOURNAL FOR FRIDAY 4TH OCTOBER, 2019
______________________________________________________________________________

SUBJECT: Breakage fixed for Go 1.13
   DATE: Fri  4 Oct 21:53:50 BST 2019

I finally managed to work up the enthusiasm to tackle the breakage caused by
Go 1.13 and issue #31859[1]. I did feel bad just leaving things and walking
away for a while, but I needed to do just that.

After working things through and trying out a few experiments I have come to a
conclusion. That conclusion is: You can no longer use command flags to pass
settings into init functions and write tests using the testing package.

This is because you can no longer use flags.Parse in init functions without
testing complaining bitterly and failing miserably.

The only way I found of making the existing WolfMUD code work was to call
testing.Init just before flags.Parse in my config.init function. However, that
then means that testing flags will always be present in the binary — exactly
the problem that was meant to be solved by commit fbc6a9[2] and resulting in
issue #31859 in the first place! :(

The WolfMUD config package is not perfect and has its flaws. For example it is
not concurrently safe to update the server’s configuration once it is setup.
However, there has not been a requirement to change configuration settings on
the fly for a running server and the current package has been working well. In
the future it may become necessary to rework the config package, but that time
is not right now.

What to do?

++ NOTE: THE BELOW IS ONLY FOR THE PUBLIC DEV BRANCH UNTIL THE NEXT RELEASE ++

I’ve committed a change to the public dev branch to drop usage of command line
arguments to the server binary. The relevant WolfMUD documentation has also
been updated in the docs directory.

Currently the data path and configuration file are passed to the server as a
command line argument, assuming Linux and Bash in this example:


  ./server ./data/config.wrj


With this change the server now uses a WOLFMUD_DIR environment variable.
Assuming Linux and Bash again, you should now use:


  WOLFMUD_DIR=./data/config.wrj ./server


Alternatively, still assuming Linux and Bash, you can export the environment
variable first and then run the server:


  export WOLFMUD_DIR=./data/config.wrj
  ./server


On Windows you have to ‘set’ the environment variable, then run the server:


  set WOLFMUD_DIR=./data/config.wrj
  ./server


For other operating systems and command shells you will have to consult your
documentation. It’s not a pretty solution — but everything, including tests,
are working for Go 1.13 and previous versions.

When the server is started, if WOLFMUD_DIR is set, then the log should begin
with the lines:


  config.go:127: Server started, logging using UTC timezone.
  config.go:261: Found environment variable WOLFMUD_DIR=./data/config.wrj


As always, if you have any comments or feedback: diddymus@wolfmud.org

--
Diddymus

  [1] Go issue #21859 testing: DO NOT UNPIN panic in Init if flag.Parse has
      already been called https://github.com/golang/go/issues/31859

  [2] https://github.com/golang/go/commit/fbc6a972226f889d2ab1150468755615098ee80f


  Up to Main Index                           Up to Journal for October, 2019