1.创建数据库和表信息CREATEDATABASE yinzhengjie CHARSET utf8mb4; USE yinzhengjie;CREATETABLEusers( idBIGINT(20)PRIMARYKEY AUTO_INCREMENT COMMENT'用户ID', usernameVARCHAR(255)NOTNULLCOMMENT'用户名', passwordVARCHAR(255)NOTNULLCOMMENT'密码', status ENUM('active','inactive','deleted')NOTNULLDEFAULT...
(int(i)) // fast fmt.Sprint(i) // slow // int -> int64 ,不会丢失精度 var n int = 97 fmt.Println(int64(n) == int64(97)) // string -> float32/float64 https://yourbasic.org/golang/convert-string-to-float/ f := "3.14159265" if s, err := strconv.ParseFloat(f, 32); ...
typepstruct{idint32statusuint32// one of pidle/prunning/...schedtickuint32// incremented on every scheduler callsyscalltickuint32// incremented on every system callm muintptr// back-link to associated m (nil if idle)// Queue of runnable goroutines. Ac...
EnumInt仅允许[]int中的值 EnumInt32仅允许[]int32中的值 EnumInt64仅允许[]int64中的值 EnumFloat32仅允许[]float32中的值 EnumFloat64仅允许[]float64中的值 EnumStrSlice将数据转为[]string,并检查其元素是否存在于指定的[]string中 EnumIntSlice将数据转为[]int,并检查其元素是否存在于指定的[]int中 D...
type myintint//新类型type intalias =int//类型别名,所有使用intalias的地缝都可以使用int 引入类型别名的用途:1)在大规模重构项目代码的时候,尤其是将一个类型从一个包移动到另一个包中的时候,有些代码会使用新包中的类型,有些代码使用旧包中的类型,最典型的是context包。2)允许一个庞大的包分解成内部的...
// 定义一个 enum 常量 const ( Red = "red" Green = "green" Blue = "blue" ) func main() { // 将 enum 常量转换成字符串 color, _ := strconv.Itoa(int(Red)) fmt.Println(color) // 输出 "red" color, _ = strconv.Itoa(int(Green)) ...
第一章——基础概念:简述线程、协程及goroutine的基础概念,并进一步引出 gmp 架构 第二章——gmp详设:步入到源码中,对 gmp 底层数据结构设计进行一探究竟 第二部分则着眼于goroutine 的生命周期变化过程: 第三章——调度原理:以第一人称的正向视角,观察一个 g 是如何诞生以及被调度执行的 ...
数值,包含 double,float,int32,int64,uint32,uint64,sint32,sint64,fixed32,fixed64,sfixed32,sfixed64。 布尔bool 字符串 string 字节bytes 04 protobuf 字段规则 protobuf 字段规则有两个,单数(singular)和复数(repeated),必须满足其中一个,proto3 默认字段规则是单数。单数的意思是该字段只能出现 0 或 1...
package mainimport "fmt"func main() { // create unbuffered channel of int values with capacity of 1 ch := make(chan int) select { case ch <- 3: // uncomment the following line to get this program work // default: } fmt.Printf("ok\n")}fatal error: all goroutines are asleep -...
message Person { required string name = 1; required int32 id = 2; optional string email = 3;enumPhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { required string number = 1; optional PhoneType type = 2 [default = HOME]; } repeated PhoneNumber phone = 4;}pro...