golang位移操作的一个小坑
妙音
posted @ 2021年11月25日 16:08
in golang
, 1033 阅读
问题描述
现有int16类型的整数,将它转为两个字节存放。在还原时,一不小心会就被坑了。
错误用法
length := int(keyBytes[cursor] + keyBytes[cursor+1] <<8)
正确用法
keyBytes := []byte{ 16, 1} length := int(uint16(keyBytes[cursor]) + uint16(keyBytes[cursor+1]) <<8)
错误原因
字节byte位移时类型不会自动变化, 先要转换类型再位移。
2023年6月21日 12:02
I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. Thanks... 평택출장마사지
2023年7月12日 19:30
This particular papers fabulous, and My spouse and i enjoy each of the perform that you have placed into this. I'm sure that you will be making a really useful place. I has been additionally pleased. Good perform! 천안출장 마사지
2023年7月15日 21:34
hello!! Very interesting discussion glad that I came across such informative post. Keep up the good work friend. Glad to be part of your net community. Clicksud
2023年8月09日 16:38
I'm in awe of the quality of content you consistently deliver. This article is top-notch.
2023年8月12日 06:43
Thanks for a very interesting blog. Your blog provided us with valuable information to work with. I am from Imamia Quran Academy. Shia Academy is using this radical idea of taking online classes so that any environmental factor could not disrupt the learning process. Join our Online Shia Quran Academy now, and Start your free 3 days Trial.
2023年8月30日 12:20
You’ve got some interesting points in this article. I would have never considered any of these if I didn’t come across this. Thanks!. เว็บแทงบอลดีที่สุดUFABET
2023年8月31日 19:44
I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. last minute naar bad waltersdorf
2023年10月21日 19:35
Nice to be visiting your blog again, it has been months for me. Well this article that i’ve been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. ufabetทางเข้าเล่น
2023年11月06日 21:53
What a fantastic blog! I enjoy reading your posts. Good luck with your paintings! Thanks for reading! You could be of great assistance to a lot of people who are searching for this information. pgslot168
2023年11月07日 00:56
We are looking for a lot of data on this item. In the meantime, this is the perfect article I was looking for . Please post a lot about items related to!!! I am waiting for your article. And when you are having difficulty writing articles, I think you can get a lot of help by visiting my ufa168
2023年11月14日 22:14
betflix vip A very impressive article, I regularly visit your blog to read free time. It has both helped me relax and have more knowledge.
2023年11月30日 14:58
vThanks , I have just been looking for information about this topic for ages and yours is the best I have came upon till now. biogaming
2023年12月06日 09:19
The importance of user education in maximizing the benefits of large file transfer apps, <a href="https://play.google.com/store/apps/details?id=mefile.transfer.appwe.transfer.file.smash.send.files.forfree.gratuit">move google drive to onedrive</a>
including tutorials, FAQs, and online support.
2023年12月06日 09:19
2023年12月06日 09:22
[move google drive to onedrive
](https://play.google.com/store/apps/details?id=mefile.transfer.appwe.transfer.file.smash.send.files.forfree.gratuit
)
2023年12月06日 09:23
[https://play.google.com/store/apps/details?id=mefile.transfer.appwe.transfer.file.smash.send.files.forfree.gratuit move google drive to onedrive]
2023年12月06日 09:24
The importance of user education in maximizing the benefits of large file transfer apps, including tutorials, FAQs, and online support.
2023年12月06日 09:26
The importance of user education in maximizing the benefits of large file transfer apps, including tutorials, FAQs, and online [https://play.google.com/store/apps/details?id=mefile.transfer.appwe.transfer.file.smash.send.files.forfree.gratuit|move google drive to onedrive]
2023年12月11日 23:09
The next time I read a blog, I hope that it doesn't disappoint me as much as this one. I mean, I know it was my choice to read, but I thought you had something interesting to say. All I hear is a bunch of whining about something that you could fix if you weren't too busy looking for attention. UFABETแทงบอลเว็บแม่
2024年3月31日 17:09
THE ONE CARGO รับ นำเข้าสินค้าจากจีน เว็บสั่งของจากจีน ที่ช่วยดูแลทุกการนำเข้าจนถึงหน้าบ้านคุณ ช่วยคุยติดต่อ โรงงาน ร้านค้าแหล่งขายส่ง มีล่ามช่วยแก้ปัญหาต่อราคาคุยกับร้านจีนให้ มีระบบติดตามสถานะพัสดุ พร้อมแจ้งเตื่อนเข้า Line
2024年10月31日 23:35
Fantastic post. I was pleased by this blog, which I was always monitoring! Very helpful stuff, especially the last section. I really value this kind of knowledge. I spent a lot of time researching this specific information. My exploration has come to an end because of this blog. e visas india visa for belgian citizens
2024年11月05日 22:17
Whoa, this is such a great post. This is too informatics, in my opinion. That's exactly what I was looking for. I would like to suggest that you continue to provide this kind of information.Thank you, if this is feasible. naked