mirror of
				https://github.com/xxjwxc/ginrpc.git
				synced 2025-11-01 02:43:33 +08:00 
			
		
		
		
	fix get on json
添加get模式支持json 标签,主要用于proto自动生成文件
This commit is contained in:
		
							
								
								
									
										24
									
								
								internal/bytesconv/bytesconv.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								internal/bytesconv/bytesconv.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| // Copyright 2020 Gin Core Team. All rights reserved. | ||||
| // Use of this source code is governed by a MIT style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package bytesconv | ||||
|  | ||||
| import ( | ||||
| 	"unsafe" | ||||
| ) | ||||
|  | ||||
| // StringToBytes converts string to byte slice without a memory allocation. | ||||
| func StringToBytes(s string) []byte { | ||||
| 	return *(*[]byte)(unsafe.Pointer( | ||||
| 		&struct { | ||||
| 			string | ||||
| 			Cap int | ||||
| 		}{s, len(s)}, | ||||
| 	)) | ||||
| } | ||||
|  | ||||
| // BytesToString converts byte slice to string without a memory allocation. | ||||
| func BytesToString(b []byte) string { | ||||
| 	return *(*string)(unsafe.Pointer(&b)) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 xxj
					xxj