Here you will find all the specification types defined by our Json Schemas, in Go.
Current status of features implemented in the SDK is listed in the table below:
Feature | Status |
---|---|
Parse workflow JSON and YAML definitions | ✔️ |
Programmatically build workflow definitions | 🚫 |
Validate workflow definitions (Schema) | ✔️ |
Validate workflow definitions (Integrity) | ✔️ |
Generate workflow diagram (SVG) | 🚫 |
Latest Releases | Conformance to spec version |
---|---|
v1.0.0 | v0.5 |
v2.0.1 | v0.6 |
v2.1.2 | v0.7 |
v2.4.1 | v0.8 |
Run the following command in the root of your Go's project:
$ go get github.com/serverlessworkflow/sdk-go/v2
Your go.mod
file should be updated to add a dependency from the Serverless Workflow specification.
To use the generated types, import the package in your go file like this:
import "github.com/serverlessworkflow/sdk-go/v2/model"
Then just reference the package in your Go file like myfunction := model.Function{}
.
Serverless Workflow Specification supports YAML and JSON files for Workflow definitions. To transform such files into a Go data structure, use:
package sw
import (
"github.com/serverlessworkflow/sdk-go/v2/model"
"github.com/serverlessworkflow/sdk-go/v2/parser"
)
func ParseWorkflow(filePath string) (*model.Workflow, error) {
workflow, err := parser.FromFile(filePath)
if err != nil {
return nil, err
}
return workflow, nil
}
The Workflow
structure then can be used in your application.
Join us at CNCF Slack, channel #serverless-workflow-sdk
and say hello 🙋.
This guide aims to guide newcomers to getting started with the project standards.
For this project we use basically the default configuration for most used IDEs. For the configurations below, make sure to properly configure your IDE:
- imports: goimports
This should be enough to get you started.
If you are unsure that your IDE is not correctly configured, you can run the lint checks:
make lint
If something goes wrong, the error will be printed, e.g.:
$ make lint
make addheaders
make fmt
./hack/go-lint.sh
util/floatstr/floatstr_test.go:19: File is not `goimports`-ed (goimports)
"k8s.io/apimachinery/pkg/util/yaml"
make: *** [lint] Error 1
Lint issues can be fixed with the --fix
flag, this command can be used:
make lint params=--fix
For IntelliJ you can find an example editorconfig
file here. To use it please visit
the Jetbrains documentation.
On MacOSX/darwin you might get this issue:
goimports: can't extract issues from gofmt diff output
To solve install the diffutils
package:
brew install diffutils