Golang and Java msgpack different

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Wrote a server,java with Golang, wrote a client.

The communication was packaged using msgpack and found that the packages for Golang and Java pack were inconsistent

public class Mymessage {//Public fields is serialized.    public String name;    public double version;}    Mymessage src = new mymessage ();    Src.name = "Msgpack"; Src.version = 0.6;

Java bytes:

Bytes: [A7 6d 6b CB 3f E3 33 33 33 33 33 33]


Golang

Type userstruct struct {Name stringid int32}data, err: = Msgpack. Marshal (&user) If Err = = Nil {fmt. PRINTLN ("Data:", data)} else {fmt. Println ("ERR:", err)}

Golang bytes:

Go: [A4 6e 6d A7 6d 33 33 33 33, 6b A7--------


It might be possible to see that Java Pack omitted field-related information


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.