genequal

command module
v0.0.0-...-fafa16c Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: MIT Imports: 10 Imported by: 0

README

genequal

Generate Equal() methods from AST

Usage

# go build

# Usage: genequal <path>

Example

Passing this code

package main

import "time"

type User struct {
	ID              int
	Revision        int
	Email           string
	GithubID        string
	DepartmentID    int
	DepartmentName  string
	ProfileImageURL string
	CreatedAt       time.Time
	DeletedAt       *time.Time
}

Will prints this

func (this User) Equal(other User) bool {
	if this.ID != other.ID {
		return false
	}
	if this.Revision != other.Revision {
		return false
	}
	if this.Email != other.Email {
		return false
	}
	if this.GithubID != other.GithubID {
		return false
	}
	if this.DepartmentID != other.DepartmentID {
		return false
	}
	if this.DepartmentName != other.DepartmentName {
		return false
	}
	if this.ProfileImageURL != other.ProfileImageURL {
		return false
	}
	if this.CreatedAt != other.CreatedAt {
		return false
	}
	if this.DeletedAt != other.DeletedAt {
		if this.DeletedAt != nil && other.DeletedAt != nil {
			if !this.DeletedAt.Equal(*other.DeletedAt) {
				return false
			}
		} else {
			return false
		}
	}

	return true
}

LICENSE

MIT

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