fatih / Structtag
Licence: other
Parse and modify Go struct field tags
Stars: ✭ 405
Programming Languages
go
31211 projects - #10 most used programming language
Labels
Projects that are alternatives of or similar to Structtag
react-native-twitter-textview
A <TextView/> component for React Native built on top of twitter-text linkification.
Stars: ✭ 71 (-82.47%)
Mutual labels: tags
sic
link aggregator community organised by tags (with no javascript)
Stars: ✭ 82 (-79.75%)
Mutual labels: tags
guess-filename.py
Derive a file name according to old file name cues and/or PDF file content
Stars: ✭ 27 (-93.33%)
Mutual labels: tags
tag
Git utility to create tags in order to identify specific releases
Stars: ✭ 24 (-94.07%)
Mutual labels: tags
gatsby-simple-blog
an easily configurable gatsby-starter-blog with overreacted looking and tags, breadcrumbs, disqus, i18n, eslint, algolia supported
Stars: ✭ 48 (-88.15%)
Mutual labels: tags
audio-tag-analyzer
Extracts metadata music metadata found in audio files
Stars: ✭ 18 (-95.56%)
Mutual labels: tags
Terratag
Terratag is a CLI tool that enables users of Terraform to automatically create and maintain tags across their entire set of AWS, Azure, and GCP resources
Stars: ✭ 385 (-4.94%)
Mutual labels: tags
ShowMoreText
This is simple library for creating textview expandable. Like Continue or Less. This library extended versiion TextView. Easy to use.
Stars: ✭ 97 (-76.05%)
Mutual labels: tags
ebsautotagger
AWS Lambda function to tag EBS volumes created by autoscaling
Stars: ✭ 18 (-95.56%)
Mutual labels: tags
bibliothecula
document organizer with tags and full-text-search, in a simple and clean sqlite3 schema
Stars: ✭ 148 (-63.46%)
Mutual labels: tags
Id3
Library to read, modify and write ID3 & Lyrics3 tags in MP3 files. Provides an extensible framework for retrieving ID3 information from online services.
Stars: ✭ 27 (-93.33%)
Mutual labels: tags
Seo Helper
🔍 SEO Helper is a package that provides tools and helpers for SEO (Search Engine Optimization).
Stars: ✭ 262 (-35.31%)
Mutual labels: tags
Taggerkit
🏷 TaggerKit helps you to quickly implement tags in your UIKit apps, so you can go on and test your idea without having to worry about logic and custom collection layouts.
Stars: ✭ 390 (-3.7%)
Mutual labels: tags
Tfbubbleitup
Custom view for writing tags, contacts and etc. - written in Swift
Stars: ✭ 333 (-17.78%)
Mutual labels: tags
structtag
structtag provides a way of parsing and manipulating struct tag Go fields. It's used by tools like gomodifytags. For more examples, checkout the projects using structtag.
Install
go get github.com/fatih/structtag
Example
package main
import (
"fmt"
"reflect"
"sort"
"github.com/fatih/structtag"
)
func main() {
type t struct {
t string `json:"foo,omitempty,string" xml:"foo"`
}
// get field tag
tag := reflect.TypeOf(t{}).Field(0).Tag
// ... and start using structtag by parsing the tag
tags, err := structtag.Parse(string(tag))
if err != nil {
panic(err)
}
// iterate over all tags
for _, t := range tags.Tags() {
fmt.Printf("tag: %+v\n", t)
}
// get a single tag
jsonTag, err := tags.Get("json")
if err != nil {
panic(err)
}
fmt.Println(jsonTag) // Output: json:"foo,omitempty,string"
fmt.Println(jsonTag.Key) // Output: json
fmt.Println(jsonTag.Name) // Output: foo
fmt.Println(jsonTag.Options) // Output: [omitempty string]
// change existing tag
jsonTag.Name = "foo_bar"
jsonTag.Options = nil
tags.Set(jsonTag)
// add new tag
tags.Set(&structtag.Tag{
Key: "hcl",
Name: "foo",
Options: []string{"squash"},
})
// print the tags
fmt.Println(tags) // Output: json:"foo_bar" xml:"foo" hcl:"foo,squash"
// sort tags according to keys
sort.Sort(tags)
fmt.Println(tags) // Output: hcl:"foo,squash" json:"foo_bar" xml:"foo"
}
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].