GO-vatar series: Collaboration with Postman collection

Ferawati Hartanti Pratiwi
1 min readDec 7, 2020
https://image.freepik.com/free-vector/cheerful-postman-riding-bicycle_165429-402.jpg

Do you have a Postman collection? And often working with that?

Let’s illustrate how to combine Postman collection with Golang.

Postman Collection

Please use https://www.getpostman.com/collections/d164cacb143635aade85 as our collection and save it as postman_collection.json file.

The content will be like this.

Installation

go get github.com/rbretecher/go-postman-collection

Example

Read and parse

It will print crudcrud, GET & https://crudcrud.com/api/c5f5fac06b6c481e95caaaf5a2f57e42 as the result. We can take advantage of this for our automation API in Golang.

Create and save

It will generate a new postman_collection.json. The content will be like this.

Create auth and env

Auth can be added to a Request or an ItemGroupandVariable can be added to Collection, Item, ItemGroup and URL“ — https://github.com/rbretecher/go-postman-collection.

auth := postman.CreateAuth(postman.Basic, postman.CreateAuthParam("username", "password"))
env := postman.CreateVariable("env", "prod")

Full code.

The result will be like this.

--

--

Ferawati Hartanti Pratiwi

QA (Quality Ambassador) | mpermperpisang official Medium account