Logo ByteGopher
  • English
    中文
Logo Inverted Logo
  • Posts
  • Blog
  • CloudNative
  • Infrastructure
    • TimeSeriesDB
  • Kubernetes
  • Note C
  • Note Go
  • React
  • Tips
  • Nodus
  • Interview
  • Life
  • Linux
Hero Image

https://www.jianshu.com/p/a6c6f47a5ef7 https://blog.csdn.net/weixin_42096901/article/details/103017044 https://blog.csdn.net/weixin_39406430/article/details/123715072 http://t.zoukankan.com/yangyongjie-p-14576216.html https://zhuanlan.zhihu.com/p/430848775 https://blog.csdn.net/weixin_42340926/article/details/126211173

January 1, 0001 Read
Hero Image

1title: Linux Network Virtualization Network Namespace In order to provide the isolation, Linux has 6 namespaces to split the different resources, shown as follows: Namespace Description Mount Namespace File system mount point CLONE_NEWNET UTS Namespace Hostname CLONE_NETUTS IPC Namespace POSIX process messaging queue CLONE_NEWIPC PID Namespace Process PID number namespace CLONE_NEWPID Network Namespace IP address/Port/Router/IPtables CLONE_NEWNS User Namespace User isolation CLONE_NEWUSER For the process, if they want to use the resources of the Namespace, they should enter the namespace first.

January 1, 0001 Read
Hero Image

Hi, Kural, About the IPV6 SFC, the following is my debug process. Now, the func CalculateRoutes() can genarate the create route to the pod, but can’t add to the corresponding pod. The calculated result for the sfc-head pod: But for the agent pod, while adding routes to the container through func ContainerAddRoute() failed. Because in this function, it will get the host network configuration to find the default gateway, to add an extra route to the host network through the default gateway on the host.

January 1, 0001 Read
Hero Image

for containerd for crio for docker

January 1, 0001 Read
Hero Image

fork create process fork 被调用一次,可以返回两次。 在调用fork之后的代码会执行两次,一次在父进程中执行,返回的是创建成功的子进程的Id,一次是在子进程中执行,返回的是0;如果出现错误,fork返回的是负值。 1/*linux下:*/ 2 3#include <stdio.h> 4#include <unistd.h> 5 6int main() { 7 pid_t pid; 8 pid = fork(); 9 if(pid == 0) //返回子进程 10 { 11 printf("child pid: %d\n", getpid()); 12 } else { 13 printf("pid: %d\n", pid);//父进程中返回子进程的pid 14 printf("father pid: %d\n", getpid()); 15 } 16} 1pid: 2876921 2father pid: 2876920 3child pid: 2876921 fork的两种用法 父进程希望复制自己,使父子进程同时执行不同的代码段。 比如在网络服务程序中,父进程等待客户端的服务请求。当请求到达时,父进程调用fork()使子进程处理此请求;而父进程继续等待下一个请求。 一个进程要执行不同的程序 这个在shell下比较常见,这种情况下, fork()之后一般立即接exec函数。

January 1, 0001 Read
Hero Image

January 1, 0001 Read
Hero Image

类型 2.1 变量 标识符与关键字 标识符 在编程语言中标识符就是程序员定义的具有特殊意义的词,比如变量名、常量名、函数名等等。 Go语言中标识符由字母数字和_(下划线)组成,并且只能以字母和_开头。 举几个例子:abc, _, _123, a123。 关键字 关键字是指编程语言中预先定义好的具有特殊含义的标识符。 关键字和保留字都不建议用作变量名。 Go语言中有25个关键字: 1 break default func interface select 2 case defer go map struct 3 chan else goto package switch 4 const fallthrough if range type 5 continue for import return var 此外,Go语言中还有37个保留字。 1 Constants: true false iota nil 2 3 Types: int int8 int16 int32 int64 4 uint uint8 uint16 uint32 uint64 uintptr 5 float32 float64 complex128 complex64 6 bool byte rune string error 7 8 Functions: make len cap new append copy close delete 9 complex real imag 10 panic recover go 语言中的变量必须先声明再使用。

January 1, 0001 Read
Hero Image

流程控制 if…else 1package main 2 3import "fmt" 4 5func main() { 6 var number int = 5 7 if number += 4; 10 > number { 8 number :=0 9 number += 3 10 fmt.Print(number) 11 } else if 10 < number { 12 number -= 2 13 fmt.Print(number) 14 } 15 fmt.Println(number) 16} 17 18// 39

January 1, 0001 Read
Hero Image

函数 现代计算机的进程执行模型大部分是基于“堆栈”的,编译器不需要对函数做过多的转换就能让其在栈上运行 2.1 基本概念 2.1.1 函数定义 一个函数的定义包含如下几个部分: 函数声明关键字func、函数名、参数列表、返回列表和函数体。 首字母的大小写决定该函数在其他包的可见:大写时其他包可见,小写时只有相同的包可以访问。 函数可以没有输入参数、也可以没有返回值(默认返回0) 1func A(){ 2} 3 4func B() int{ 5 return 1 6} 多个相同类型的参数可以使用简写模式 1func add(a,b int) int{ // a int, b int 简写为 a,b int 2 return a+b 3} 支持有名的返回值,参数名相当于函数体最外层的局部变量,命名返回值变量会被初始化为类型零值最后的return可以不带参数名直接返回。 1func add(a,b int) (sum int){ // sum 相当于函数内部的局部变量,被初始化为0 2 sum = a+b 3 return // return sum 的简写模式 4 5 // sum := a+b 6 // return sum // 需要显式的调用return sum 7} 不支持默认值参数??

January 1, 0001 Read
Hero Image

Go并发编程案例解析 nginx influxdb 时序数据库 Prometheus Grafana 实例代码 https://github.com/itsmikej/imooc_logprocess 常见的并发模型 进程&线程 Apache C10K 服务器要同时支持10K的并发连接 异步非阻塞 (Nginx,Libevent, NodeJs)epoll 复杂度高 协程 GoLang, Erlang, Lua Golang并发实现 程序并发执行 goroutine 多个goroutine间的数据同步通信channels 多个channel选择数据读取或者写入select Goroutines Goroutines 程序并发执行 1foo() // 执行函数foo, 程序等待函数foo返回 2go foo() // 执行函数foo 3bar() // 不用等待foo返回 Channels Channels多个goroutine间的数据通信与同步 1c := make(chan string) // 创建一个channel 2go func(){ 3 time.Sleep(1*time.Second) 4 c <- "message from closure" // 发送数据到channel 中 5}() 6 7msg:=<- c // 阻塞直到接收到数据 Select Select 从多个Channel 中读取或写入数据

January 1, 0001 Read
Hero Image

软件开发的新挑战 多核硬件架构 超大规模分布式计算集群 web模式下导致的前所未有的规模和更新速度 区块链开发语言, Kubernetes Docker 只有25个关键字 有垃圾回收机制,但是仍然可以直接使用指针访问内存 CSP并发机制 关键字 c 37 c++ 11 84 go 25 go 垃圾回收,使用指针直接内存访问. 复合和继承 docker kubernetes go 默认使用静态连接,编译完成是一个独立的二进制 1package main // package name 2 3import "fmt" // dependence 4 5// functionality 6func main() { 7 fmt.Print("hello world \n") 8} 应用程序入口, 必须是main包 package main 必须是main方法 func main() 文件名不一定是main.go package 的名字不需要与目录保持一致 退出返回值 与其他主要编程语言的差异 Go main函数不支持任何返回值 通过os.Exit 来返回状态 1package main 2 3import ( 4 "fmt" 5 "os" 6) 7 8func main() { 9 fmt.

January 1, 0001 Read
Hero Image

1package dal 2 3import "testing" 4 5func Empty() { 6 str := "12312" 7 if str == "" { 8 9 } 10} 11func Lenzero() { 12 str := "" 13 if len(str) == 0 { 14 15 } 16} 17func BenchmarkEmpty(b *testing.B) { 18 for n := 0; n < b.N; n++ { 19 Empty() 20 } 21} 22 23func BenchmarkLenzero(b *testing.B) { 24 for n := 0; n < b.

January 1, 0001 Read
  • ««
  • «
  • 9
  • 10
  • 11
  • 12
  • 13
  • »
  • »»
Navigation
  • About
  • Skills
  • Recent Posts
  • My Story
Contact me:
  • renqiqiang@outlook.com

Stay up to date with email notification

By entering your email address, you agree to receive the newsletter of this website.

Toha Theme Logo Toha
© 2020-2022 Copyright.
Powered by Hugo Logo