force
force copied to clipboard
Add a way to pass parameters to functions that isn't a fixed argument order
Currently you can define functions in Force like ReleaseTeleportContainer := func(teleportVersion string, gitRepo string, os string, arch string) {}
This is good for small numbers of parameters but would quickly get messy with 5+ parameters needed for a function. Also, as Go doesn't support optional function parameters or overloading there isn't a simple way to make this tidier.
Maybe there could be a way to define a struct and then pass that to a function (very rough example):
TeleportReleaseArgs := struct(
// teleportVersion is the Teleport version to release
{Name: "teleportVersion", Type: String},
// gitRepo is the Git repo to use
{Name: "gitRepo", Type: String},
// os is the operating system to build for
{Name: "os", Type: String},
// arch is the architecture to build for
{Name: "arch", Type: String, default: "linux"},
// runtime is the runtime to build for
{Name: "runtime", Type: String, Optional: true},
)
ReleaseTeleportContainer := func(args TeleportReleaseArgs) {}
Key parts are:
- needs a way to define a default for a given parameter
- needs a way to make parameters optional
(there are possibly arguments for wanting to build/define some kind of custom type system for validation too, but I think to start with the standard Int
, String
and Bool
types would work)