mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-30 22:15:27 -05:00
refactor io package
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
package serial
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"v2ray.com/core/common/buf"
|
||||
)
|
||||
import "strconv"
|
||||
|
||||
func Uint16ToBytes(value uint16, b []byte) []byte {
|
||||
return append(b, byte(value>>8), byte(value))
|
||||
@@ -14,7 +10,7 @@ func Uint16ToString(value uint16) string {
|
||||
return strconv.Itoa(int(value))
|
||||
}
|
||||
|
||||
func WriteUint16(value uint16) buf.Supplier {
|
||||
func WriteUint16(value uint16) func([]byte) (int, error) {
|
||||
return func(b []byte) (int, error) {
|
||||
b = Uint16ToBytes(value, b[:0])
|
||||
return 2, nil
|
||||
@@ -29,7 +25,7 @@ func Uint32ToString(value uint32) string {
|
||||
return strconv.FormatUint(uint64(value), 10)
|
||||
}
|
||||
|
||||
func WriteUint32(value uint32) buf.Supplier {
|
||||
func WriteUint32(value uint32) func([]byte) (int, error) {
|
||||
return func(b []byte) (int, error) {
|
||||
b = Uint32ToBytes(value, b[:0])
|
||||
return 4, nil
|
||||
|
||||
Reference in New Issue
Block a user