GO-vatar series: Collaboration with Postman collection
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 ItemGroup
” and ”Variable
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.
Working with Postman and Golang? Why not combine both? — MperMperPisang
Reference