- π― What is tagcase?
- β¨ Key Features
- β³ Quick Start
- βοΈ Configuration
- π§ Advance
- π€ Contributing
- π License
tagcase makes struct tags naming consistent throughout your Go project. Whether you are working with JSON APIs, databases, configurations, or anything else.
# yaml-language-server: $schema=https://raw.githubusercontent.com/miyamo2/tagcase/main/schema.json
tags:
json:
case: snake_case
dynamodbav:
case: camelCase
tagcase -w path/to/file.go
type User struct {
- ID int `json:"user_id" dynamodbav:"UserID"`
- Name string `json:"userName" dynamodbav:"user_name"`
- Email string `json:"Email" dynamodbav:"email"`
+ ID int `json:"user_id" dynamodbav:"userID"`
+ Name string `json:"user_name" dynamodbav:"userName"`
+ Email string `json:"email" dynamodbav:"email"`
}
- 6 Case Formats
- Flexible configuration
golangci-lint
Plugin supportgo vet
Analyzer
# Go
go install github.com/miyamo2/tagcase@latest
# Homebrew
brew install miyamo2/tap/tagcase
# Check files for tag inconsistencies (shows diff)
tagcase -d path/to/file.go
# Fix formatting issues automatically
tagcase -w path/to/file.go
# Initialize configuration file
tagcase --init
# Go
go install github.com/miyamo2/tagcase/cmd/tagcase-analyzer@latest
# Homebrew
brew install miyamo2/tap/tagcase-analyzer
# Run analyzer on your Go project
go vet -vettool=$(which tagcase-analyzer) ./...
Create a .tagcase.yaml
file to customize rules for your project:
# yaml-language-server: $schema=https://raw.githubusercontent.com/miyamo2/tagcase/main/schema.json
# Specify case conventions for different tag types
tags:
json:
# Supported cases: snake_case, camelCase, PascalCase, kebab-case, SNAKE_CASE, KEBAB-CASE
case: snake_case
db:
case: snake_case
yaml:
case: camelCase
xml:
case: PascalCase
# Custom initialism handling
initialism:
enable:
- API
- UUID
disable:
- ID
- Add
.custom-gcl.yml
to your project root
version: v2.2.0
plugins:
- module: 'github.com/miyamo2/tagcase'
import: 'github.com/miyamo2/tagcase/pkg/golangci-lint/plugin'
version: latest
- Build the custom golangci-lint
golangci-lint custom
- Add tagcase to your
.golangci.yaml
:
version: "2"
linters:
settings:
custom:
tagcase:
type: "module"
settings:
tags:
db:
case: snake_case
- Run the custom golangci-lint
./custom-gcl run ./...
We welcome contributions! tagcase is built by the community, for the community.
- π Report bugs
- π Request features
- π Submit pull requests
- π¬ Share with others
- β Star the repo if you find it useful!
tagcase is released under the MIT License