Packages
Since the JS doesn’t have all the useful functions to perform operations like on file manipulation or http request (see otto docs for more info), driplane maps and export to the JS environment some Go functions as packages.
File
This package contains functions for manipulating files.
Return
The return value will be a JS object containing 2 fields:
| Name | Type | Description | 
|---|---|---|
| Status | BOOL | if true the operation was successful | 
| Error | STRING | if status is false it contains the reason of the failure | 
Functions
| Prototype | Description | 
|---|---|
| file.Move(src string, dest string) | Move the file srcto the new positiondest | 
| file.Copy(src string, dest string) | Copy the file srcto the positiondest | 
| file.Truncate(filename string, size int) | set or adjust the file called filenamebysizebytes | 
| file.Delete(filename string) | Remove the file called filename | 
| file.Exists(filename string) | Return Status = true if filenameexists on disk | 
| file.AppendString(filename string, text string) | Append the string textto the filefilename | 
Log
This package contains functions for writing strings on the logs.
Return
It doesn’t have a return value.
Functions
| Prototype | Description | 
|---|---|
| log.Info(format string, …) | Write an Info line on the log | 
| log.Error(src string, …) | Write an Error line on the log | 
| log.Debug(src string, …) | Write a Debug line on the log | 
Strings
This package contains functions for manipulating strings.
Return
The return value will be a JS object containing 2 fields:
| Name | Type | Description | 
|---|---|---|
| Status | BOOL | if true the operation was successful | 
| Error | STRING | if status is false it contains the reason of the failure | 
Functions
| Prototype | Description | 
|---|---|
| strings.StartsWith(str string, substr string) | Status = true if strstart withsubstr | 
Util
This package contains miscellaneous functions.
Return
The return value will be a JS object containing 2 fields:
| Name | Type | Description | 
|---|---|---|
| Status | BOOL | if true the operation was successful | 
| Error | STRING | if status is false it contains the reason of the failure | 
| Value | STRING | this string contains the returned value | 
Functions
| Prototype | Description | 
|---|---|
| util.Sleep(seconds int) | wait for secondsseconds | 
| util.Getenv(name string) | get the value of the nameenvironment variables, if it exists, and return it on theValuefield of the returned value | 
| util.Md5File(filename string) | calculate the MD5 hash of the filenameand return it on theValuefield | 
| util.Sha1File(filename string) | calculate the SHA1 hash of the filenameand return it on theValuefield | 
| util.Sha256File(filename string) | calculate the SHA256 hash of the filenameand return it on theValuefield | 
| util.Sha512File(filename string) | calculate the SHA512 hash of the filenameand return it on theValuefield | 
Http
This package contains functions to perform HTTP requests.
Return
The return value will be a JS object containing 4 fields:
| Name | Type | Description | 
|---|---|---|
| Status | BOOL | if true the operation was successful | 
| Error | STRING | if status is false it contains the reason of the failure | 
| Response | OBJECT | it returns the http.Response object | 
| Body | STRING | it contains the body of the response converted in string | 
Functions
| Prototype | Description | 
|---|---|
| http.Request(method string, uri string, headers interface{}, data interface{}) | |
| http.Get(url string, headers map[string]string) | |
| http.Post(url string, headers map[string]string, data interface{}) | |
| http.DownloadFile(filepath string, method string, uri string, headers interface{}, data interface{}) | |
| http.UploadFile(filename string, fieldname string, method string, uri string, headers interface{}, data interface{}) | 
Cache
This package contains functions for add and get values from the global cache.
Return
The return value will be a JS object containing the following fields:
| Name | Type | Description | 
|---|---|---|
| Status | BOOL | if true the operation was successful | 
| Error | STRING | if status is false it contains the reason of the failure | 
| Value | STRING | if status is true it contains the resulting value | 
Functions
| Prototype | Description | 
|---|---|
| cache.Put(key string, value string, ttl int64) | add the valuein the cache using the keykeyand it will be deleted afterttlseconds | 
| cache.Get(key string) | get the value stored in the cache with the key key |