Open suzuki-shunsuke opened 5 months ago
Jsonnet's function supports default argument.
https://jsonnet.org/learning/tutorial.html#functions
e.g.
// Default arguments are like Python: local my_function(x, y=10) = x + y;
https://pkg.go.dev/github.com/google/go-jsonnet@v0.20.0#NativeFunction
NativeFunction has a field Params, which a list of Identifier. Identifier represents a variable / parameter / field name. +gen set.
Params
https://pkg.go.dev/github.com/google/go-jsonnet@v0.20.0/ast#Identifier
I want to define a default argument, but is it possible?
I tried to add a default argument named opts, but it didn't work.
opts
Params: ast.Identifiers{"pattern", "s", "opts"},
If I omit the argument, the error RUNTIME ERROR: Missing argument: opts occurred.
RUNTIME ERROR: Missing argument: opts
I tried the following code, but it also didn't work. RUNTIME ERROR: Missing argument: opts={}
RUNTIME ERROR: Missing argument: opts={}
Params: ast.Identifiers{"pattern", "s", "opts={}"},
Jsonnet's function supports default argument.
https://jsonnet.org/learning/tutorial.html#functions
e.g.
https://pkg.go.dev/github.com/google/go-jsonnet@v0.20.0#NativeFunction
NativeFunction has a field
Params
, which a list of Identifier. Identifier represents a variable / parameter / field name. +gen set.https://pkg.go.dev/github.com/google/go-jsonnet@v0.20.0/ast#Identifier
I want to define a default argument, but is it possible?
I tried to add a default argument named
opts
, but it didn't work.If I omit the argument, the error
RUNTIME ERROR: Missing argument: opts
occurred.I tried the following code, but it also didn't work.
RUNTIME ERROR: Missing argument: opts={}