jsonCameler

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: MIT Imports: 9 Imported by: 0

README

jsonCameler Go Report Card

jsonCameler can be used to check whether JSON tags of structs are written in lowerCamel case. You can skip lint check by adding comment nocaml to the fields of the struct or to the above line of the declaration of the struct.

Installation

go install github.com/k3forx/jsonCameler/cmd/jsonCameler@latest

How to use

go vet -vettool=`which jsonCameler` ./...

Here is an example.

package main

import (
	"time"
)

type User struct {
	ID        int       `json:"id"`        
	FirstName string    `json:"firstName"` 
	LastName  string    `json:"last-name"` // invalid
	Username  string    `json:"user-name"` // nocamel
	BirthDay  time.Time `json:"-"`         
}

// nocamel
type Score struct {
	ID        int
	UserID    int       `json:"user_id"`
	Score     int       `json:"s-co-re"`
	CreatedAt time.Time `json:"created_at" some tags`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

func main() {
	...
}

The result will be like...

go vet -vettool=`which jsonCameler` ./
./main.go:16:2: invalid JSON tag `last-name`

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "jsonCameler",
	Doc:  doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
		commentmap.Analyzer,
	},
}

Analyzer is ...

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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