Work with Word Documents in Go (Golang)


Work with Word Documents in Go (Golang)

Powerful Go library for creating, editing and processing Word DOCX, DOC, RTF files. Open, generate, edit, split, merge, compare and convert Office Word documents using Golang library. Easily convert PDF to Word (DOC, DOCX, ODT, RTF and HTML) and in the opposite direction with Aspose Cloud Go library.

Table of Contents

About Go language

Go, also known as Golang, is a modern general-purpose programming language that is simple to learn, easy to read and convenient to use. Over the last few years, it has turned into one of the industry's favorite languages for building distributed systems, large-scale solutions and cloud-native services. Go is designed for professional programmers who want to build reliable and robust production software with high-level abstractions, ease of automation, complex event processing, runtime efficiency and perfect scalability.

Compared to many other languages that lack native support for multicore and multiprocessor computers, Go can be very efficient with its built-in concurrency and parallelism support. Lightweight computation threads called Goroutines together with Channels for communication between them, make it relatively easy for Go developers to write code that efficiently utilizes all available CPU cores, whereas the multiplexing of Goroutines onto OS threads is done automatically.

Other major Golang features include:

  • High-speed compilation.
  • Garbage collection support for safe memory management.
  • Stack management for memory optimization.
  • Static linking and clear dependency management. Developers don’t need to worry anymore about dependencies and library versions.
  • High-performance networking. The Golang environment comes with a powerful networking package in the standard library.

What is Cloud Go SDK

Words Cloud API is a modern REST API designed to control Word documents programmatically and incorporate a full-featured document processing functionality into distributed software solutions. It is not limited to the preparation of Word documents only, but also includes a wide range of advanced features.

When integrating with Words Cloud API, a developer has options to interact with it directly or use the SDK for a high-level mainstream language, like the Go package, which is a lightweight wrapper around Words Cloud API.

With the Go package you can put the inspirational Golang philosophy into practice by writing a lean and efficient document-processing code. There are at least four main reasons you should choose the Go SDK as the preferred means of developing your software. They are: simplicity, wide functionality, reliability and ease of automation.


Using Go you can efficiently utilize the Aspose Cloud API without the need to deal with low-level HTTP transactions. This helps to make fewer errors, find and correct them faster. But what is more important, it allows you to focus directly on the application's business logic. Also, it should be noted that Go has an easy-to-understand syntax, familiar to any developer with a C-language background.

Have a look at the Developer Guide detailing functions and features of Go SDK.

Wide Functionality

Go SDK assists in reading, editing, merging, splitting documents and converting to different formats. You can work with a complete set of Word document components, such as main text, sections, headers, footers, tables, drawing objects, fonts, hyperlinks, comments, watermarks, math objects and others.

For detailed information about the content of this SDK, including a description of new features, please see the GitHub Repository.

You can test the Cloud API functionality directly from your web browser with our online converter, viewer, editor, splitter, merger and other apps.


All Aspose Cloud SDKs are kept in sync with REST API endpoints as they are added or enhanced. Our team tests them thoroughly before deployment, therefore developers can be assured that Go SDK is reliable, fault-free and ready for production use.

Regardless of the programming language, you need to register within Words Cloud Services and obtain Client Id & Client Secret credentials before leveraging Cloud API. The Client Id-Secret pair is used to authenticate API requests and provide a secure way to transmit your data.

Ease of Automation

The preparation of documents has always been a tedious process, but with the help of Go Cloud SDK you can automate your document-related tasks with ease.

Our team is targetting to provide developers with high flexibility and performance. The architecture of Words Cloud API is very flexible, and it can be applied to all kinds of applications, independent of operating systems and programming languages.

You can automate your everyday documentation workflow tasks and increase overall business productivity by creating scalable, resilient and platform-independent applications.

  • Main
  • Convert
  • Structure
  • Content
  • Tables
  • MailMerge
  • Other
  • Plugins


Go 1.13 or higher

Supported Document Formats

You can both read and write documents in: DOCX, DOC, PDF, MD, RTF, DOCM, DOTX, DOT, DOTM, ODT, OTT, XML, HTML, MHTML, XHTML, TXT.
The write-only formats are: XPS, OpenXPS, PS, JPEG, PNG, BMP, SVG, TIFF, EMF, PCL, EPUB.
The read-only formats are: MOBI, CHM.
For more details, please check Supported File Formats.

Go Cloud SDK Installation

Here go step-by-step instructions:

  1. Download and install the Go compiler.
  2. Use “go get -v“ command to install Go Cloud SDK from GitHub repository.

Getting started with Go Cloud SDK

The following simple Golang code samples show how to integrate into Words Cloud Services and demonstrate the use of some basic API calls. Check the Developer's Guide for other usage scenarios.

Convert PDF to Word in Go

The following code sample shows how to convert PDF to DOCX in the Cloud and save the result to a local file:

Convert PDF to DOCX
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)

// Request a conversion of "sample.pdf" into "docx" format
document, _ := os.Open("sample.pdf")
response, _ := wordsApi.ConvertDocument(ctx, document, "docx", nil)
defer response.Body.Close()

// Save response in "sample.docx"
output, _ := os.Create("sample.docx")
defer output.Close()
io.Copy(output, response.Body)
	"AppKey": "##################",
	"AppSid": "####-####-####-####-####"

Advanced Features

How to open and edit a DOCX document in Go

  1. Install the latest version of Go library.
  2. Go to the Aspose Cloud Dashboard.
  3. Create a new Account to access all applications and services or Sign In to your existing account.
  4. Click on Applications in the left menu to get Client Id and Client Secret.
  5. Upload a DOCX file to the Cloud Storage or use directly in the request body.
  6. Check Developer Guide to edit a DOCX file in Go.

Support and Learning Resources