Lazy Man Communication Protocol code generator Fastbin

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

This week, a lazy man. The communication Protocol code generator Fastbin, which parses the specified go code, extracts the structure information, and then generates binary serialization and deserialization methods for each struct. The generated code conforms to the Binarymarshaler and Binaryunmarshaler interface requirements defined in the encoding package, and also supports a more efficient serialization and deserialization approach.

The serialization format used by Fastbin is nothing special, and there is no protobuf optional field or Flatbuffer random access function, simple enough to be said to be rudimentary.

The development of this tool is entirely from the perspective of the project development process.

In our past projects, we have been using a set of custom protocol description Language to do the protocol description, and then use these protocols to describe the document to generate the corresponding server and customer code, which is Protobuf, Flatbuffer and other tools of the process.

There is a problem with this configuration-based development process, where it is often necessary to switch back and forth between configuration files, command lines, generated objects, and function codes, which can easily disrupt the coherence of thought.

I have a personal joke about the coherence of my mind.

Once I want to activate a software, sn in my Gmail mailbox, I opened Gmail mailbox when I found the company's automatic science Internet access can not open Gmail, so I began to study the company's science online which link problems, and finally set to be DNSMASQ configuration problem, I went to the whole configuration. When I have been configured, open Gmail, I am on the computer in there for a long time what I was going to do?

In fact, this kind of thing will happen in the development process, our project development process will involve a variety of tools configuration, these things are scattered our little energy, in fact, invisible to us brings a lot of extra energy loss. This energy loss not only affects the development efficiency and even affect the product quality and the enthusiasm of doing things, because the human energy is limited, when a thing to do a lot of steps are very cumbersome, people will naturally reduce the number of times, and even from the subconscious to do it.

So I hope that in our project development process, the tool can be at hand, take to use, put down, do not interfere, do not disperse energy. In this way, you can focus more on the project itself rather than on a link in the development process.

I think about it, and the most straightforward way to do that is to use the code itself as a configuration, and the tools in turn extract the information from the code so that the entire development process is no longer needed to switch back and forth.

So the Fastbin feature is the 0 configuration, Fastbin Fast does not mean that its execution efficiency how fast the data structure is good, but that its development efficiency is high, write code on demand can be used.

Go because of the built-in Go parser, so parsing go structure is not difficult, in addition to the go built-in template package also saves code generation tool a lot of code, improve code readability.

Fastbin also uses the go generate command to generate the Fastbin code for this file using the "Go Generate" command, as long as the header of the file that needs to generate the code is annotated with a line.

If you are interested in this tool or idea, welcome to the project homepage to see, Welcome to submit issue and PR.

Project home: Funny/fastbin GitHub

If the good is water, the water is good for all things without contention.

Related Article

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.