Our powerful Go SDK allows you to find the difference between DOCX documents and save the results to a convenient format for viewing. To verify our product capabilities, compare DOCX files using this Go library and see the differences.
Our Go SDK is designed to give you the most accurate result, even though comparison is a complex function itself.
Sometimes you need to be sure that the document in the DOCX format has not been changed, and if it has, you need to find out what the difference is. Just use our Go diff tool to compare two DOCX files and find differences in whole words or single characters. Moreover, if only one character in a word has changed, this word will be marked as changed entirely.
Now you no longer need to spend time manually comparing DOCX documents, and you can quickly find even small changes and export such diffs to a document in a convenient format.
Check out how our solution to compare DOCX files using Go SDK works. To achieve this, load the DOCX files you want to compare and select the export file format – it will be automatically loaded after comparing.
Note that you need to accept all revisions in compared documents before calling the comparison method, as shown in our example:
import (
"os"
"github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models"
)
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)
fileName1:= "Input1.docx"
fileName2:= "Input2.docx"
fileResult:= "Output.docx"
// Upload documents to cloud storage.
firstDocumentContent, _ := os.Open(fileName1)
uploadFirstFileRequestOptions := map[string]interface{}{}
uploadFirstFileRequest := &models.UploadFileRequest{
FileContent: firstDocumentContent,
Path: ToStringPointer(fileName1),
Optionals: uploadFirstFileRequestOptions,
}
_, _, _ = wordsApi.UploadFile(ctx, uploadFirstFileRequest)
secondDocumentContent, _ := os.Open(fileName2)
uploadSecondFileRequestOptions := map[string]interface{}{}
uploadSecondFileRequest := &models.UploadFileRequest{
FileContent: secondDocumentContent,
Path: ToStringPointer(fileName2),
Optionals: uploadSecondFileRequestOptions,
}
_, _, _ = wordsApi.UploadFile(ctx, uploadSecondFileRequest)
// Compare documents in cloud.
compareDataOptions := models.CompareData{
Author: ToStringPointer("author"),
FileReference: models.CreateRemoteFileReference(fileName2),
}
compareDocumentRequestOptions := map[string]interface{}{"destFileName": fileResult,}
compareDocumentRequest := &models.CompareDocumentRequest{
Name: ToStringPointer(fileName1),
CompareData: &compareDataOptions,
Optionals: compareDocumentRequestOptions,
}
_, _, _ = wordsApi.CompareDocument(ctx, compareDocumentRequest)
// Download result document from cloud storage.
downloadFileRequestOptions := map[string]interface{}{}
downloadFileRequest := &models.DownloadFileRequest{
Path: ToStringPointer(fileResult),
Optionals: downloadFileRequestOptions,
}
_, _ = wordsApi.DownloadFile(ctx, downloadFileRequest)
Run go get -v github.com/aspose-words-cloud/aspose-words-cloud-go/2007/api to install Aspose.Words Cloud SDK for Go. You can get a lot of useful information about other installation methods from the "How to use SDK" section.
Clone Aspose.Words Cloud SDK for Go source code from GitHub and use it in your project. Please follow these Instructions to quickly get the necessary security credentials and access our REST API.
Refer to the Repository Documentation to see the details.
You can perform compare operation for other file formats: