Go tool to modify struct field tags

gomodifytags

Go tool to modify/update field tags in structs. gomodifytags makes it easy to update, add or delete the tags in a struct field. You can easily add new tags, update existing tags (such as appending a new key, i.e: db, xml, etc..) or remove existing tags. It also allows you to add and remove tag options. It's intended to be used by an editor, but also has modes to run it from the terminal. Read the usage section below for more information.

gomodifytags

Install

go get github.com/fatih/gomodifytags

Supported editors

  • vim-go with :GoAddTags and :GoRemoveTags
  • go-plus (atom) with commands golang:add-tags and golang:remove-tags
  • vscode-go with commands Go: Add Tags and Go: Remove Tags
  • A (Acme) with commands addtags and rmtags
  • emacs-go-tag with commands go-tag-add and go-tag-remove

Usage

gomodifytags has multiple ways to modify a tag. Let's start with an example package:

package main

type Server struct {
	Name        string
	Port        int
	EnableLogs  bool
	BaseDomain  string
	Credentials struct {
		Username string
		Password string
	}
}

We have to first pass a file. For that we can use the -file flag:

$ gomodifytags -file demo.go
-line, -offset, -struct or -all is not passed

What are these? There are four different ways of defining which field tags to change:

  • -struct: This accepts the struct name. i.e: -struct Server. The name should be a valid type name. The -struct flag selects the whole struct, and thus it will operate on all fields.
  • -field: This accepts a field name. i.e: -field Address. Useful to select a certain field. The name should be a valid field name. The -struct flag is required.
  • -offset: This accepts a byte offset of the file. Useful for editors to pass the position under the cursor. i.e: -offset 548. The offset has to be inside a valid struct. The -offset selects the whole struct. If you need more granular option see -line
  • -line: This accepts a string that defines the line or lines of which fields should be changed. I.e: -line 4 or -line 5,8
  • -all: This is a boolean. The -all flag selects all structs of the given file.

Let's continue by using the -struct tag:

$ gomodifytags -file demo.go -struct Server
one of [-add-tags, -add-options, -remove-tags, -remove-options, -clear-tags, -clear-options] should be defined

Adding tags & options

There are many options on how you can change the struct. Let us start by adding tags. The following will add the json key to all fields. The value will be automatically inherited from the field name and transformed to snake_case:

$ gomodifytags -file demo.go -struct Server -add-tags json
package main

type Server struct {
	Name        string `json:"name"`
	Port        int    `json:"port"`
	EnableLogs  bool   `json:"enable_logs"`
	BaseDomain  string `json:"base_domain"`
	Credentials struct {
		Username string `json:"username"`
		Password string `json:"password"`
	} `json:"credentials"`
}

By default every change will be printed to stdout. So it's safe to run it and see the results of it. If you want to change it permanently, pass the -w (write) flag.

$ gomodifytags -file demo.go -struct Server -add-tags json -w

You can pass multiple keys to add tags. The following will add json and xml keys:

$ gomodifytags -file demo.go -struct Server -add-tags json,xml
package main

type Server struct {
	Name        string `json:"name" xml:"name"`
	Port        int    `json:"port" xml:"port"`
	EnableLogs  bool   `json:"enable_logs" xml:"enable_logs"`
	BaseDomain  string `json:"base_domain" xml:"base_domain"`
	Credentials struct {
		Username string `json:"username" xml:"username"`
		Password string `json:"password" xml:"password"`
	} `json:"credentials" xml:"credentials"`
}

If you prefer to use camelCase instead of snake_case for the values, you can use the -transform flag to define a different transformation rule. The following example uses the camelcase transformation rule:

$ gomodifytags -file demo.go -struct Server -add-tags json,xml -transform camelcase
package main

type Server struct {
	Name        string `json:"name" xml:"name"`
	Port        int    `json:"port" xml:"port"`
	EnableLogs  bool   `json:"enableLogs" xml:"enableLogs"`
	BaseDomain  string `json:"baseDomain" xml:"baseDomain"`
	Credentials struct {
		Username string `json:"username" xml:"username"`
		Password string `json:"password" xml:"password"`
	} `json:"credentials" xml:"credentials"`
}

Formatting tag values

By default a struct tag's value is transformed from a struct's field and used directly. As an example for the field Server string, we generate a tag in the form: json:"server" (assuming -add-tags=json is used).

However, some third party libraries use tags in a different way and might require to them to have a particular formatting, such as is the case of prefixing them (field_name=). The --template flag allows you to specify a custom format for the tag value to be applied.

$ gomodifytags -file demo.go -struct Server -add-tags gaum -template "field_name=$field" 
package main

type Server struct {
	Name        string `gaum:"field_name=name"`
	Port        int    `gaum:"field_name=port"`
	EnableLogs  bool   `gaum:"field_name=enableLogs"`
	BaseDomain  string `gaum:"field_name=baseDomain"`
}

The $field is a special keyword that is replaced by the struct tag's value after the transformation.

Transformations

We currently support the following transformations:

  • snakecase: "BaseDomain" -> "base_domain"
  • camelcase: "BaseDomain" -> "baseDomain"
  • lispcase: "BaseDomain" -> "base-domain"
  • pascalcase: "BaseDomain" -> "BaseDomain"
  • keep: keeps the original field name

You can also pass a static value for each fields. This is useful if you use Go packages that validates the struct fields or extract values for certain operations. The following example adds the json key, a validate key with the value set to gt=1 and the scope key with the value read-only:

$ gomodifytags -file demo.go -struct Server -add-tags json,validate:gt=1,scope:read-only
package main

type Server struct {
	Name        string `json:"name" validate:"gt=1" scope:"read-only"`
	Port        int    `json:"port" validate:"gt=1" scope:"read-only"`
	EnableLogs  bool   `json:"enable_logs" validate:"gt=1" scope:"read-only"`
	BaseDomain  string `json:"base_domain" validate:"gt=1" scope:"read-only"`
	Credentials struct {
		Username string `json:"username" validate:"gt=1" scope:"read-only"`
		Password string `json:"password" validate:"gt=1" scope:"read-only"`
	} `json:"credentials" validate:"gt=1" scope:"read-only"`
}

To add options to for a given key, we use the -add-options flag. In the example below we're going to add the json key and the omitempty option to all json keys:

$ gomodifytags -file demo.go -struct Server -add-tags json -add-options json=omitempty
package main

type Server struct {
	Name        string `json:"name,omitempty"`
	Port        int    `json:"port,omitempty"`
	EnableLogs  bool   `json:"enable_logs,omitempty"`
	BaseDomain  string `json:"base_domain,omitempty"`
	Credentials struct {
		Username string `json:"username,omitempty"`
		Password string `json:"password,omitempty"`
	} `json:"credentials,omitempty"`
}

If the key already exists you don't have to use -add-tags

Skipping unexported fields

By default all fields are processed. This main reason for this is to allow structs to evolve with time and be ready in case a field is exported in the future. However if you don't like this behavior, you can skip it by passing the --skip-unexported flag:

$ gomodifytags -file demo.go -struct Server -add-tags json --skip-unexported
package main

type Server struct {
        Name       string `json:"name"`
        Port       int    `json:"port"`
        enableLogs bool
        baseDomain string
}

Removing tags & options

Let's continue with removing tags. We're going to use the following simple package:

package main

type Server struct {
	Name        string `json:"name,omitempty" xml:"name,attr,cdata"`
	Port        int    `json:"port,omitempty" xml:"port,attr,cdata"`
	EnableLogs  bool   `json:"enable_logs,omitempty" xml:"enable_logs,attr,cdata"`
	BaseDomain  string `json:"base_domain,omitempty" xml:"base_domain,attr,cdata"`
	Credentials struct {
		Username string `json:"username,omitempty" xml:"username,attr,cdata"`
		Password string `json:"password,omitempty" xml:"password,attr,cdata"`
	} `json:"credentials,omitempty" xml:"credentials,attr,cdata"`
}

To remove the xml tags, we're going to use the -remove-tags flag:

$ gomodifytags -file demo.go -struct Server -remove-tags xml
package main

type Server struct {
	Name        string `json:"name"`
	Port        int    `json:"port"`
	EnableLogs  bool   `json:"enable_logs"`
	BaseDomain  string `json:"base_domain"`
	Credentials struct {
		Username string `json:"username"`
		Password string `json:"password"`
	} `json:"credentials"`
}

You can also remove multiple tags. The example below removs json and xml:

$ gomodifytags -file demo.go -struct Server -remove-tags json,xml
package main

type Server struct {
	Name        string
	Port        int
	EnableLogs  bool
	BaseDomain  string
	Credentials struct {
		Username string
		Password string
	}
}

If you want to remove all keys, we can also use the -clear-tags flag. This flag removes all tags and doesn't require to explicitly pass the key names:

$ gomodifytags -file demo.go -struct Server -clear-tags
package main

type Server struct {
	Name        string
	Port        int
	EnableLogs  bool
	BaseDomain  string
	Credentials struct {
		Username string
		Password string
	}
}

To remove any option, we can use the -remove-options flag. The following will remove all omitempty flags from the json key:

$ gomodifytags -file demo.go -struct Server -remove-options json=omitempty
package main

type Server struct {
	Name        string `json:"name" xml:"name,attr,cdata"`
	Port        int    `json:"port" xml:"port,attr,cdata"`
	EnableLogs  bool   `json:"enable_logs" xml:"enable_logs,attr,cdata"`
	BaseDomain  string `json:"base_domain" xml:"base_domain,attr,cdata"`
	Credentials struct {
		Username string `json:"username" xml:"username,attr,cdata"`
		Password string `json:"password" xml:"password,attr,cdata"`
	} `json:"credentials" xml:"credentials,attr,cdata"`
}

To remove multiple options from multiple tags just add another options:

$ gomodifytags -file demo.go -struct Server -remove-options json=omitempty,xml=cdata
package main

type Server struct {
	Name        string `json:"name" xml:"name,attr"`
	Port        int    `json:"port" xml:"port,attr"`
	EnableLogs  bool   `json:"enable_logs" xml:"enable_logs,attr"`
	BaseDomain  string `json:"base_domain" xml:"base_domain,attr"`
	Credentials struct {
		Username string `json:"username" xml:"username,attr"`
		Password string `json:"password" xml:"password,attr"`
	} `json:"credentials" xml:"credentials,attr"`
}

Lastly, to remove all options without explicitly defining the keys and names, we can use the -clear-options flag. The following example will remove all options for the given struct:

$ gomodifytags -file demo.go -struct Server -clear-options
package main

type Server struct {
	Name        string `json:"name" xml:"name"`
	Port        int    `json:"port" xml:"port"`
	EnableLogs  bool   `json:"enable_logs" xml:"enable_logs"`
	BaseDomain  string `json:"base_domain" xml:"base_domain"`
	Credentials struct {
		Username string `json:"username" xml:"username"`
		Password string `json:"password" xml:"password"`
	} `json:"credentials" xml:"credentials"`
}

Line based modification

So far all examples used the -struct flag. However we also can pass the line numbers to only change certain files. Suppose we only want to remove the tags for the Credentials struct (including the fields) for the following code (lines are included):

01  package main
02  
03  type Server struct {
04  	Name        string `json:"name" xml:"name"`
05  	Port        int    `json:"port" xml:"port"`
06  	EnableLogs  bool   `json:"enable_logs" xml:"enable_logs"`
07  	BaseDomain  string `json:"base_domain" xml:"base_domain"`
08  	Credentials struct {
09  		Username string `json:"username" xml:"username"`
10  		Password string `json:"password" xml:"password"`
11  	} `json:"credentials" xml:"credentials"`
12  }

To remove the tags for the credentials we're going to pass the -line flag:

$ gomodifytags -file demo.go -line 8,11 -clear-tags xml
package main

type Server struct {
	Name        string `json:"name" xml:"name"`
	Port        int    `json:"port" xml:"port"`
	EnableLogs  bool   `json:"enable_logs" xml:"enable_logs"`
	BaseDomain  string `json:"base_domain" xml:"base_domain"`
	Credentials struct {
		Username string
		Password string
	}
}

For removing the xml tags for certain lines, we can use the -remove-tags field. The following example will remove the xml tags for the lines 6 and 7 (fields with names of EnableLogs and BaseDomain):

$ gomodifytags -file demo.go -line 6,7 -remove-tags xml
package main

type Server struct {
	Name        string `json:"name" xml:"name"`
	Port        int    `json:"port" xml:"port"`
	EnableLogs  bool   `json:"enable_logs"`
	BaseDomain  string `json:"base_domain"`
	Credentials struct {
		Username string `json:"username" xml:"username"`
		Password string `json:"password" xml:"password"`
	} `json:"credentials" xml:"credentials"`
}

The same logic applies to adding tags or any other option as well. To add the bson tag to the lines between 5 and 7, we can use the following example:

$ gomodifytags -file demo.go -line 5,7 -add-tags bson
package main

type Server struct {
	Name        string `json:"name" xml:"name"`
	Port        int    `json:"port" xml:"port" bson:"port"`
	EnableLogs  bool   `json:"enable_logs" xml:"enable_logs" bson:"enable_logs"`
	BaseDomain  string `json:"base_domain" xml:"base_domain" bson:"base_domain"`
	Credentials struct {
		Username string `json:"username" xml:"username"`
		Password string `json:"password" xml:"password"`
	} `json:"credentials" xml:"credentials"`
}

Editor integration

Editors can use the tool by calling the tool and then either replace the buffer with the stdout or use the -w flag.

Also -line and -offset flags should be preferred to be used with editors. An editor can select a range of lines and then pass it to -line flag. The editor also can pass the offset under the cursor if it's inside the struct to -offset

Editors also can use the -format flag to output a json output with the changed lines. This is useful if you want to explicitly replace the buffer with the given lines. For the file below:

package main

type Server struct {
	Name        string
	Port        int
	EnableLogs  bool
	BaseDomain  string
	Credentials struct {
		Username string
		Password string
	}
}

If we add the xml tag and tell to output the format in json with the -format flag, the following will be printed:

$ gomodifytags -file demo.go -struct Server -add-tags xml -format json
{
  "start": 3,
  "end": 12,
  "lines": [
    "type Server struct {",
    "\tName        string `xml:\"name\"`",
    "\tPort        int    `xml:\"port\"`",
    "\tEnableLogs  bool   `xml:\"enable_logs\"`",
    "\tBaseDomain  string `xml:\"base_domain\"`",
    "\tCredentials struct {",
    "\t\tUsername string `xml:\"username\"`",
    "\t\tPassword string `xml:\"password\"`",
    "\t} `xml:\"credentials\"`",
    "}"
  ]
}

The output is defined with the following Go struct:

type output struct {
	Start int      `json:"start"`
	End   int      `json:"end"`
	Lines []string `json:"lines"`
}

The start and end specifies the positions in the file the lines will apply. With this information, you can replace the editor buffer by iterating over the lines and set it for the given range. An example how it's done in vim-go in Vimscript is:

let index = 0
for line_number in range(start, end)
  call setline(line_number, lines[index])
  let index += 1
endfor

Unsaved files

Editors can supply gomodifytags with the contents of unsaved buffers by using the -modified flag and writing an archive to stdin. Files in the archive will be preferred over those on disk.

Each archive entry consists of:

  • the file name, followed by a newline
  • the (decimal) file size, followed by a newline
  • the contents of the file

Development

At least Go v1.11.x is required. Older versions might work, but it's not recommended.

gomodifytags uses Go modules for dependency management. This means that you don't have to go get it into a GOPATH anymore. Checkout the repository:

git clone https://github.com/fatih/gomodifytags.git

Start developing the code. To build a binary, execute:

GO111MODULE=on go build -mod=vendor

This will create a gomodifytags binary in the current directory. To test the package, run the following:

GO111MODULE=on go test -v -mod=vendor

If everything works fine, feel free to open a pull request with your changes.

Owner
Fatih Arslan
Software Engineer. Gopher and Coffee geek. Creator of vim-go. Tool maker.
Fatih Arslan
Comments
  • Cannot modify tags: invalid line directive found

    Cannot modify tags: invalid line directive found

    Committer: GitHub [email protected] 2019-07-16 15:06:38 is normal.

    Committer: Fatih Arslan [email protected] 2019-08-12 17:45:01 prompt:

    Cannot modify tags: invalid line directive found

    type BillStatQuery struct {
    	BuildingId string
    	SearchKey  string
    	Floor      int
    	RoomId     string
    }
    
  • Wrong output when the file isn't gofmt'd

    Wrong output when the file isn't gofmt'd

    With the following file:

    $ cat tags.go
    package a
    type x struct {
        Foo int
        bar int
    }
    

    The tool gives the wrong results.

    Should be start=2:

    $ gomodifytags -format json -file tags.go -transform snakecase -line 3,4 -add-tags json -add-options json=
    {
      "start": 3,
      "end": 4,
      "lines": [
        "type x struct {",
        "\tFoo int `json:\"foo\"`"
      ]
    }
    

    Should be start=2, and one line is missing from the output:

    $ gomodifytags -format json -file tags.go -transform snakecase -line 3,3 -add-tags json -add-options json=
    {
      "start": 3,
      "end": 3,
      "lines": [
        "type x struct {"
      ]
    }
    

    start is correct, but the last line (}) missing:

    $ gomodifytags -format json -file tags.go -transform snakecase -offset 23 -add-tags json -add-options json=
    {
      "start": 2,
      "end": 5,
      "lines": [
        "",
        "type x struct {",
        "\tFoo int `json:\"foo\"`",
        "\tbar int `json:\"bar\"`"
      ]
    }
    

    It seems that the tool operates on the file as if they're gofmt'd.

  • Formatting tag values $field not generated

    Formatting tag values $field not generated

    I'm trying to generate with formatting tag values with -template. And I got null $field.

    script executed:

    gomodifytags -file purchase.go -all -add-tags gorm --template "column:$field" -w
    

    result:

    type PurchaseModel struct {
            BaseField         `json:",inline" gorm:"column:"`
            Code              string `json:"code,omitempty" gorm:"column:"`
            RefOrderId        string `json:"ref_order_id,omitempty" gorm:"column:"`
            Date              string `json:"date,omitempty" gorm:"column:"`
            Status            string `json:"status,omitempty" gorm:"column:"`
            PaymentStatus     string `json:"payment_status,omitempty" gorm:"column:"`
            InvoiceNumber     string `json:"invoice_number,omitempty" gorm:"column:"`
            InvoiceDate       string `json:"invoice_date,omitempty" gorm:"column:"`
            InvoiceDueDate    string `json:"invoice_due_date,omitempty" gorm:"column:"`
            InvoiceTotalPrice string `json:"invoice_total_price,omitempty" gorm:"column:"`
    }
    

    result gorm:"column:" should be gorm:"column:code"

    please help, Thanks

  • New Add/Remove prefix option

    New Add/Remove prefix option

    Some libraries like the gorm ORM or the gaum SQL query builder use a prefix in the tag name (ie gorm:"column:struct_field", gaum:"field_name=struct_field") to help ther Scanner/Valuer interact with the sql library in go. This PR adds the ability to add and remove said prefixes. I used these two libraries as samples in the tests files to help understand the rationale behind said feature to people reading without context, hopefully this doesn't break any project convention.

  • anonymous structs?

    anonymous structs?

    Is there support for anonymous structs? gomodifytags doesn't seem to work on anonymous structs.

    Here's an example:

    Running gomodifytags -file main.go -line 7,9 -add-tags json returns selection is not inside a struct

    package main
    
    import "fmt"
    
    func main() {
    	anon := []struct {
    		ID int
    		A  string
    		B  string
    	}{}
    
    	fmt.Println(anon)
    }
    
  • Different tags use different transforms

    Different tags use different transforms

    A tag on a struct uses the same transforms, and I want to use separate transforms for each tag.

    AppDeploymentServerModuleConfig struct {
    		ID                    int    `json:"id" gorm:"id"`
    		AppDeploymentConfigID int    `json:"appDeploymentConfigID" gorm:"app_deployment_config_id"`
    
    }
    

    json use camelcase transforms, gorm use snakecase transforms

  • Embedded struct can not be used with -transform camelcase

    Embedded struct can not be used with -transform camelcase

    type PDetail struct {
    	PSummary //will cause problem
    	Thumbnail             string `json:"thumbnail"`
    }
    
     W
    panic: runtime error: index out of range
    
    goroutine 1 [running]:
    main.(*config).addTags(0xc4200a4200, 0x0, 0x0, 0xc4200e74e0, 0x0, 0x100eda8, 0x20)
            /Users/ / /go/src/github.com/fatih/gomodifytags/main.go:351 +0x8a5
    
  • Add

    Add "Title Case" option

    This is just a continue from this PR, anant-barlota seems to be inactive. Addressing https://github.com/fatih/gomodifytags/pull/66#discussion_r460717316 and fixed conflicts issue #65

  • Adding Title Case to the list of supported cases

    Adding Title Case to the list of supported cases

    Hi, I was wondering if we could add an additional option of 'Title Case'. I came across its usefulness while adding csv tags to my structs.

    I've written a simple code fix for it, but I'm unable to push the branch to this repo. I would appreciate any feedback on this.

  • Unexported embedded struct with skip-unexported option is still tagged

    Unexported embedded struct with skip-unexported option is still tagged

    Input:

    type stationEvent struct{}
    
    type StationConnectorUnplugged struct {
    	stationEvent
    	ConnectorID    int
    	MeterStop      int
    	TransactionID  int32
    	ChargingCardID identifier.ChargingCardID
    	Timestamp      time.Time `json:"timestamp`
    }
    

    Output:

    type stationEvent struct{}
    
    type StationConnectorUnplugged struct {
            stationEvent   `json:"stationEvent"`
            ConnectorID    int                       `json:"connectorID"`
            MeterStop      int                       `json:"meterStop"`
            TransactionID  int32                     `json:"transactionID"`
            ChargingCardID identifier.ChargingCardID `json:"chargingCardID"`
            Timestamp      time.Time                 `json:"timestamp`
    }
    

    Expected:

    type stationEvent struct{}
    
    type StationConnectorUnplugged struct {
            stationEvent
            ConnectorID    int                       `json:"connectorID"`
            MeterStop      int                       `json:"meterStop"`
            TransactionID  int32                     `json:"transactionID"`
            ChargingCardID identifier.ChargingCardID `json:"chargingCardID"`
            Timestamp      time.Time                 `json:"timestamp`
    }
    
  • Add new

    Add new "skip-private" option

    Really we never need JSON tags for private fields So this is such an option

    For example you may have following struct

    type Struct struct {
        Public  int
        private int
    }
    

    Currently gomodifytags would add these tags

    type Struct struct {
        Public  int `json:"public"`
        private int `json:"private"`
    }
    

    With new option it would add

    type Struct struct {
        Public  int `json:"public"`
        private int
    }
    
  • Don't double up underscores with -transform=snakecase

    Don't double up underscores with -transform=snakecase

    It would treat an existing underscore as a "word", so one underscore got transformed in to 3.

    I run in to this semi-regularly when I copy something like a database schema to a struct:

    type Sequence struct {
    	sequence_id  int64
    	server_id    int32
    	data_type    string
    	increment_by int64
    	cache_size   int64
    }
    

    And this gets transformed to:

    type Sequence struct {
    	sequence_id  int64 `db:"sequence___id"`
    	server_id    int32 `db:"server___id"`
    	data_type    string `db:"data___type"`
    	increment_by int64  `db:"increment___by"`
    	cache_size   int64  `db:"cache___size"`
    }
    

    I could fix up the field names first, which needs to be done anyway, or use -transform keep, but this makes it do the right thing with the defaults with a minimal of friction, and I don't expect it to break anything for anyone.

  • Add -transform lowercase

    Add -transform lowercase

    background: I got some error while doing scanny.pgxscan.Select because the column is not there

    without the struct tag db:"createdat" (actually it was CreatedAt on the struct) it shows error scanning all: scanning: scanning: doing scan: scanFn: scany: column: createdat

    and gomodifytags only allow PascalCase or snake_case (only these two that most similar), where what i need is lowercase.

  • Override flag defaults with a config file

    Override flag defaults with a config file

    I'd like to have the ability to change the defaults of the executable, e.g. to make the default transformation be camelCase instead of snake_case.

    My proposal would be to introduce a config file (e.g. ~/.config/gomodifytags/config) where you could override default flag values.

  • Unable to install gomodifytags tool on VS Code

    Unable to install gomodifytags tool on VS Code

    I have been unable to download and install the gomodifytags package automatically via the install all option and when I attempt to do it manually via the go install github.com/fatih/gomodifytags@latest command, I get the following as feedback:

    # github.com/fatih/gomodifytags
    C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: C:\Users\IAN\AppData\Local\go-build\7e\7ead9b6fbf2293b80b2d0531d108001d1e31a4fd463224b9b481fc70392a1baa-d: not package main
    

    How can I resolve this challenge?

  • Extract gomodifytags into a library

    Extract gomodifytags into a library

    This PR moves the gomodifytags tool into its package to be imported by other applications (i.e.: gopls). It's currently deliberately put under internal, as I want to make sure it meets the needs of others.

    related: https://github.com/golang/vscode-go/issues/2002

  • Unable to add static tag value with comma.

    Unable to add static tag value with comma.

    Is it somehow possible to add tags with comma eg. with mapstructure:

    type Friend struct {
        Person `mapstructure:",squash"`
    }
    

    I tried this but then squash is treated as the next tag token, maybe I'm missing something? :)

Access and modify property values in deeply nested maps, using dot-separated paths

Dig lets you access and modify property values in deeply nested, unstructured maps, using dot-separated paths: source := make(map[string]interface{})

May 7, 2022
Copier for golang, copy value from struct to struct and more

Copier I am a copier, I copy everything from one to another Features Copy from field to field with same name Copy from method to field with same name

Jan 8, 2023
Postgres uuid[] field for gorm.io - Golang

Postgres uuid[] field for gorm.io - Golang

Jan 17, 2022
gormuuid array field example

gormuuid - Examples An testing repo for https://github.com/ubgo/gormuuid module How to test Install the postgres and create a new database testdb Upda

Oct 20, 2021
A Runtime Struct Builder for Go

A Runtime Struct Builder for Go

Jul 8, 2022
Robust & Easy to use struct mapper and utility methods for Go

go-model Robust & Easy to use model mapper and utility methods for Go struct. Typical methods increase productivity and make Go development more fun ?

Dec 30, 2022
gin struct controller

gin struct controller

Oct 4, 2021
Tugas Alta Immersive Backend Golang Fundamental Programming (Pointer, Struct, Method, Interface)
Tugas Alta Immersive Backend Golang Fundamental Programming (Pointer, Struct, Method, Interface)

Tatacara Melakukan Setup Tugas clone project ini dengan cara git clone https://github.com/Immersive-Backend-Resource/Pointer-Struct-Method-Interface.g

Jan 9, 2022
Highly configurable struct to map converter.

Mapify Highly configurable struct to map converter. Will convert maps into other maps as well (work in progress). Features configuration outside the s

Jul 30, 2022
efaceconv - Code generation tool for high performance conversion from interface{} to immutable type without allocations.

efaceconv High performance conversion from interface{} to immutable types without additional allocations This is tool for go generate and common lib (

May 14, 2022
GoWrap is a command line tool for generating decorators for Go interfaces

GoWrap GoWrap is a command line tool that generates decorators for Go interface types using simple templates. With GoWrap you can easily add metrics,

Dec 30, 2022
Perforator is a tool for recording performance metrics over subregions of a program using the Linux "perf" interface.

Perforator Perforator is a tool for recording performance metrics over subregions of a program (e.g., functions) using the Linux "perf" interface.

Dec 15, 2022
a tool for creating exploited media files for discord

Discord-Exploits A program for creating exploited media files for discord written in Go. Usage discord-exploits is a command line utility, meaning you

Dec 29, 2021
A full-featured license tool to check and fix license headers and resolve dependencies' licenses.
A full-featured license tool to check and fix license headers and resolve dependencies' licenses.

SkyWalking Eyes A full-featured license tool to check and fix license headers and resolve dependencies' licenses. Usage You can use License-Eye in Git

Dec 26, 2022
sigurls is a reconnaissance tool, it fetches URLs from AlienVault's OTX, Common Crawl, URLScan, Github and the Wayback Machine.

sigurls is a reconnaissance tool, it fetches URLs from AlienVault's OTX, Common Crawl, URLScan, Github and the Wayback Machine. DiSCLAIMER: fe

May 22, 2021
A tool and library for using structural regular expressions.

Structural Regular Expressions sregx is a package and tool for using structural regular expressions as described by Rob Pike (link).

Dec 7, 2022
TUI grep tool respect for IntelliJ
TUI grep tool respect for IntelliJ

ilse TUI grep tool respect for IntelliJ Requirements ripgrep for fast grep bat for beautiful preview Features support HeadMatch(FirstMatch), WordMatch

Sep 27, 2022
A tool to check problems about meta files of Unity
A tool to check problems about meta files of Unity

A tool to check problems about meta files of Unity on Git repositories, and also the tool can do limited autofix for meta files of auto-generated files.

Dec 22, 2022
A tool to find redirection chains in multiple URLs
A tool to find redirection chains in multiple URLs

UnChain A tool to find redirection chains in multiple URLs Introduction UnChain automates process of finding and following `30X` redirects by extracti

Dec 12, 2022