gotag

command module
v0.0.0-...-1607f5e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

gotag is a command tool that can automatically generate tags for golang struct.

Quick start

Install gotag

go install github.com/sycki/gotag@latest

Process your go file

gotag -a json:camel,yaml:camel,gorm:snake model/*.go

or 

gotag -a json:aA,yaml:aA,gorm:a_a model/*.go

File content

type User struct {
    Name               string `json:"name" yaml:"name" gorm:"name"`
    IdCard             string `json:"idCard" yaml:"idCard" gorm:"id_card"`
    ResidentialAddress string `json:"residentialAddress" yaml:"residentialAddress" gorm:"residential_address"`
    CompanyName        string `json:"companyName" yaml:"companyName" gorm:"company_name"`
}

Usage

gotag is a command tool that can automatically generate tags for golang struct.

Usage: gotag [OPTIONS] filename ...

Options:
    -a, --add <TagName:Style>   Add tags to struct
                                TagName:     can be any string
                                Style:       "camel", "snake", "go", "upper", "lower"
                                Style alias: "aA", "a_a", "Aa", "AA", "aa"
    -i, --index <Number>        Specify the position for the --add option
                                Negative number: means cover all
                                0 ~ max integer: insert to the specified position
    -r, --remove <TagName>      Remove tags from struct

Examples:
    gotag -a json:camel -a gorm:snake model/*.go

    gotag -a json:aA,gorm:a_a -i -1 model/*.go

    gotag -r json model/*.go

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL