beego阅读源码走通数据库的初始化
摘要:一般初始化数据库会在main的运行的时候第一步进行,常用的方式 dbhost := beego.AppConfig.String("dbhost") dbport := beego.AppConfig.String("dbport") dbuser := beego.AppConfig.String
阅读全文
posted @
2022-12-27 11:25
topass123
阅读(72)
推荐(0) 编辑
beego数据交互
摘要:模板引擎 指定模板:c.TplName = "index.tpl"默认支持tpl和htmlbeego.AddTemplateExt设置其他后缀beego.AddTemplateExt("后缀名")如果不设置该参数,那么默认会去到模板目录的 Controller/<方法名>.tpl 查找,例如上面的方
阅读全文
posted @
2022-12-26 17:47
topass123
阅读(44)
推荐(0) 编辑
beego
摘要:什么是beego beego时基于mvc架构实现的web框架 beego的优势 语言层面支持并发内置强大的插件部署简单智能化,可以监控cpu,memory,goroutin强大的网络库
阅读全文
posted @
2022-12-26 17:03
topass123
阅读(39)
推荐(0) 编辑
go的sort包
摘要:基础方法调用 package main import ( "fmt" "sort" ) func main() { intList := [] int {2, 4, 3, 5, 7, 6, 9, 8, 1, 0} float8List := [] float64 {4.2, 5.9, 12.3, 1
阅读全文
posted @
2022-12-25 00:41
topass123
阅读(32)
推荐(0) 编辑
go正则
摘要:常用方法,实话说没有python的正则丰富 package main import ( "fmt" "regexp" ) func main() { reg, _ := regexp.Compile("[1,3,5,8,6]{3}[0-9]{8}") res := reg.FindAll([]byt
阅读全文
posted @
2022-12-20 01:03
topass123
阅读(72)
推荐(0) 编辑
服务发现
摘要:启动服务consul_conf的json文件看https://www.cnblogs.com/topass123/p/16993018.html consul agent -server -dev -ui -client 0.0.0.0 -config-dir=C:\Users\86185\go\c
阅读全文
posted @
2022-12-19 20:39
topass123
阅读(16)
推荐(0) 编辑
文件形式服务注册
摘要:编写json文件 { "service":{ "id": "hello", "name": "hello", "address": "127.0.0.1", "port": 8080, "tags": ["uth","report"], "checks":[ { "tcp": "127.0.0.1:
阅读全文
posted @
2022-12-19 20:35
topass123
阅读(5)
推荐(0) 编辑
grpc
摘要:建立proto syntax = "proto3"; option go_package = ".;say"; package say; service SayService{ rpc SayHello(sayRequest)returns(sayResponse){} } message sayR
阅读全文
posted @
2022-12-19 16:10
topass123
阅读(10)
推荐(0) 编辑
rpc
摘要:暂时忽略rpc的安装问题 构建rpc-server package main import ( "fmt" "net" "net/http" "net/rpc" ) type User struct { } func (u *User) GetUser(name string, out_data *
阅读全文
posted @
2022-12-19 12:09
topass123
阅读(11)
推荐(0) 编辑
time
摘要:时间类型 // timeDemo 时间对象的年月日时分秒 func timeDemo() { now := time.Now() // 获取当前时间 fmt.Printf("current time:%v\n", now) year := now.Year() // 年 day := now.Day
阅读全文
posted @
2022-12-17 23:08
topass123
阅读(227)
推荐(0) 编辑
strconv
摘要:strconv与之前的strings有本质的区别。他不仅仅局限于字符本身的功能与字节的转化,还提供可int,bool的多种数据类型的解析 string 与 int 类型之间的转换 Atoi():字符串转整型 Itoa():整型转字符串 Parse 系列函数 Parse 系列函数用于将字符串转换为指定
阅读全文
posted @
2022-12-17 22:56
topass123
阅读(23)
推荐(0) 编辑
文件读写io/bufio/os/ioutil
摘要:os package main import ( "log" "os" ) func main() { // 1.文件的基础操作,create/open/close/chmod -> go/io库 f, err := os.Create("create.txt") if err != nil { l
阅读全文
posted @
2022-12-17 22:28
topass123
阅读(25)
推荐(0) 编辑
json
摘要:json的序列化【本质是转化为可传输的二进制】 type Monster struct { Name string //如果改成小写,序列化时跨包会丢掉此字段 Age int `json:"age"` //代表json过后的重命名 Score float64 } func testStruct()
阅读全文
posted @
2022-12-17 21:57
topass123
阅读(9)
推荐(0) 编辑
字符串与byte的使用
摘要:字符串涉及的用法strings 1)统计 strings.Count 2)替换 strings.Replace() 3)组合 strings.Join() 4)清洗 strings.Trim() 5)查找子串 strings.Index();strings.Contains() 6)分割 strin
阅读全文
posted @
2022-12-17 21:46
topass123
阅读(62)
推荐(0) 编辑