Giter Club home page Giter Club logo

sublime-gotags's Introduction

GoTags

GoTags is a Sublime Text plugin to append or remove tags for Golang struct.

Functionality includes:

  • Append JSON tag with snake cased field name or remove JSON tag
  • Append XML tag with snake cased field name or remove XML tag
  • Append Xorm tag with xorm field type or remove Xorm tag

Usage

By default via the keyboard shortcut: Super + Shift + G, Super + Shift + T on OSX or Ctrl + Shift + G, Ctrl + Shift + T on other platforms(or change it in ${packages}/User/Default (plantform).sublime-keymap). Then choice the action you want.

** Makesure lines type STRUCT_NAME struct{ are in select region. **

For example:

type Example struct {
    FieldOne int       ``         // int field
    FieldTwo string    `orig tag` // string field
    FieldThree time.Time // time field
}

Then select type Example struct { line (or this is current line) and type the shortcut, select action JSON: Append tags:

type Example struct {
	FieldOne	int	`json:"field_one"`         // int field
	FieldTwo	string	`orig tag json:"field_two"` // string field
	FieldThree	time.Time	`json:"field_three"` // time field
}

After save with gofmt:

type Example struct {
	FieldOne   int       `json:"field_one"`          // int field
	FieldTwo   string    `orig tag json:"field_two"` // string field
	FieldThree time.Time `json:"field_three"`        // time field
}

Idea from:

gotag: golang auto generate struct tag.

sublime-gotags's People

Contributors

howcrazy avatar jostyee avatar

Stargazers

 avatar  avatar Joe Scharf avatar Marten Klitzke avatar Simon avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

coccodrillo

sublime-gotags's Issues

The GoTags is not work

When i select the line type STRUCT_NAME struct{ and then type the shotcut, there is nothing happen in the editor. And the Status Bar tell me: Unable to find gotags.
My struct is like this:

type People struct{
    Name string
    Age int
}

Commands doesn't work in type blocks

The command does not work if the structure is in the type(...) block.

To work around this, I must move the structure out of the block, making it independent, fill it with tags through the command, and return the result back to the block.

type (
	Example struct { // Doesn't work here
		Hello string
		World uint
	}
	
	...
)

type Example struct { // Works fine
	Oh   bool   `json:"oh"`
	Hi   int    `json:"hi"`
	Mark string `json:"mark"`
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.