golang字符串转Uint16

switch params[index].ParameType {
		case 10: //10=数值(Byte)
			params[index].ParameByte = []byte{byte(xtools.InterfaceToInt(params[index].ParameValue))}
		case 15: //15=Bytes
			params[index].ParameByte, _ = hex.DecodeString(params[index].ParameValue)
		case 20: //20=ASCII
			params[index].ParameByte = []byte(params[index].ParameValue)
		case 30: //30=Uint16
			var value = make([]byte, 2)
			valueUint64, _ := strconv.ParseUint(params[index].ParameValue, 10, 16)
			binary.BigEndian.PutUint16(value, uint16(valueUint64))
			params[index].ParameByte = value

你可能感兴趣的:(golang)