utils for easy coding in golang
command run:
export GO111MODULE=on
go build . && go generate test/test_generate_mongodb.go
- curd
- generate soft delete code
- generate find by xxx unique field code
- set timestamp to
create at
field - set timestamp to
update at
field - set timestamp to
delete at
field - generate migrate code by unique index
Command run:
go-easy generate error-code --type EnumTestA --type EnumTestB
//go:generate go-easy generate error-code --type EnumTest
type EnumTest uint64
const (
// PlaceHolder
EnumTestNone EnumTest = iota
// Test One
EnumTest1
// Test Tow
EnumTest2
)
go generate test_enum.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"
}