pkg/util/util.go

15 lines
441 B
Go

// Package util provides common utility functions and helpers for various operations across the project.
package util
import (
"reflect"
"strings"
)
// GetTagName extracts the first comma-separated value from a struct field's tag.
// For example, given a tag `json:"name,omitempty"`, it returns "name".
func GetTagName(field reflect.StructField, tag string) string {
name := strings.SplitN(field.Tag.Get(tag), ",", 2)[0]
return name
}