From 6332daef316c39e0d587c6699ed3e74f9927101b Mon Sep 17 00:00:00 2001 From: yuzhiquan Date: Thu, 14 May 2020 18:20:32 +0800 Subject: [PATCH] struct instead of int within signal chan, and trans Printf to Println Signed-off-by: yuzhiquan --- src/cmd/migrate-patch/main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/migrate-patch/main.go b/src/cmd/migrate-patch/main.go index f5da0f0f7..b5d5541aa 100644 --- a/src/cmd/migrate-patch/main.go +++ b/src/cmd/migrate-patch/main.go @@ -33,14 +33,14 @@ func main() { log.Fatalf("Failed to connect to Database, error: %v\n", err) } defer db.Close() - c := make(chan int, 1) + c := make(chan struct{}, 1) go func() { err := db.Ping() for ; err != nil; err = db.Ping() { - log.Printf("Failed to Ping DB, sleep for 1 second.\n") + log.Println("Failed to Ping DB, sleep for 1 second.") time.Sleep(1 * time.Second) } - c <- 1 + c <- struct{}{} }() select { case <-c: @@ -54,11 +54,11 @@ func main() { log.Fatalf("Failed to check schema_migrations table, error: %v \n", err) } if tblCount == 0 { - log.Printf("schema_migrations table does not exist, skip.\n") + log.Println("schema_migrations table does not exist, skip.") return } if colCount > 0 { - log.Printf("schema_migrations table does not require update, skip.\n") + log.Println("schema_migrations table does not require update, skip.") return } if _, err := db.Exec(pgSQLDelRows); err != nil { @@ -67,5 +67,5 @@ func main() { if _, err := db.Exec(pgSQLAlterStmt); err != nil { log.Fatalf("Failed to update database, error: %v \n", err) } - log.Printf("Done updating database. \n") + log.Println("Done updating database.") }