Logging with Go

brief introduction Define configuration Read log-related configuration summary The current part of the code brief introduction In the previous section, we used viper to read the configuration file. logrus is used to log in this section. logrus is a structured logger with fully compatible API s with logger in standard libraries. Define configu ...

Posted by thegman on Thu, 03 Oct 2019 11:16:09 -0700

A pit of reference encountered in slice processing in golang

Two days ago, I encountered a pit when I was working on a sweeping robot algorithm. Part of the code is as follows: func move2(startPoint Point) [][]Point { allFootPrint := [][]Point{{startPoint}} for i := 0; i < N; i++ { allNewFootPrint := make([][]Point, 0) for len(allFootPrint) > 0 { curFootPrint := ...

Posted by MartinGr on Thu, 03 Oct 2019 08:43:57 -0700

How to publish your own code on Github for others to use

In daily development, we all use third-party libraries written by others, so we can also publish our code to github for others to use. First, we need to build a new warehouse named goutil and use public (private warehouse can't be seen by others!). Then clone goes to the local place. git clone https://github.com/startdusk/goutil.git Here we use ...

Posted by lisa71283 on Thu, 03 Oct 2019 07:05:40 -0700

Providing an external http interface API based on grpc through grpc-gateway

The advantages of grpc are no longer described, but how to provide Restful interface to the outside world and how to use grpc-gateway to convert grpc to Restful API when there is no desire to develop the same function repeatedly. install go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway go get -u github.com/micro/protobuf ...

Posted by kmussel on Mon, 30 Sep 2019 16:21:48 -0700

Go Language Processing JSON-Generating JSON String by Marshal

Using the encodong/json standard library built in Go language, we can easily generate and analyze data in JSON format. func Marshal(v interface{}) ([]byte, error) From the return value, we can see that the function has two return values, one is the json code of the incoming parameter v, the type is []b ...

Posted by newguy45 on Mon, 30 Sep 2019 08:24:51 -0700

Memory Cache Papers of Problems Easily Neglected in Beego

Preface When I blog based on beego, I encountered a strange problem: when using Memory Cache type caching, it's strange that the caching doesn't work, but it's okay to use redis. Because of the time problem, I didn't go deep into it. After all, at that time, I would actually use Memory as a cache. So I put it down, and today someone in the grou ...

Posted by Lord Sauron on Mon, 30 Sep 2019 01:32:45 -0700

Yitaifang Mining Source Code: clique Algorithms

Chain customer, specially for developers, there are questions to answer! This article is from Block Chain Technology Community No reprinting without permission. cliqueThe official consensus algorithm of ETF is ethash algorithm, which has been analyzed in detail in the previous article. It is based on POW consensus mechanism. Miners need to calc ...

Posted by rosegarden on Fri, 27 Sep 2019 02:29:28 -0700

How many pointers do you know in Go?

Pointer This chapter focuses on the application of string, number, array, slice, map, channel, structure and pointer assignment and function parameter transfer.   Character string The string itself is also the structure of StringHeader, which contains the Data pointer and string length, as follows type StringHeader struct { Data uin ...

Posted by mark_kccs on Mon, 23 Sep 2019 03:40:22 -0700

Rapid deployment of kubernetes cluster through RKE

RKE:Ranchar Kubernetes Engine https://github.com/rancher/rkeBecause RKE is written by golang, download the binary files of the corresponding system directly.Download address: https://github.com/rancher/rk... preparation in advance 1. Ubuntu 16.04.3 LTS version is recommended; if CentOS 7 is used, version 7.3 or more is recommended.2. The hostna ...

Posted by yame conoces on Sun, 15 Sep 2019 22:08:16 -0700

Go Language [Data Structure] Slice

Section brief introduction Simply put, slicing is a simplified version of a dynamic array. The length of the Go array cannot be changed, and the length of the slice is not fixed, so the length of the slice is naturally not a component of the type. Although arrays have something to do with them, the types and operations of arrays are not flexi ...

Posted by techmeister on Sun, 15 Sep 2019 02:47:49 -0700