Blog › Development

Structomap is back again

Structomap is back again

Hi everyone.

I've updated this library (https://github.com/devinterface/structomap) created long time ago because it solves a real problem in Go's webservices: to return different data as JSON response basing on arbitrary conditions.

For example, in a JSON response, I want to omit the user "password" field in all responses and maybe omit the field "balance" if the user is not an admin.

Using Golang tags on the struct is not enough, because I can only use the omitempty tag but not omit conditionally.

So the fastest way to avoid this problem is to convert a struct to a map and then render the map as JSON.

This library works well but it was unmaintained. So I've forked it and updated to be used with Golang 1.11 and 1.12 with modules support.

Now I've integrated it in 2 "echo" webservices and finally I am able to render JSON in a conditional way.

https://github.com/devinterface/structomap

Do you need Golang support for your next big project? Ask us a quotation!

We work also with Rails, Django, NodeJs/Express, React and Vue.

Find out where AI can save your company time.

One hour with our team: we map your processes, pick 2-3 concrete use cases and tell you what is worth doing first. No strings attached.

Book a free AI assessment
Subsidised finance

Incentives and grants for your software or AI project.

With specialised partners we check which incentives your project can access and prepare the paperwork and the financing plan.

  • Hyper-depreciation for 4.0 and 5.0 assets
  • National and regional grants
  • Financing plan
Book a free AI assessment