In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to understand golang environment data 212protocol". In daily operation, I believe many people have doubts about how to understand golang environment data 212protocol. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to understand golang environment data 212protocol". Next, please follow the editor to study!
Unit test method package serverimport ("bytes", "github.com/liqiongtao/goo", "log", "strconv"testing") func Test_message2dbV2 (t * testing.T) {buf: = [] byte ("# 0331QNshipping 20210408192740056 [# 0331QNshipping 20210408192740056] STSTABSTATION 0507A010000330lead 1flagship 5CPP =\ u0026\ u0026DataTimeplate 20210408192740a01001color Rtdbath 14authora01002color Flagman Na01002color Rtdcards 37.2color 97.94a1006 A01007 Mustang Rtdbath 0meme a01007 lyric Flagstaff Nente a01008 lyrics Nittlee 297 memorials a01008 lyric Flagions Nevera 34001 Michor Rtdspell 53 meme a34001 Fleming Nente a34002 Mustang Rtdflowers 62mema34002 Flyagem N A34004buf Rtdcast 39Magol a34004buf Flagger N\ u0026\ u002671C0\ r\ n ") / / determine whether the data begins with # # if! bytes.Equal (buf [: 2], [] byte (" # # ")) {goo.Log.WithField (" message ") String (buf). Error ("incorrect message format") return} / / replace the escape character buf = bytes.ReplaceAll (buf, [] byte ("\ u0026"), [] byte ("&") var (dl int err error) / / get protocol data length dl Err = strconv.Atoi (string (buf [2:6])) if err! = nil {goo.Log.WithField ("message", string (buf)) .error (err.Error ()) return} if l: = len (buf) Dl > lumb6 {return} var (dtBuf = buf [6: dl+6] index int data = map [string] string {}) / / convert data to map for _, I: = range bytes.Split (dtBuf, [] byte ("& &")) {for _ J: = range bytes.Split (I, [] byte (" ) {if string (j) = "" {continue} for _, bf: = range bytes.Split (j, [] byte (") ") {if string (bf) ="{continue} index = bytes.Index (bf) [] byte ("=") if index =-1 {continue} data [string (bf [: index])] = string (bf [index + 1:])} }} for k V: = range data {log.Println (k, "=", v)}} so far The study on "how to understand golang Environment data 212 Protocol" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.