import
— no go get
needed.
When you write Go code on Pipedream, you can share data between steps and access environment variables. However, you can’t connect accounts, return HTTP responses, or take advantage of other features available in the Node.js environment at this time.
If you have any feedback on the Go runtime, please let us know in our community.
golang
language runtime in language dropdownfmt.Println
at any time to log information as the script is running.
The output for the fmt.Println
Logs will appear in the Results
section just beneath the code editor.
fmt
package in order to run fmt.Println
.net/http
for making HTTP requestsencoding/json
for encoding and decoding JSONdatabase/sql
for reading and writing to SQL databasesimport
it in your step’s code:
/tmp
directory in an HTTP request:
pipedream-go
package.
In this example, we’ll pretend this data is coming into our HTTP trigger via POST request.
Steps
variable from the pd
package. Specifically, this data from the POST request into our workflow is available in the trigger
map.
pokemon
data is accessible to downstream steps within pd.Steps["code"]["pokemon"]
Steps
data shared between workflow steps.For the best experience, we recommend only exporting structs that can be marshalled into JSON.os
package.
GET
requestGET
requests to retrieve data from an API:
POST
requestos.Exit
to exit the main
function with a specific error code.
os.Exit
is called. In this example, the exit code 1
will appear in the Results of the step.
/tmp
directory is accessible from your workflow steps for saving and retrieving files.
You have full access to read and write both files in /tmp
.
/tmp
/tmp/go-logo.svg
holds the official Go logo.
/tmp
directory. Let’s open the go-logo.svg
file.
/tmp
limitations/tmp
directory can store up to of storage. Also the storage may be wiped or may not exist between workflow executions.
To avoid errors, assume that the /tmp
directory is empty between workflow runs.