ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Go​Tags

by howcrazy ALL

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

Details

Installs

  • Total 8K
  • Win 6K
  • Mac 1K
  • Linux 508
May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30
Windows 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0
Mac 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
Linux 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

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.