strcgo provides custom helpers to handle tasks related to struct
.
You can use the go get
method:
go get github.com/dalikewara/strcgo
You can check all available helper functions through the related files above (get.go
, etc).
For example, if you want to get tag value from a struct field, you can do like this:
type s struct {
ID uint64 `json:"id"`
Name string `json:"name"`
}
tagValue := strcgo.GetTagValueFromField(s{}, "Name", "json")
fmt.Println(tagValue) // output: name
Read at CHANGELOG.md
Copyright © 2024 Dali Kewara