.gofiles. A module is a collection of one or more packages with a
go.modfile specifying the module name, the required version of Go, and any dependencies.
go.sumfile. You should commit both
go.sumto your source control repository so your builds are repeatable.
go mod init. Running
go getwill scan your module's packages for dependencies and add these to your
go.sum, defaulting to current releases.
go.sumfiles with the new version. Optionally, you can run
go mod tidyto remove unused versions of any dependencies. Be sure to commit your
go.sumfiles to save the updated versions.
go buildin the root of the project to get a binary named
go buildthe two main packages into binaries with names that are not the same as the directory name (
lambda, respectively in this case).
cdinto the desired module and launch a
godocserver from there. Whenever reading the documentation, start a local
godocserver from your terminal.
go buildand to test a Go project, use
code/enginesdirectories with the following
test/hop(to run tests for Hop, for example).
enginesis separated into its own modules in order to reduce dependencies, keep build times short, and keep binaries small for production.
var, or declared and initialized with
:=most of the time. Use
varif the initial value of a variable is not important because it will be overwritten soon.
errors.New. Insert variable values into an error string with
(r record)before the method name is a "receiver." Note that
maketo pre-allocate memory for the new slice. You can also do this in the second function using
make(int, 0, len(x)+1).
range. This prevents subtle errors caused by relying on such an order, but can be disorienting the first time you see it. If you want your Hop models to execute deterministically, don't use a map to keep track of unmade decisions.
jsonannotation changes the name of the field in the output so it's
1m30s, 20 seconds is
20s, and 100 milliseconds is
launch.jsonfor Go of type
launch packageto be able to run/debug the solution from within Visual Studio Code and output the result in the Debug Console. Just copy the following json into your new
cmddirectory and click on the Play icon or hit