Go library to build highly customized reports using REST API
Start Free TrialGroupDocs.Assembly Cloud SDK for Go lets you embed powerful document‑generation capabilities into any Go application without the need for heavy third‑party libraries. The service is fully cloud‑based and communicates through a simple REST API, which means you only need an internet connection and your API credentials to start creating documents.
The typical workflow consists of three logical steps:
This approach enables generation of contracts, invoices, shipping manifests, sales proposals, and any other business‑critical document in real time. It also supports Mail Merge for batch creation of personalized letters, barcode generation, HTML background styling, and email attachment creation. All operations are secured with SSL/TLS encryption and API‑key authentication, ensuring that sensitive data never leaves the cloud unprotected.
Because the heavy lifting occurs in the cloud, the SDK works on every operating system that can run Go (Windows macOS, Linux) and requires only the standard go get
installation step. No additional software, no native Office installations, and no manual handling of complex file formats are needed – the cloud service abstracts all that complexity away, allowing you to focus on business logic.
The snippet below demonstrates how to upload a template, read a data source and call the Assembly API to produce a document using Go.
Steps
config.json
.AssembleOptions
with template path and desired output format.AssembleDocument
and receive the assembled file.import (
"os"
"io/ioutil"
"github.com/groupdocs-assembly-cloud/groupdocs-assembly-cloud-go/api"
"github.com/groupdocs-assembly-cloud/groupdocs-assembly-cloud-go/api/models"
)
// 1. Initialise configuration
config, _ := models.NewConfiguration("config.json")
assemblyApi, ctx, _ := api.NewAPIClient(config)
// 2. Upload template
fileName := "Input1.docx"
requestFileContent, _ := os.Open(fileName)
uploadReq := &models.UploadFileRequest{
FileContent: requestFileContent,
Path: ToStringPointer(fileName),
}
_, _, _ = assemblyApi.UploadFile(ctx, uploadReq)
// 3. Read data source
dataFile := "Input2.docx" // can be XML or JSON
data, _ := ioutil.ReadFile(dataFile)
// 4. Prepare assemble options
templateInfo := api.TemplateFileInfo{FilePath: fileName}
assembleOptions := api.AssembleOptions{
TemplateFileInfo: &templateInfo,
SaveFormat: "docx",
ReportData: string(data),
}
// 5. Generate document
output, err := assemblyApi.AssemblyApi.AssembleDocument(ctx, assembleOptions)
if err != nil {
// handle error
}
// `output` contains the generated document