fatih / structs

Utilities for Go structs

Home Page:http://godoc.org/github.com/fatih/structs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get tag-value without omitempty

rogierlommers opened this issue · comments

Excellent package! One question though: I sometimes need to get the tag() from a struct value, but then without the "omitempty" part. Does it make sense to create a dedicated method for that? So instead of func (f *Field) Tag(key string) string to have something like func (f *Field) TagWithoutOmitEmpty(key string) string?

Hi @rogierlommers

Tags have their own syntax. I recommend you get them via Tag() and then use the structtag package that allows you to do anything with that struct tag: https://github.com/fatih/structtag Thanks!

👍 Didn't see that one :). Thanks!