本文整理汇总了Golang中github.com/jingweno/gotask/tasking.T.Errorf方法的典型用法代码示例。如果您正苦于以下问题:Golang T.Errorf方法的具体用法?Golang T.Errorf怎么用?Golang T.Errorf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jingweno/gotask/tasking.T
的用法示例。
在下文中一共展示了T.Errorf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TaskCrossCompile
// Cross-compiles gh for current operating system.
//
// Cross-compiles gh for current operating system. The build artifacts will be in target/VERSION
func TaskCrossCompile(t *tasking.T) {
t.Log("Updating goxc...")
err := t.Exec("go get -u github.com/laher/goxc")
if err != nil {
t.Errorf("Can't update goxc: %s\n", err)
return
}
t.Logf("Cross-compiling gh for %s...\n", runtime.GOOS)
err = t.Exec("goxc", "-wd=.", "-os="+runtime.GOOS, "-c="+runtime.GOOS)
if err != nil {
t.Errorf("Can't cross-compile gh: %s\n", err)
return
}
}
示例2: TaskGitHubUser
// NAME
// gh-user - Get URL for a given GitHub user login
//
// DESCRIPTION
// Given a GitHub user login, call the GitHub API to get this user and print out the user page URL.
//
// For example
//
// $ gotask git-hub-user jingweno
//
// OPTIONS
// --verbose, -v
// run in verbose mode
func TaskGitHubUser(t *tasking.T) {
if len(t.Args) == 0 {
t.Error("No GitHub user login is provided!")
return
}
login := t.Args[0]
data, err := fetchGitHubUser(login)
if err != nil {
t.Error(err)
return
}
url, ok := data["html_url"]
if !ok {
t.Errorf("No URL found for user login %s\n", login)
return
}
t.Logf("The URL for user %s is %s\n", login, url)
}
示例3: TaskCrossCompileAll
// Cross-compiles gh for all supported platforms.
//
// Cross-compiles gh for all supported platforms. The build artifacts
// will be in target/VERSION. This only works on darwin with Vagrant setup.
func TaskCrossCompileAll(t *tasking.T) {
t.Log("Removing build target...")
err := os.RemoveAll("target")
if err != nil {
t.Errorf("Can't remove build target: %s\n", err)
return
}
// for current
t.Logf("Compiling for %s...\n", runtime.GOOS)
TaskCrossCompile(t)
if t.Failed() {
return
}
// for linux
t.Log("Compiling for linux...")
err = t.Exec("vagrant ssh -c 'cd ~/src/github.com/jingweno/gh && git pull origin master && gotask cross-compile'")
if err != nil {
t.Errorf("Can't compile on linux: %s\n", err)
return
}
}
示例4: testInsert
// testInsert checks SQL statements generated from Go model.
func testInsert(t *tasking.T, db *sql.DB, eng modsql.Engine) {
modsql.InitStatements(db, eng, model.Insert)
defer func() {
if err := modsql.CloseStatements(); err != nil {
t.Error(err)
}
}()
// insert inserts data without transaction
insert := func(model modsql.Modeler) {
if _, err := model.StmtInsert().Exec(model.Args()...); err != nil {
t.Error(err)
}
}
// To remove nanoseconds in timestamps since the drivers return fewer digits.
nsec := regexp.MustCompilePOSIX(`\.[0-9]+ \+`)
// scan checks that output data is the same than input data.
scan := func(query string, input, output modsql.Modeler) {
rows := db.QueryRow(modsql.SQLReplacer(eng, query))
if err := rows.Scan(output.Args()...); err != nil {
t.Errorf("query: %q\n%s", query, err)
} else {
in := fmt.Sprintf("%v", input)
out := fmt.Sprintf("%v", output)
if strings.Contains(out, "UTC") { // Field DateTime
in = nsec.ReplaceAllLiteralString(in, " +")
out = nsec.ReplaceAllLiteralString(out, " +")
}
if in != out {
t.Errorf("got different data\ninput: %v\noutput: %v\n", in, out)
}
}
}
// Transaction
inputTx := &model.Catalog{0, "a", "b", 1.32}
err := insertFromTx(db, inputTx)
if err != nil {
modsql.CloseStatements()
t.Error(err)
}
scan("SELECT * FROM catalog WHERE catalog_id = 0", inputTx, &model.Catalog{})
// Check data input from SQL files
inputTypes := &model.Types{0, 8, 16, 32, 64, 1.32, 1.64, "one", []byte("12"), 'A', 'Z', true}
scan("SELECT * FROM types WHERE int_ = 0", inputTypes, &model.Types{})
inputDef := &model.Default_value{0, 10, 10.10, "foo", []byte{'1', '2'}, 'a', 'z', false}
scan("SELECT * FROM default_value WHERE Id = 0", inputDef, &model.Default_value{})
inputTimes0 := &model.Times{0, time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)}
scan("SELECT * FROM times WHERE typeId = 0", inputTimes0, &model.Times{})
if inputTimes0.Datetime.IsZero() {
t.Error("inputTimes0.Datetime: should not be zero:", inputTimes0.Datetime)
}
inputTimes1 := &model.Times{1, time.Time{}}
scan("SELECT * FROM times WHERE typeId = 1", inputTimes1, &model.Times{})
if !inputTimes1.Datetime.IsZero() {
t.Error("inputTimes1.Datetime: should be zero:", inputTimes1.Datetime)
}
// Direct insert
input0 := &model.Types{1, 8, -16, -32, 64, -1.32, -1.64, "a", []byte{1, 2}, 8, 'r', true}
insert(input0)
scan("SELECT * FROM types WHERE int_ = 1", input0, &model.Types{})
input1 := &model.Default_value{1, 8, 1.32, "a", []byte{1, 2}, 8, 'r', false}
insert(input1)
scan("SELECT * FROM default_value WHERE id = 1", input1, &model.Default_value{})
input2 := &model.Times{2, time.Now().UTC()}
insert(input2)
scan("SELECT * FROM times WHERE typeId = 2", input2, &model.Times{})
if input2.Datetime.IsZero() {
t.Error("input2.Datetime: should not be zero:", input2.Datetime)
}
input3 := &model.Account{11, 22, "a"}
insert(input3)
scan("SELECT * FROM account WHERE acc_num = 11", input3, &model.Account{})
input4 := &model.Sub_account{1, 11, 22, "a"}
insert(input4)
scan("SELECT * FROM sub_account WHERE sub_acc = 1", input4, &model.Sub_account{})
input5 := &model.Catalog{33, "a", "b", 1.32}
insert(input5)
scan("SELECT * FROM catalog WHERE catalog_id = 33", input5, &model.Catalog{})
//.........这里部分代码省略.........