• The Method of Using JSON in Go Language


    Encode Encoding an object into JSON data, accepting an interface {} object, returning [] byte and error: func Marshal(v interface{}) ([]byte, error) The Marshal function will recursively traverse the entire object, encoding the object according to the member type in turn. The type conversion rules are as follows: Boolean type converted to JSONNumber converted to […]

  • Go grpc installation and use tutorial


    GRPC is an RPC framework developed by Google. It uses HTTP/2 protocol and ProtoBuf as a serialization tool. The client side provides objective-C and Java interfaces, while the server side has Java, Golang and C++ interfaces, which provides a solution for the communication between the mobile end (iOS/Androi) and the server side. Of course, in […]

  • Details of Interface in Go Language You Don’t Know


    Preface Recently, when we look at the object-oriented knowledge points of the Go language, we find that its object-oriented ability depends entirely on the interface, and its interface is completely different from the interface we know before. So the whole process keeps thinking about why it’s designed like this? What impact does this design have […]

  • Specific Use of Go Interface


    A brief look at Go shows that the design of Go grammar is very concise and easy to understand. That’s exactly what Rob Pike, the father of the Go language, said: “Less is more” – the avenue is simpler. Now I will talk about my own experience about the specific grammatical characteristics. interface overview Unlike […]

  • Some “pits” encountered when slice is passed as a parameter in Go language


    Preface I believe that seeing this topic may be considered a commonplace topic. It has always been possible to understand a variety of situations by grasping a “value transfer”, but recently encountered a deeper “small hole” to share with you. First of all, let’s start with the simplest one. Look at the following code: func […]

  • Using GO Language to Realize Multi-Person Chat Room Example Course


    Preface A simple multi-person chat room based on TCP is realized by using the related methods in the net package of go. It is managed by a server. The main feedback is whether the client has successfully connected and the content input from the client is displayed. It is sent to each client connected on […]

  • Basic Use Tutorials of Strct and Interface in Goang


    Preface This article mainly introduces the related content of struct and interface in golang, which belongs to the basic knowledge of golang. Let’s have a look at the detailed introduction. struct Struct is used to customize complex data structures, which can contain multiple fields (attributes) and can be nested; the struct type in go is […]

  • Talking about the Use and Realization of go-restful Framework


    REST (Representational State Transfer) is a widely used way to implement synchronous communication between distributed nodes in recent years. REST principle describes an interactive form of client-server in network, that is, locating resources with URL and describing the interactive form of operation with HTTP method. If the network interface between CSs meets the REST style, […]

  • Writing a Simple Web Socket Push Service in Go Language


    The code in this article can be found at github.com/alfred-zhong/wsserver. background Recent demand to display alarm information on the web page. In the past, alarm information was pushed to users by short message, micro-message and App. Now, login users can receive alarm push in real time on the web. I vaguely remember meeting similar needs […]

  • How to write an example tutorial of Go language Middleware


    Introduction In the context of web development, “middleware” usually means “part of an application that wraps the original application and adds some additional functionality”. This concept always seems to be unintelligible, but I think middleware is great. First, a good middleware has a responsibility to be pluggable and self-sufficient. This means that you can embed […]

  • How Go Implements HTTP Request Current Limitation Example


    In the development of high concurrent systems, there are three sharp tools to protect the system: cache, downgrade and current limiting. In order to ensure that the online system can also guarantee certain flexibility and stability during peak business period, the most effective solution is service downgrade, and current limiting is one of the most […]

  • Analysis of renderer package code in go language


    Renderer is a simple, lightweight and fast response rendering package of Go language. It can support JSON, JSONP, XML, HYAML, HTML, File and other types of responses. This package is a very convenient toolkit when developing web applications or RESTFul APIs. This article bypasses how to use it, goes deep into the code implementation to […]