Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4aa5110726 | |||
| d4b7e7e9e6 | |||
| 98ee26f215 | |||
| 0218dfd02e | |||
|
|
629ec74be6 |
@@ -41,10 +41,6 @@ func New(srvKey string, cfg any) {
|
|||||||
log.Fatalln("ERROR: Service Not Nil", cfp)
|
log.Fatalln("ERROR: Service Not Nil", cfp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(string(yamlFile), "Port:") {
|
|
||||||
log.Fatalln("ERROR: Port Not Nil", cfp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析YAML
|
// 解析YAML
|
||||||
err = yaml.Unmarshal(yamlFile, cfg)
|
err = yaml.Unmarshal(yamlFile, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -55,7 +51,7 @@ func New(srvKey string, cfg any) {
|
|||||||
func NotNil(values ...string) {
|
func NotNil(values ...string) {
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
if strings.TrimSpace(value) == "" {
|
if strings.TrimSpace(value) == "" {
|
||||||
log.Fatalln("ERROR:Must config not nil")
|
log.Fatalln("ERROR:Must config key not nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type Reply struct {
|
|||||||
func (reply *Reply) Success(ctx *gin.Context, data any) {
|
func (reply *Reply) Success(ctx *gin.Context, data any) {
|
||||||
reply.Code = 200
|
reply.Code = 200
|
||||||
reply.Data = data
|
reply.Data = data
|
||||||
|
reply.Msg = ""
|
||||||
if data == nil {
|
if data == nil {
|
||||||
reply.Data = ""
|
reply.Data = ""
|
||||||
}
|
}
|
||||||
@@ -23,12 +24,12 @@ func (reply *Reply) Success(ctx *gin.Context, data any) {
|
|||||||
}
|
}
|
||||||
func (reply *Reply) Error(ctx *gin.Context, err error) {
|
func (reply *Reply) Error(ctx *gin.Context, err error) {
|
||||||
reply.Code = 500
|
reply.Code = 500
|
||||||
|
reply.Data = ""
|
||||||
// Status code defaults to 500
|
// Status code defaults to 500
|
||||||
e, ok := status.FromError(err)
|
e, ok := status.FromError(err)
|
||||||
if ok {
|
if ok {
|
||||||
reply.Code = int(e.Code())
|
reply.Code = int(e.Code())
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.Msg = e.Message()
|
reply.Msg = e.Message()
|
||||||
|
|
||||||
// Send error
|
// Send error
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
log.SetFlags(log.Ldate | log.Ltime)
|
||||||
|
}
|
||||||
|
|
||||||
// record INFO message. Color White
|
// record INFO message. Color White
|
||||||
func Info(format string, a ...interface{}) {
|
func Info(format string, a ...interface{}) {
|
||||||
message := fmt.Sprintf("\033[37m[Info] "+format+"\033[0m\n", a...)
|
message := fmt.Sprintf("\033[37m[Info] "+format+"\033[0m\n", a...)
|
||||||
|
|||||||
Reference in New Issue
Block a user