• File basic operation


    Read the entire file Reading the entire file into memory is one of the most basic file operations. This needs to be usedioutilIn the bagReadFileFunction. package main import ( “flag” “fmt” “io/ioutil” ) func main() { fptr := flag.String (“path”, ” test.txt Path of the file to be read) flag.Parse() data, err := ioutil.ReadFile(*fptr) if […]

  • Golang implements switch operation through SSH


    Simple implementation, through input instructions, two-step execution of switch commands. Enter the account number and password for the replacement. Multiple accounts and passwords can be input at one time. In order to facilitate operation, the input format is specified. Such as user name; host IP; password | user name; host IP; password. For example, admin; […]

  • Gin framework series 04: interesting discussion on parameter binding and verification


    Reading guide In the second section, we learned the routing definition and parameter reception of gin framework. Today, we will explain the binding and verification of parameters according to a student’s request. Why check parameters? I don’t have to ask this question, but I’d like to explain it here. Suppose to do a registration interface, […]

  • Golang implements single sign on system (go SSO)


    This is a single sign on system based on go language, which realizes mobile number registration, mobile number + verification code login, mobile number + password login, account logout and other functions. User authentication adopts cookie and JWT. The related methods of sending and receiving SMS have been provided, and only need to make corresponding […]

  • Implementation of golang operation elasticsearch


    1. Premise 1.1 docker installation elasticsearch Query elasticsearch version docker search elasticsearch Pull the corresponding version to local Create a network docker network create esnet Start container docker run –name es -p 9200:9200 -p 9300:9300 –network esnet -e “discovery.type=single-node” bdaab402b220 1.2 after that, you can write go code. For intuitive visualization, elistichd is deployed […]

  • Go language foundation (1)


    Go language foundation (1) package Package call Go programs are organized through packages.Only source files with package name main can contain the main function.Executable programs have and only one main package.Import other non main packages through the import keyword.You can import by using the import keyword: import “fmt” mport “io” You can also import more […]

  • [go] Pointer


    1、 Three pointer types Normal pointer* Non type safe pointer unsafe.Pointer (similar to Cvoid*) Built in type pointer uintpter (in fact, it is an integer, representing the address, supporting operation) graph LR Normal pointer and unsafe.Pointer Type pointers can represent references to an address and are found by GC. But uintptr does not refer to […]

  • Golang performance test (1) benchmark performance test


    This paper introduces how golang does benchmark performance testing. After writing the code, in addition to running the necessary unit tests, we also need to consider the performance of the code. Performance measurement is actually the memory allocation and CPU consumption of the process when the program is running. Based on the function test provided […]

  • Golang — in-depth introduction, take you to use the reflection of golang to a common background query method


    Some basic methods This article will not introduce the basic concepts and principles of reflection, and will explain some basic and advanced uses from each common method. Reflection is not suitable for use in the business layer because it will reduce the running speed geometrically, and the robustness of the program made by reflection is […]

  • Read goroutine and channel


    Open source library “go home” focuses on go language technology stack and interview questions to help gopher step onto a bigger stage. Welcomego home~ Background As we all know, process is the basic unit of operating system resource allocation. It has independent memory space, and threads can share the memory space of the same process. […]

  • Basic usage and underlying principles of [go] map


    1. Basic use of map Map declaration Var M4 map [int] int // just declare that there is no open space M4 [1] = 100 // error reported log.Println(m4) establish //1 M3: = make (map [int] string, 100) // length can be specified log.Println (len (M3)) // 0 number of key value pairs M2: = […]

  • Detailed explanation of pointer


    A pointer is a value representing a memory address, which is often the starting position of the value of another variable stored in memory Go language supports pointer between Java language and C / C + + language. It does not cancel the direct operation ability of code to pointer like Java, but also avoids […]