Skip to content

siskinc/go-easy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-easy

utils for easy coding in golang

generate

mongodb

example

command run:

export GO111MODULE=on
go build . && go generate test/test_generate_mongodb.go

functions

  1. curd
  2. generate soft delete code
  3. generate find by xxx unique field code
  4. set timestamp to create at field
  5. set timestamp to update at field
  6. set timestamp to delete at field
  7. generate migrate code by unique index

error-code

example

Command run:

go-easy generate error-code --type EnumTestA --type EnumTestB

example

code(test_enum.go)
//go:generate go-easy generate error-code --type EnumTest
type EnumTest uint64
const (
	// PlaceHolder
	EnumTestNone EnumTest = iota
	// Test One
	EnumTest1
	// Test Tow
	EnumTest2
)
command
go generate test_enum.go
Generate Code (enum_test_generate_error_code.go)
// Code generated by go-easy generate error code DO NOT EDIT.
// go-easy url: https://github.com/siskinc/go-easy
package test

func (e EnumTest) Error() string {
	switch e {

	case EnumTest1:
		return "Test One"

	case EnumTest2:
		return "Test Tow"

	case EnumTestNone:
		return "PlaceHolder"

	}
	return "UNKNOWN"
}

func (e EnumTest) String() string {
	switch e {

	case EnumTest1:
		return "EnumTest1"

	case EnumTest2:
		return "EnumTest2"

	case EnumTestNone:
		return "EnumTestNone"

	}
	return "UNKNOWN"
}

About

utils for easy coding in golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages