Documentation ¶
Overview ¶
Common tools and helper functions
Index ¶
- Variables
- func Bind(c *gin.Context, obj interface{}) error
- func ConvertMapToStruct(m map[string]interface{}, s interface{}) error
- func ConvertToDistinctArray(edges []domain.WordsLink) []string
- func InitConfig()
- func RandString(n int) string
- func ToPointer[T any](x T) *T
- type CommonError
- type Configuration
- type Nullable
- type Stream
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInternalServerError = errors.New("internalServerError") ErrNotFound = errors.New("notFound") ErrConflict = errors.New("alreadyExist") ErrBadParamInput = errors.New("badParamInput") ErrEmailDuplicate = errors.New("emailDuplicated") ErrTokenInvalid = errors.New("tokenInvalid") ErrUnauthentication = errors.New("unAuthentication") ErrInvalidCredential = errors.New("invalidCredential") )
Functions ¶
func Bind ¶
Changed the c.MustBindWith() -> c.ShouldBindWith(). I don't want to auto return 400 when error happened. origin function is here: https://github.com/gin-gonic/gin/blob/master/context.go
func ConvertMapToStruct ¶
func ConvertToDistinctArray ¶
func InitConfig ¶
func InitConfig()
Types ¶
type CommonError ¶
type CommonError struct {
Errors map[string]interface{} `json:"errors"`
}
My own Error type that will help return my customized Error info
{"database": {"hello":"no such table", error: "not_exists"}}
func NewValidatorError ¶
func NewValidatorError(err error) CommonError
To handle the error returned by c.Bind in gin framework https://github.com/go-playground/validator/blob/v9/_examples/translations/main.go
type Configuration ¶
type Configuration struct { AppName string AppDomain string AppEmail string TokenSecret string RefreshTokenSecret string //database DBHost string DBPort string DBUsername string DBPassword string //mail server SMTPHost *string SMTPPort *string SMTPUsername *string SMTPPassword *string //mailjet MailjetPublicKey *string MailjetPrivateKey *string }
var AppConfig *Configuration
type Nullable ¶
type Nullable struct {
Value any
}
func (Nullable) ToInt64Ptr ¶
func (Nullable) ToStringArrayPtr ¶
func (Nullable) ToStringPtr ¶
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) Contains ¶
dst := StreamOf(hoges).
Contains(func(hoge *Hoge) bool { return hoge.ID == "abc" })
要素の存在確認
func (*Stream) Filter ¶
dst := StreamOf(hoges).
Filter(func(hoge *Hoge) bool { return hoge.Num > 3 }).Out().([]*Hoge)
要素のフィルタリング
func (*Stream) ForEach ¶
dst := StreamOf(hoges).
ForEach(func(hoge *Hoge, i int) { hoge.ID = "abc" })
要素のループ
func (*Stream) Map ¶
dst := StreamOf(hoges).
Map(func(hoge *Hoge) string { return hoge.ID }).Out().([]string)
要素の変換
Click to show internal directories.
Click to hide internal directories.