摘要:type Student struct { Id int64 `gorm:"primary_key"` Name string `gorm:"column:name"` Age int `gorm:"column:age"` } func (Student) TableName() string {
阅读全文
摘要:序列化后输出。 package main import ( "encoding/json" "fmt" ) type Student struct { Age int Name string } func printStructPointerSlice(data interface{}) strin
阅读全文
摘要:InClusterConfig方法 package main import ( "context" "test/signals" "time" "os" core_v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1
阅读全文
摘要:kube-ovn v1.10.10 存活pod判断条件 pkg/controller/pod.goisPodAlive函数判断pod是否存活,pod从存活变成死亡后,该ip会分给其他pod。 3种ip分配方式 场景1:正常分配 pkg/ipam/subnet.gogetV4RandomAddress
阅读全文
摘要:watch用于观察内容变化,后面带要执行的命令。默认每2秒刷新一次。默认一直执行到用户ctrl+c为止,可通过timeout来控制超时时间。 参数含义-n 数字:指定刷新间隔。-d:高亮显示变化部分。 watch -d date
阅读全文
摘要:方式1:debug.Stack函数 调用runtime.Stack函数,无需指定参数,输出当前goroutine的栈信息。源码在runtime/debug/stack.go中: func Stack() []byte { buf := make([]byte, 1024) for { n := ru
阅读全文
摘要:场景1:连接db并访问 # 创建数据库表 .open test.db create table student(id int primary key not null, name char(10) not null, age int not null); # 下载go依赖 go get gorm.i
阅读全文
摘要:SQLite是本地数据库,没有后台进程,一般Linux默认安装了SQLite3。 # 创建数据库和表 # 显示字段名 .headers on # 每个字段占一行 .mode line # 列出所有表名 select name from sqlite_master where type = 'tabl
阅读全文
摘要:traceroute [ip地址],表示路由追踪该ip,结果出现星号表示没有正常获取到响应。 客户端每次发送TTL从1开始递增的端口3万以上的UDP报文,如果经过的下一跳会响应该报文场景1:没有到达最终节点,回复TTL超时的ICMP报文。场景2:到达最终节点,回复端口不可达的ICMP报文。 缺点1.
阅读全文
摘要:ovs端口模式 tag对应vlan id,取值范围是0-4095。 # 设置端口vlan模式(默认是access,还有trunk等) ovs-vsctl set port tap0 vlan_mode=access # 设置端口tag ovs-vsctl set port tap0 tag=101
阅读全文