go版本的supervisord
go和python解码msgpack不一致

golang位移操作的一个小坑

妙音 posted @ 2021年11月25日 16:08 in golang , 213 阅读

问题描述

 
    现有int16类型的整数,将它转为两个字节存放。在还原时,一不小心会就被坑了。
 
 

错误用法

 
length := int(keyBytes[cursor] + keyBytes[cursor+1] <<8)
 

正确用法

 
keyBytes := []byte{ 16, 1}
length := int(uint16(keyBytes[cursor]) + uint16(keyBytes[cursor+1]) <<8)
 

错误原因

 
字节byte位移时类型不会自动变化, 先要转换类型再位移。
 
 
Avatar_small
YOLO 说:
2021年12月02日 19:51

slotok Just pick up the phone, whether the system

Avatar_small
seo 说:
2021年12月05日 06:07

I would really work with this company whenever I have a project. They are very efficient and knowledgeable. You could check out their https://caldwells.com/interior-doors/traditional-doors here.

Avatar_small
AAA 说:
2021年12月23日 16:54

Glad to be one of several visitors on this awe inspiring internet site : D. 안전놀이터

Avatar_small
Digital_Zone 说:
2021年12月31日 03:38

Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive! minecraft server

Avatar_small
asasa 说:
2022年1月07日 21:01

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. building the mansions at acqualina For Sale

Avatar_small
Digital_Zone 说:
2022年1月13日 07:21

You delivered such an impressive piece to read, giving every subject enlightenment for us to gain information. Thanks for sharing such information with us due to which my several concepts have been cleared. 먹튀검증

Avatar_small
Digital_Zone 说:
2022年1月13日 07:27

Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive! 먹튀폴리스

Avatar_small
Digital_Zone 说:
2022年1月13日 07:31

Thank you a bunch for sharing this with all of us you actually realize what you are talking about! Bookmarked. Please also seek advice from my site =). We could have a hyperlink change contract between us! 토토사이트

Avatar_small
Digital_Zone 说:
2022年1月13日 07:36

This type of message always inspiring and I prefer to read quality content, so happy to find good place to many here in the post, the writing is just great, thanks for the post. 토토사이트

Avatar_small
Digital_Zone 说:
2022年1月13日 07:42

You have done a great job on this article. It’s very readable and highly intelligent. You have even managed to make it understandable and easy to read. You have some real writing talent. Thank you. 먹튀검증

Avatar_small
Digital_Zone 说:
2022年1月13日 07:48

Really a great addition. I have read this marvelous post. Thanks for sharing information about it. I really like that. Thanks so lot for your convene. 안전놀이터

Avatar_small
joker game 说:
2022年1月14日 02:44

I am continually amazed by the amount of information available on this subject. What you presented was well researched and well worded in order to get your stand on this across to all your readers.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter