Map In Golang

Introduction This article is mainly to learn and understand the characteristics of map by exploring the data structure and source code implementation of map in golang, containing a total of map’s model exploration, access, expansion, etc.. Map’s underlying memory model The underlying struct that represents map in golang’s source code is hmap, which is short for hashmap. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 type hmap struct { // The number of elements stored in the map, which is returned directly when len(map) is called in golang count int // The status marker bit, which can be used to determine whether or not the current status is in this state by performing & operations with the defined enumeration value flags uint8 B uint8 // 2^B denotes the number of buckets, B denotes the number of bits after the hash to group the buckets noverflow uint16 // Approximate number of overflow buckets hash0 uint32 // hash seed is generally a prime number buckets unsafe.

Forced deletion of Kubernetes Namespace

1. Preface I was using Kubernetes and had a problem with a Kubernetes NameSpace not being deleted properly. The NameSpace status had been in Terminating for quite a while, and I decided to force the NameSpace to be deleted. 2. Steps 1. View the existing NameSpace 1 2 3 4 5 6 7 8 [root@master ~]# kubectl get ns NAME STATUS AGE default Active 5h46m istio-system Terminating 11m kube-node-lease Active 5h46m kube-public Active 5h46m kube-system Active 5h46m kubernetes-dashboard Active 5h46m 2.

Implementation of string in libc++

std::string is probably one of the most common standard library data structures used by C++ programmers, how is std::string implemented internally after so long? What exactly is SSO (Small String Optimization)? I’ve recently become interested in the code of libc++, so I’ll use its implementation as an example to briefly answer the above questions. (Note that I have trimmed down the code shown a bit for ease of narration!) Internal structure My version of libc++ here is 37db2833.

Match-Case in Python 3.10

Preface Many Python core developers thought that Python didn’t need to add switch-case syntax, because you could do the same thing with if/elif/else. In fact, Guido himself wasn’t interested in this syntax either, so it wasn’t until Python 3.10 that a new match-case was added. This new syntax is called Structural Pattern Matching, and since there are a lot of new features, there are three PEPs to introduce it. PEP

Flannel for Cloud-Native Virtual Networks

When I used to look at k8s related knowledge, my network knowledge was relatively weak, so I didn’t understand the Flannel network. So recently I researched some knowledge of cloud-native virtual networks and wrote two articles: VXLAN Protocol for Cloud-Native Virtual Networks and Cloud-native virtual networking tun/tap & veth-pair which introduced some knowledge of virtual networks. These are all for flannel, and now we finally come to the Flannel article.

Inode in the Linux file system

File System The file system is the subsystem of the operating system responsible for managing persistent data. To put it simply, it is responsible for saving the user’s files to the disk hardware, because even if the computer loses power, the data in the disk is not lost, so the files can be saved persistently. The basic data unit of a file system is the file, and its purpose is to organize and manage the files on disk, and the different ways of organizing them result in different file systems.

Tekton Practices

Previously we explained the use of the Jenkins pipeline to implement CI/CD for Kubernetes applications, now we will migrate this pipeline to Tekton, in fact, the overall idea is the same, that is, to divide the entire workflow into different tasks to perform, the previous workflow stages are divided into the following stages: Clone code -> unit testing -> compile and package -> Docker image build/push -> Kubectl/Helm deployment services/.

Practices of multi-label based issue-driven software development

Software devours the world, open source devours software! The issue driven development model based on an issue tracking system has not only had a significant impact on the development process of open source systems, but more and more companies and organizations in the commercial software development space are also using the issue-driven development approach. For the issue mentioned here, we can’t just understand it as bug in the past, that would be too narrow and outdated.

Resetting the root password for MySQL8

This article explains how to set the initial root password of MySQL 8.0 in CentOS7 and how to reset the root password after forgetting it. 1. First login If MySQL is just installed, it will generate a random password in the log file by default, we can use it to login and reset the password. 1 2 3 4 $ sudo grep 'temporary password' /var/log/mysqld.log 2019-11-22T16:40:10.133730Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >KG6Ybt3%lgo $ mysql -u root -p Enter password: To reset the password you can use the following command.

Using ntfsfix to solve the problem of not being able to mount NTFS drives under Linux

Use ntfsfix to solve the problem of not being able to mount NTFS hard disk under Linux, mainly by the problem of $MFT file of hard disk partition, you can use chkdsk command under windows or use ntfsfix under Linux to fix it. First the failure details. 1 2 3 4 5 6 7 8 9 10 $ sudo mount /dev/sda1 $MFTMirr does not match $MFT (record 3). Failed to mount '/dev/sda1': Input/output error NTFS is either inconsistent, or there is a hardware fault, or it's a SoftRAID/FakeRAID hardware.

Managing Jenkins build nodes with Kubernetes' built-in PodTemplate

Jenkins integrates well with Kubernetes, whether it’s a controller or a build node (agent) running as a Pod on Kubernetes. Anyone familiar with Jenkins knows that Jenkins supports multiple types of build nodes, such as fixed configuration and dynamic configuration. The way nodes connect to the controller includes JNLP, SSH, and so on. For those who are already fully embracing container technology, most of them use build nodes by connecting to Kubernetes clusters and dynamically starting and destroying Pods.

Understanding the ECMAScript Advanced Syntax Compilation and Helper Handling Scheme from the tsconfig parameter importHelpers

1 Introduction to TypepScript Syntax Compilation and Helper Functions Using TypepScript’s built-in tsc tool, you can translate ts source files into standard JavaScript code files. The configuration file tsconfig.json can be used to configure the specific scheme of tsc compilation. The tsc compilation parameter target specifies the language standard version of the output, so in practice it can also be used as a tool to translate higher versions of ECMAScript source code to lower versions.

React: useNavigate() may be used only in the context of a Router component

When we try to use the useNavigate hook outside the Router context of a react router, we get the warning “useNavigate() may be used only in the context of a Router component”. To fix this issue, you can only use the useNavigate hook in the Router context. Here is an example of wrapping a React application in a Router in the index.js file. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // index.

Caddy, an out-of-the-box web server

As we all know, the Web server is an indispensable basic service for Web development and is often used in development. Familiar open source Web servers are the well-known Apache, the powerful Nginx. The open source project we are going to introduce today is written in Go the up-and-coming “: Caddy It has a download without installation can be used, zero configuration to achieve HTTPS and other characteristics, so in

Quickly build new clusters on Kubernetes with Crossplane and VCluster

Crossplane is an open source Kubernetes plugin that solves the problem of provisioning cloud resources by extending the Kubernetes API. When using Crossplane, you can define declaratively what cloud resources need to be created for your application to work properly, without writing any code. The definition of these cloud resources can be done directly by creating the associated CRD objects, which can be thought of as a cloud-native version of Terraform.

Talking about gRPC's Trailers design

I’ve “critiqued” gRPC many times, and one of the most mysterious aspects of its complex design is its reliance on the trailers header. There is basically no information on the web about why gRPC uses trailers to pass status codes. I recently read an article by Carl Why Does gRPC Insist on Trailers?. Carl was a member of the gRPC R&D team and he Carl was part of the gRPC development team, and in this article he details the vision for designing gRPC and the process that led to it getting out of control.

Enable kvm nested virtualization on Linux

kvm supports nested virtualization, which means that virtual machines can be created within virtual machines. This article focuses on how to turn on kvm nested virtualization in CentOS 7 with Intel processors. kvm is mainly implemented through the kernel module, so we can check if kvm nested virtualization is enabled on our system by simply executing the following command and know if it is supported based on the output. 1 2 $ cat /sys/module/kvm_intel/parameters/nested N If not, we need to create a new kvm-nested.

The Sendfile command in nginx and how it works

This article explains the sendfile command in the http module in nginx and how it works. 1. Introduction to sendfile() The http module of nginx has a sendfile directive, which is on by default. The official website documentation explains it as follows. Enables or disables the use of sendfile(). Starting from nginx 0.8.12 and FreeBSD 5.2.1, aio can be used to pre-load data for sendfile(): 1 2 3 4 5 location /video/ { sendfile on; tcp_nopush on; aio on; } In this configuration, sendfile() is called with the SF_NODISKIO flag which causes it not to block on disk I/O, but, instead, report back that the data are not in memory.

Is Golang's Channel a free, lock-free implementation?

Today I saw a piece of code that exposes metrics with Prometheus’ client_go. Instead of simply inc()ing the corresponding metric counter, it implements a very strange logic of its own: when the program needs to add counter +1, it does not operate the corresponding metrics directly, but packages the metrics to be added in its own format and sends the object to a channel, each metric corresponds to a channel The program starts a globally unique worker goroutine at the beginning, which is responsible for all the metrics: it gets messages from different channels, unpacks them, finds the corresponding metrics that should be added, and then performs the final addition operation.

Does database MySQL need to be containerized?

Definition of Containers: Containers are designed to solve the problem of “how to ensure that the software can run properly when switching runtime environments”. Currently, containers and Docker are still the hottest words in the technology field, stateless services containerization has been the trend, but also brings a hot issue is debated by everyone: database MySQL need to be containerized? We carefully analyze the various views of everyone, and find that those who agree are only elaborating MySQL needs containerization from the perspective of container advantages, with little business scenarios to verify their views; on the other hand, if we look at the opponents, they elaborate MySQL does not need containerization from multiple factors such as performance and data security, and also cite some unsuitable business scenarios.