修复自定义Marshal序列化的BUG
This commit is contained in:
		
							
								
								
									
										10
									
								
								data_type.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								data_type.go
									
									
									
									
									
								
							@ -14,11 +14,11 @@ package consts
 | 
				
			|||||||
// Date : 14:10 2024/11/25
 | 
					// Date : 14:10 2024/11/25
 | 
				
			||||||
type DataType string
 | 
					type DataType string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (df DataType) String() string {
 | 
					func (df *DataType) String() string {
 | 
				
			||||||
	return string(df)
 | 
						return string(*df)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (df DataType) MarshalJSON() ([]byte, error) {
 | 
					func (df *DataType) MarshalJSON() ([]byte, error) {
 | 
				
			||||||
	return []byte(df.String()), nil
 | 
						return []byte(df.String()), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -27,9 +27,9 @@ func (df DataType) MarshalJSON() ([]byte, error) {
 | 
				
			|||||||
// Author : go_developer@163.com<白茶清欢>
 | 
					// Author : go_developer@163.com<白茶清欢>
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Date : 14:45 2024/11/25
 | 
					// Date : 14:45 2024/11/25
 | 
				
			||||||
func (df DataType) IsValid() bool {
 | 
					func (df *DataType) IsValid() bool {
 | 
				
			||||||
	for _, item := range DataTypeList {
 | 
						for _, item := range DataTypeList {
 | 
				
			||||||
		if item.Value == df {
 | 
							if item.Value == *df {
 | 
				
			||||||
			return true
 | 
								return true
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								file_type.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								file_type.go
									
									
									
									
									
								
							@ -9,15 +9,15 @@ package consts
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type FileType string
 | 
					type FileType string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ft FileType) String() string {
 | 
					func (ft *FileType) String() string {
 | 
				
			||||||
	return string(ft)
 | 
						return string(*ft)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ft FileType) MarshalJSON() ([]byte, error) {
 | 
					func (ft *FileType) MarshalJSON() ([]byte, error) {
 | 
				
			||||||
	return []byte(ft.String()), nil
 | 
						return []byte(ft.String()), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ft FileType) IsValid() bool {
 | 
					func (ft *FileType) IsValid() bool {
 | 
				
			||||||
	supportFileTypeList := []FileType{
 | 
						supportFileTypeList := []FileType{
 | 
				
			||||||
		FileTypeJson,
 | 
							FileTypeJson,
 | 
				
			||||||
		FileTypeIni,
 | 
							FileTypeIni,
 | 
				
			||||||
@ -28,7 +28,7 @@ func (ft FileType) IsValid() bool {
 | 
				
			|||||||
		FileTypeTxt,
 | 
							FileTypeTxt,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for _, fileType := range supportFileTypeList {
 | 
						for _, fileType := range supportFileTypeList {
 | 
				
			||||||
		if fileType == ft {
 | 
							if fileType == *ft {
 | 
				
			||||||
			return true
 | 
								return true
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -9,11 +9,11 @@ package consts
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type HttpHeader string
 | 
					type HttpHeader string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (hh HttpHeader) String() string {
 | 
					func (hh *HttpHeader) String() string {
 | 
				
			||||||
	return string(hh)
 | 
						return string(*hh)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (hh HttpHeader) MarshalJSON() ([]byte, error) {
 | 
					func (hh *HttpHeader) MarshalJSON() ([]byte, error) {
 | 
				
			||||||
	return []byte(hh.String()), nil
 | 
						return []byte(hh.String()), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								logger.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								logger.go
									
									
									
									
									
								
							@ -9,15 +9,15 @@ package consts
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type LogLevel string
 | 
					type LogLevel string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ll LogLevel) String() string {
 | 
					func (ll *LogLevel) String() string {
 | 
				
			||||||
	return string(ll)
 | 
						return string(*ll)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ll LogLevel) MarshalJSON() ([]byte, error) {
 | 
					func (ll *LogLevel) MarshalJSON() ([]byte, error) {
 | 
				
			||||||
	return []byte(ll.String()), nil
 | 
						return []byte(ll.String()), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ll LogLevel) IsValid() bool {
 | 
					func (ll *LogLevel) IsValid() bool {
 | 
				
			||||||
	levelList := []LogLevel{
 | 
						levelList := []LogLevel{
 | 
				
			||||||
		LogLevelDebug,
 | 
							LogLevelDebug,
 | 
				
			||||||
		LogLevelInfo,
 | 
							LogLevelInfo,
 | 
				
			||||||
@ -26,7 +26,7 @@ func (ll LogLevel) IsValid() bool {
 | 
				
			|||||||
		LogLevelPanic,
 | 
							LogLevelPanic,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for _, level := range levelList {
 | 
						for _, level := range levelList {
 | 
				
			||||||
		if level == ll {
 | 
							if level == *ll {
 | 
				
			||||||
			return true
 | 
								return true
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										19
									
								
								logger_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								logger_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					// Package consts ...
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Description : consts ...
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Author : go_developer@163.com<白茶清欢>
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Date : 2025-01-22 15:36
 | 
				
			||||||
 | 
					package consts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"testing"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestLogLevel_String(t *testing.T) {
 | 
				
			||||||
 | 
						byteData, err := json.Marshal(LogLevelDebug)
 | 
				
			||||||
 | 
						fmt.Println(string(byteData), err)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										6
									
								
								redis.go
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								redis.go
									
									
									
									
									
								
							@ -9,11 +9,11 @@ package consts
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type RedisCmd string
 | 
					type RedisCmd string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (rc RedisCmd) String() string {
 | 
					func (rc *RedisCmd) String() string {
 | 
				
			||||||
	return string(rc)
 | 
						return string(*rc)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (rc RedisCmd) MarshalJSON() ([]byte, error) {
 | 
					func (rc *RedisCmd) MarshalJSON() ([]byte, error) {
 | 
				
			||||||
	return []byte(rc.String()), nil
 | 
						return []byte(rc.String()), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								request.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								request.go
									
									
									
									
									
								
							@ -38,17 +38,17 @@ func (rdl RequestDataLocation) IsValid() bool {
 | 
				
			|||||||
// Date : 14:41 2024/11/25
 | 
					// Date : 14:41 2024/11/25
 | 
				
			||||||
type ResponseDataLocation string
 | 
					type ResponseDataLocation string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (rdl ResponseDataLocation) String() string {
 | 
					func (rdl *ResponseDataLocation) String() string {
 | 
				
			||||||
	return string(rdl)
 | 
						return string(*rdl)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (rdl ResponseDataLocation) MarshalJSON() ([]byte, error) {
 | 
					func (rdl *ResponseDataLocation) MarshalJSON() ([]byte, error) {
 | 
				
			||||||
	return []byte(rdl.String()), nil
 | 
						return []byte(rdl.String()), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (rdl ResponseDataLocation) IsValid() bool {
 | 
					func (rdl *ResponseDataLocation) IsValid() bool {
 | 
				
			||||||
	for _, item := range ResponseDataLocationList {
 | 
						for _, item := range ResponseDataLocationList {
 | 
				
			||||||
		if item.Value == rdl {
 | 
							if item.Value == *rdl {
 | 
				
			||||||
			return true
 | 
								return true
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -9,11 +9,11 @@ package consts
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type HttpScheme string
 | 
					type HttpScheme string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (hs HttpScheme) String() string {
 | 
					func (hs *HttpScheme) String() string {
 | 
				
			||||||
	return string(hs)
 | 
						return string(*hs)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (hs HttpScheme) MarshalJSON() ([]byte, error) {
 | 
					func (hs *HttpScheme) MarshalJSON() ([]byte, error) {
 | 
				
			||||||
	return []byte(hs.String()), nil
 | 
						return []byte(hs.String()), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user