Five mechanisms of Go error handling [Go language Bible notes]

Error handling strategy Error propagationretry Output the error and end the programOutput error messageIgnore directly When a function call returns an error, the caller should choose the appropriate way to handle the error. There are many processing methods according to different situations. Let's take a look at the five commonly used methods ...

Posted by dxdolar on Fri, 10 Sep 2021 06:22:24 +0200

node_exporter Embedding Custom Indicators

background In the monitoring alert project, prometheus and alertmanager are used to implement the monitoring alert. Common indicators such as cpu are monitored by node_exporter, network connectivity is monitored by blackbox_exporter, etc. In the actual test, different network interrupts are constructed and service interruptions are cumbersome. ...

Posted by riceje7 on Thu, 09 Sep 2021 18:31:31 +0200

Configuring Go Programming Environment for Linux Operating System

The operating system version for this article is CentOS-8.Ubuntu is the same. Install go [zy@study ~]$ cat /proc/version Linux version 4.18.0-305.12.1.el8_4.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)) #1 SMP Wed Aug 11 01:59:55 UTC 2021 Download go installation files Select the packa ...

Posted by discorevilo on Fri, 03 Sep 2021 21:50:13 +0200

cron of Go daily

brief introduction cron A library for managing timing tasks, using Go to achieve the effect of crontab command in Linux. We introduced a similar Go library before—— gron . gron code is small, which is better for learning. But its function is relatively simple, and it is no longer maintained. If there is a need for timed tasks, cron ...

Posted by vchris on Sat, 27 Jun 2020 09:10:13 +0200

Beego Learning Notes 15: Layout Page

Page Layout 1> An html page is made up of: head part, body part, internal css, internal js, external css, external js.Therefore, a layout file also needs to be split against these.     2> Create a new oneLayout.goController.Write an instance that references the layout file.The code is as follows: package controllers import ( "github.co ...

Posted by ReD_BeReT on Wed, 24 Jun 2020 18:17:42 +0200

Go Daily library twirp

brief introduction twirp Is a RPC framework based on Google Protobuf.Trp automatically produces server and client code by defining the service in the.proto file.Let's focus more on business logic.Huh?Isn't this gRPC?Unlike gRPC, which implements its own set of HTTP servers and network transport layers, twirp uses the standard library net/http.I ...

Posted by om.bitsian on Wed, 10 Jun 2020 19:04:20 +0200

Chinese processing of parameter verification error information

As we explained in the previous section, gin can use the ShouldBind method to bind parameters to a structure, but we don't cover how parameter checking works. In this section, we describe how parameter checking and checking fail and then convert to Chinese to return to the front end. 1. Data Validation Let's start with a simple example: Create ...

Posted by tsukushi on Mon, 08 Jun 2020 18:55:59 +0200

golang API request queue

outline Realization ideas usage method Start queue service Use queue service outline When a third-party API is called, there are basically restrictions on the access speed limit. When there are multiple third-party APIs, it is not good to control the access speed, which often leads to HTTP 429(Too Many Requests) and then it will be banne ...

Posted by SauloA on Sun, 31 May 2020 10:17:47 +0200

1. Basic use of reflection in Golang

Golang also provides reflection mechanism, like Java, which obtains information about objects at run time and updates their internal state; Golang obtains object types, field types and values, calls struct instance methods, updates instance values, and so on. _Go Gos The two most important objects and functions related to reflection in the refl ...

Posted by mistercoffee on Tue, 19 May 2020 19:19:09 +0200

LeetCode -- longest substring without duplicate characters

LeetCode -- longest substring without duplicate characters Blog Description The information in this article comes from the Internet and personal summary, which is intended to summarize personal learning and experience. If there is any infringement, please contact me to delete it. Thank you! Explain leetcode Question, Interview 48 The longest ...

Posted by calevans on Sun, 03 May 2020 05:39:23 +0200