message Sheet {
string sheet_name=1;
repeated Line lines=2;
}
message Line {
repeated Cell cells=1;
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
var wg sync.WaitGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
ch := make(chan int, 4) | |
go write(ch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package goroutinetimeout | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"testing" | |
"time" | |
"proto/bi/service/olap/service" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func spectreCase() error { | |
host := os.Getenv("SPECTRE_HOST") | |
key := os.Getenv("SPECTRE_KEY") | |
secret := os.Getenv("SPECTRE_SECRET") | |
if host == "" || key == "" || secret == "" { | |
fmt.Println("Error 环境变量SPECTRE_HOST、SPECTRE_KEY、SPECTRE_SECRET均不能为空") | |
} | |
var bucketName = "venus-table-bucket-test" | |
//var bucketName = "venus-table-bucket" //online |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SendEmail 发送邮件 | |
func SendEmail(conf *EmailConfig) error { | |
m := gomail.NewMessage() | |
m.SetHeader("From", conf.From) | |
m.SetHeader("To", conf.To...) | |
m.SetHeader("Subject", conf.Subject) | |
if conf.ContentType == EmailTextType { | |
m.SetBody("text/plain", conf.ContentBuffer.String()) | |
} else if conf.ContentType == EmailHTMLType { | |
m.SetBody("text/html", conf.ContentBuffer.String()) |
// UpsertByDwIndicatorID 创建或者更新,返回最新的数据
func UpsertByDwIndicatorID(d *model.BiIndicator) error {
var err error
if nil == d || 0 == d.DwIndicatorID {
return errors.New("UpsertByDwIndicatorID error: BiIndicator nil or DwIndicatorID value is empty")
}
if _, err := QueryOne([]basemodel.Pair{
{K: "dw_indicator_id", V: d.DwIndicatorID},
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
数据库相关查询优化 | |
1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。 | |
2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如: | |
select id from t where num is null | |
可以在num上设置默认值0,确保表中num列没有null值,然后这样查询: | |
select id from t where num=0 | |
3.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索引而进行全表扫描。 | |
4.应尽量避免在 where 子句中使用 or 来连接条件,否则将导致引擎放弃使用索引而进行全表扫描,如: | |
select id from t where num=10 or num=20 |
goroutine 和协程的区别?
备注:需要区分进程、线程(内核级线程)、协程(用户级线程)三个概念。
-
- 进程、线程、协程概念性区别 对于进程、线程,都是有内核进行调度,有CPU时间片的概念,进行抢占式调度(有多种调度算法)。
对于协程(用户级线程),这是对内核透明的,也就是系统并不知道有协程的存在,是完全由用户的程序自己调度的,因为是由用户程序自己控制,那么就很难像抢占式调度那样做到强制的CPU控制权切换到其他进程/线程,通常只能进行协作式调度,需要协程自己主动把控制权转让出去之后,其他协程才能被执行到。
NewerOlder