示例#1
0
文件: GoRun.go 项目: keysonZZZ/kmg
func mustCheckSumFile(path string) uint64 {
	content, err := kmgFile.ReadFile(path)
	if err != nil {
		panic(err)
	}
	return xxhash.Checksum64(content)
}
示例#2
0
func TestGoTpl(ot *testing.T) {
	MustBuildTplInDir("testFile")
	files := kmgFile.MustGetAllFiles("testFile")
	AllCurrect := true
	ErrorMsg := ""
	for _, file := range files {
		if filepath.Ext(file) != ".gotplhtml" {
			continue
		}
		generated := kmgFile.MustReadFile(filepath.Join(filepath.Dir(file), kmgFile.GetFileBaseWithoutExt(file)+".go"))
		correct, err := kmgFile.ReadFile(filepath.Join(filepath.Dir(file), kmgFile.GetFileBaseWithoutExt(file)+".go.good"))
		if err != nil {
			ErrorMsg += fmt.Sprintf("%s read good file fail err [%s]\n", file, err)
			AllCurrect = false
			continue
		}
		if !bytes.Equal(generated, correct) {
			ErrorMsg += fmt.Sprintf("%s generated not equal correct\n", file)
			AllCurrect = false
			continue
		}
	}
	if !AllCurrect {
		panic(ErrorMsg)
	}
}
示例#3
0
文件: GoRun.go 项目: keysonZZZ/kmg
func checkFileWithMd5(path string, shouldMd5 uint64) (ok bool) {
	content, err := kmgFile.ReadFile(path)
	if err != nil {
		if !os.IsNotExist(err) {
			panic(err)
		}
		return false
	}
	return xxhash.Checksum64(content) == shouldMd5
}
示例#4
0
文件: Kvdb.go 项目: keysonZZZ/kmg
// 如果没有数据会返回nil
func MustKvdbGetBytes(s string) (b []byte) {
	key := kmgCrypto.Md5Hex([]byte(s))
	content, err := kmgFile.ReadFile(kmgConfig.DefaultEnv().PathInTmp("kvdb/" + key))
	if err != nil {
		if os.IsNotExist(err) {
			return nil
		}
		panic(err)
	}
	return content
}