Go

Installation

CodeMaker AI Golang SDK can be added to Go module using go get command:

go get github.com/codemakerai/codemaker-sdk-go

Usage

Next in code instantiate API Client and pass the API Key:

c := client.NewClient(&client.Config{
     ApiKey: "<API_KEY>" 
})

To trigger the code generation process invoke the CreateProcess API:

process, err := cl.CreateProcess(&client.CreateProcessRequest{
    Process: client.Process{
       Mode:     client.ModeCode,
       Language: client.LanguageGo,
       Input: client.Input{
          Source: source,
       },
       Options: &client.Options{
          // optional code generation options
       },
    },
})

This will create a new code generation task. The return response contains a unique task id, which can be used for checking the task status and retrieving the generated output. The status of the task can be checked afterward using GetProcessStatus API.

status, err := cl.GetProcessStatus(&client.GetProcessStatusRequest{
    Id: process.Id,
})

Once the task will be COMPLETED the generated result can be retrieved using GetProcessOutput API.

output, err := cl.GetProcessOutput(&client.GetProcessOutputRequest{
    Id: process.Id,
})

Last updated