All Projects → alistanis → St

alistanis / St

Licence: mit
ST - Struct Tagger - Tags your structs so you don't have to, saving you development time and encoding/decoding sanity.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to St

Linessorter Xcode Extension
Xcode Extension that helps you keep your import statements and long code lists organized and uniform
Stars: ✭ 54 (-20.59%)
Mutual labels:  developer-tools
Logvac
Simple, lightweight, api-driven log aggregation service with realtime push capabilities and historical persistence.
Stars: ✭ 61 (-10.29%)
Mutual labels:  developer-tools
Jumbune
Jumbune, an open source BigData APM & Data Quality Management Platform for Data Clouds. Enterprise feature offering is available at http://jumbune.com. More details of open source offering are at,
Stars: ✭ 64 (-5.88%)
Mutual labels:  developer-tools
Http Prompt
An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie
Stars: ✭ 8,329 (+12148.53%)
Mutual labels:  developer-tools
Wago
Automate the actions you do after saving code.
Stars: ✭ 60 (-11.76%)
Mutual labels:  developer-tools
Trymodule
➰ It's never been easier to try nodejs modules!
Stars: ✭ 1,115 (+1539.71%)
Mutual labels:  developer-tools
Wwdc
The unofficial WWDC app for macOS
Stars: ✭ 8,137 (+11866.18%)
Mutual labels:  developer-tools
Toc
🚩 TOC, zero configuration table of content generator for Markdown files, create table of contents from any Markdown file with ease.
Stars: ✭ 66 (-2.94%)
Mutual labels:  developer-tools
Xxv
The XXV visual hex viewer for the terminal.
Stars: ✭ 61 (-10.29%)
Mutual labels:  developer-tools
Deb Dev Machine
Quickly install common Developer tools, IDE's & Services on Debian 9
Stars: ✭ 63 (-7.35%)
Mutual labels:  developer-tools
Dotfiles
🖥️ Automated Configuration, Preferences and Software Installation for macOS
Stars: ✭ 1,103 (+1522.06%)
Mutual labels:  developer-tools
Blindfold
🔎 Gitignore file generator written in rust
Stars: ✭ 60 (-11.76%)
Mutual labels:  developer-tools
Tables To Go
convert your database tables to structs easily
Stars: ✭ 62 (-8.82%)
Mutual labels:  developer-tools
Grpcc
A gRPC cli interface for easy testing against gRPC servers
Stars: ✭ 1,078 (+1485.29%)
Mutual labels:  developer-tools
Artemis Dev Tool
An Apollo GraphQL Query Schema Testing Tool
Stars: ✭ 66 (-2.94%)
Mutual labels:  developer-tools
Spm Agent Nodejs
NodeJS Monitoring Agent
Stars: ✭ 51 (-25%)
Mutual labels:  developer-tools
Git Notify
🙉 📣 Communicate important updates to your team via git commit messages
Stars: ✭ 1,091 (+1504.41%)
Mutual labels:  developer-tools
Psync
Synchronize project based on rsync; support watching changes and sync automatically
Stars: ✭ 68 (+0%)
Mutual labels:  developer-tools
Prequel
Prequel for Laravel. Clear and concise database management.
Stars: ✭ 1,141 (+1577.94%)
Mutual labels:  developer-tools
Whatthegem
Ruby gem information, stats and usage for your terminal
Stars: ✭ 63 (-7.35%)
Mutual labels:  developer-tools

ST - Struct Tagger for Go

st is a command line utility for tagging structs in your Go code.

Build Status Gitter

Get it: go get github.com/alistanis/st

If you want to run the tests, you'll need the goconvey package: go get github.com/smartystreets/goconvey

Roadmap

1. [-] Command Line Support
	* [x] Write tags to buffer(default behavior) and to file (with -w)
	* [x] Supports multiple operation modes
		* [x] Append
		* [x] Overwrite
		* [x] Skip existing tags
		* [x] Field Exclusion
		* [x] Struct Exclusion
		* [ ] Explicit Struct/field inclusion
		* [ ] Go Generate support
	  [ ] Fix whatever is wrong with the windows version
2. [ ] Web Application
	* [x] Basic static site handler (not in master)
	* [ ] Side by side input/output
	* [ ] Make it pretty  
3. [x] Tests/Build/Deploy
	* [x] Main Package tests
	* [x] Parse Package tests
	* [x] Flags package tests
	* [x] Travis Integration
		* [x] Run tests automatically 
		* [x] Build notifications
4. [x] Miscellaneous
	* [x] Gitter Integration
	* [x] Slack Channel

Usage

st -h or st --help

usage: st [flags] [path ...]
  -a	Sets mode to Append mode. Will Append to existing tags. Default behavior skips existing tags.
  -Append
    	Sets mode to Append mode. Will Append to existing tags. Default behavior skips existing tags.
  -c	Sets the struct tag to camel case.
  -camel
    	Sets the struct tag to camel case
  -i string
    	A comma separated list of fields to ignore. Will use the format json:"-".
  -ignored-fields string
    	A comma separated list of fields to ignore. Will use the format json:"-".
  -ignored-structs string
    	A comma separated list of structs to ignore. Will not tag any fields in the struct.
  -is string
    	A comma separated list of structs to ignore. Will not tag any fields in the struct.
  -o	Sets mode to overwrite mode. Will overwrite existing tags (completely). Default behavior skips existing tags.
  -overwrite
    	Sets mode to overwrite mode. Will overwrite existing tags (completely). Default behavior skips existing tags.
  -s	Sets the struct tag to snake case.
  -snake
    	Sets the struct tag to snake case.
  -t string
    	The struct tag to use when tagging. Example: -t=json  (default "json")
  -tag-name string
    	The struct tag to use when tagging. Example: --tag-name=json  (default "json")
  -v	Sets mode to verbose.
  -verbose
    	Sets mode to verbose.
  -w	Sets mode to write to source file. The default is a dry run that prints the results to stdout.
  -write
    	Sets mode to write to source file. The default is a dry run that prints the results to stdout.

Defaults

  • ST will not write to your source file unless you provide the -w or -write flags. Its default behavior prints the result to STDOUT
  • The default tag that ST uses is json
  • The default tagging mode is to Skip Existing Tags - you can change this behavior by providing one of the Append flags, -a or -Append, or by using one of the Overwrite flags, -o or -overwrite
  • The default tagging case is Snake Case - this can be changed by providing either Camel Case flag, -c or -camel

Overwrite mode will completely overwrite an existing tag. Append mode is a little trickier. If an existing tag is there for the tag that you have specified, let's use json as our example, it will leave that tag alone. If you specify a different tag, like msgpack, it will Append to the existing tag with the msgpack key/value.

Overwrite Examples

st --overwrite --tag-name=msgpack $GOFILE

type Test struct { F field `json:"f"`}
    becomes
type Test struct { F field `msgpack:"f"`}

st --overwrite --tag-name=json --case=camel $GOFILE

type Test struct { F field `json:"f"`}
    becomes
type Test struct { F field `json:"F"`}

Append Examples

st --Append --case=camel --tag-name=json $GOFILE

type Test struct { F field `json:"f"`}
    becomes (the tag is left alone because it is already there)
type Test struct { F field `json:"f"`}

st --Append --tag-name=msgpack $GOFILE

type Test struct { F field `json:"f"`}
    becomes
type Test struct { F field `msgpack:"f" json:"f"`}

Contributing & Contact

If you would like to contribute, don't be shy! Fork the project, write tests for any new code and ensure that you don't break existing functionality by running the current tests. If you're looking to submit changes upstream, it would be a good idea to discuss it with me first. I'm available via email, through Github, on the Gophers Slack ST Channel, or on Gitter.im.

If you do submit a pull request, I will review it and I will merge it if it's in line with my vision for the project.

Further examples

Contents of etc.go before running any of the following

package etc

type TestStruct struct {
	Int             int
	Int64           int64
	IntSlice        []int
	...
}

type TestStructWithTagsSnake struct {
	Int             int               `json:"int"`
	Int64           int64             `json:"int_64"`
	IntSlice        []int             `json:"int_slice"`
	...
}

type TestStructWithTagsCamel struct {
	Int             int               `json:"Int"`
	Int64           int64             `json:"Int64"`
	...
}

type TestUnexportedField struct {
	unexportedField int
	ExportedField   int
}

Append to existing tags with the tag msgpack (use -w flag to write to original source file)

st -s -a -v -t=msgpack $GOPATH/src/github.com/alistanis/st/etc/etc.go
package etc

type TestStruct struct {
	Int             int               `msgpack:"int"`
	Int64           int64             `msgpack:"int_64"`
	IntSlice        []int             `msgpack:"int_slice"`
	...
}

type TestStructWithTagsSnake struct {
	Int             int               `msgpack:"int" json:"int"`
	Int64           int64             `msgpack:"int_64" json:"int_64"`
	IntSlice        []int             `msgpack:"int_slice" json:"int_slice"`
	...
}

type TestStructWithTagsCamel struct {
	Int             int               `msgpack:"int" json:"Int"`
	Int64           int64             `msgpack:"int_64" json:"Int64"`
	IntSlice        []int             `msgpack:"int_slice" json:"IntSlice"`
	...
}

type TestUnexportedField struct {
	unexportedField int
	ExportedField   int `msgpack:"exported_field"`
}

Ignore a specific field (-i) and ignore a specific struct (-is)

st -s -a -v -i=ExportedField -is=TestStructWithTagsCamel -t=msgpack $GOPATH/src/github.com/alistanis/st/etc/etc.go
package etc

type TestStruct struct {
	Int             int               `msgpack:"int"`
	Int64           int64             `msgpack:"int_64"`
	IntSlice        []int             `msgpack:"int_slice"`
	...
}

type TestStructWithTagsSnake struct {
	Int             int               `msgpack:"int" json:"int"`
	Int64           int64             `msgpack:"int_64" json:"int_64"`
	IntSlice        []int             `msgpack:"int_slice" json:"int_slice"`
	...
}

type TestStructWithTagsCamel struct {
	Int             int               `json:"Int"`
	Int64           int64             `json:"Int64"`
	IntSlice        []int             `json:"IntSlice"`
	...
}

type TestUnexportedField struct {
	unexportedField int
	ExportedField   int `msgpack:"-"`
}
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].