# README
oracles-randomizer coding tips
- Names in Go are conventially lowerMixedCaps by default, but UpperMixedCaps is
semantically different: it "exports" the name so that external packages can
access it. This is necessary for the
Main()
function, which is called frommain.go
in the repository's root directory, and structs members which are being unmarshaled from YAML by theyaml
package. If any names beyond these are UpperMixedCaps, it's probably vestigial from when the randomizer was split into multiple Go packages (and should be corrected). - It's OK to
panic()
in unrecoverable situations where some part of the randomizer itself is incorrect, like if embedded YAML can't be loaded. For extrinsic situations like invalid user input (including input ROM), functions should returnerror
s instead, which theMain()
function should ultimately report and then exit gracefully. - Go lacks a ternary operator, so the randomizer defines a
ternary()
function to help make some code more concise. But this is not the same as a ternary operator, since arguments to functions are evaluated before passing them. Soternary(a < b, a, b)
will work as intended, butternary(len(a) < 2, a[1], a[2])
will panic if the condition isn't met.
If you're unfamiliar with Go as a language, https://golang.org/doc/effective_go.html is probably the best reference for most aspects of it. Other documents are available at https://golang.org/doc/.
# Functions
the program's entry point.