mirror of
				https://github.com/oarkflow/mq.git
				synced 2025-10-31 07:36:27 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			17 lines
		
	
	
		
			232 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			232 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package utils
 | |
| 
 | |
| import (
 | |
| 	"unsafe"
 | |
| )
 | |
| 
 | |
| func ToByte(s string) []byte {
 | |
| 	p := unsafe.StringData(s)
 | |
| 	b := unsafe.Slice(p, len(s))
 | |
| 	return b
 | |
| }
 | |
| 
 | |
| func FromByte(b []byte) string {
 | |
| 	p := unsafe.SliceData(b)
 | |
| 	return unsafe.String(p, len(b))
 | |
| }
 | 
