MUST use when writing Go scripts.
Place scripts in a folder. After writing, tell the user they can run:
wmill generate-metadata - Generate .script.yaml and .lock fileswmill sync push - Deploy to WindmillDo NOT run these commands yourself. Instead, inform the user that they should run them.
Use wmill resource-type list --schema to discover available resource types.
The file package must be inner and export a function called main:
package inner
func main(param1 string, param2 int) (map[string]interface{}, error) {
return map[string]interface{}{
"result": param1,
"count": param2,
}, nil
}
Important:
inner({return_type}, error)main (lowercase)The return type can be any Go type that can be serialized to JSON:
package inner
type Result struct {
Name string `json:"name"`
Count int `json:"count"`
}
func main(name string, count int) (Result, error) {
return Result{
Name: name,
Count: count,
}, nil
}
Return errors as the second return value:
package inner
import "errors"
func main(value int) (string, error) {
if value < 0 {
return "", errors.New("value must be positive")
}
return "success", nil
}