The Go data source is one of the integration methods available on the Kuika platform that allows you to develop custom functions and business logic. Using Go, you can define custom operations within your application, create functions that accept parameters, and use these functions in application workflows.
With the Go data source, you can write custom code to address needs beyond the built-in actions, customize data processing workflows, and create reusable functions.
Add a Data Source Connection to Your App Using Go
Log in to the Kuika platform and open the project you’ll be working on from the Apps screen.
Click the Datasources icon on the top navigation bar.
On the Datasources main screen, click the Create a Function card and select the Go option under the Development category. You can also access the same list by clicking the + icon next to the Sources heading in the left panel.
Enter a name for your data source.
Click the CREATE button.
Anatomy of the Go Editor
After creating the data source, the Go editor opens.
A. Top Area
Back button (←): Allows you to exit the editor and return to the Datasources screen.
Data source name: The name of the data source (e.g., userguide) appears in the top-left corner. You can update the name using the pencil icon next to it.
CREATE button: Used to save the Go data source you’ve created.
B. Editor Toolbar
Undo / Redo: Undoes or redoes changes made.
Copy / Paste: Copies or pastes code into the editor.
Tidy Up: Used to format, align, and make the written code more readable.
Line wrapping and font size: Sets line wrapping for long lines and adjusts the editor’s font size.
External Libraries (BETA): Allows you to add external packages for use in your Go code.
Validation icon: Indicates whether the code is valid.
C. Go Editor
This is the code editing area; all custom functions are defined here. The editor opens with the following default example structure:
go
package main
funcGreet(name string)string {
return “Hello, ” + name
}
This structure demonstrates the following:
The code begins with the `package main` declaration.
Functions are defined using the `func` keyword.
Functions can take parameters, and the parameter type can be specified (e.g., `string`).
The return type is defined at the end of the function signature (e.g., `string`).
D. Kuika AI
You can generate Go code with AI assistance from the panel on the right side of the editor.
E. Test Console
The TEST CONSOLE area at the bottom of the screen is used to test the functions you’ve written. By expanding this area:
You can view the function list,
Enter parameter values,
And check the output.
Configuring Go Data Source Settings
Manual Code Writing
You can write your code directly in the editor. To use packages from the standard library, you must import them.
Example:
go
package main
import “strings”
funcToUpperCase(text string)string {
return strings.ToUpper(text)
}
Code Generation with Kuika AI
In the Type here field at the bottom of the Kuika AI panel on the right side of the editor, define the function you want to create.
Click the Send button.
Paste the code generated by Kuika AI into your editor.
Example command: Create a function that converts the entered text to uppercase.
Using External Libraries (BETA)
You can add packages outside the standard Go libraries to your data source by clicking the External Libraries button. This feature is currently in the BETA phase.
This function takes two numbers and returns their sum.
Specifying the Return Type
The data type to be returned must be defined at the end of the function signature. Example types:
string
int
float64
bool
interface{}
[]string (slice)
Testing Functions with the Test Console
After writing your code, you can use the TEST CONSOLE section below:
Expand the Test Console section.
Select the function you want to test.
Enter sample data into the parameter fields.
Run the function.
Check the returned result.
Example:
go
package main
funcHello(name string)string {
return “Hello ” + name
}
Parameter: Kuika Expected output: Hello Kuika
Saving the Data Source with CREATE
After completing and testing your code, you can save the Go data source by clicking the CREATE button in the upper right corner. The saved data source becomes available for use within the application.
Expected Output / Result
Once these steps are complete:
The Go data source is added to the Sources list.
The defined functions become available for use in the system.