本文整理汇总了Golang中github.com/asiainfoLDP/datahub/utils/clog.Println函数的典型用法代码示例。如果您正苦于以下问题:Golang Println函数的具体用法?Golang Println怎么用?Golang Println使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Println函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getBatchDelTagsName
func getBatchDelTagsName(reponame, itemname, tagname string) ([]string, error) {
log.Println("Batch delete tags from db")
sqlrpdmid := fmt.Sprintf(`SELECT RPDMID FROM DH_DP_RPDM_MAP WHERE REPOSITORY='%s' AND DATAITEM='%s' AND STATUS='A';`, reponame, itemname)
var rpdmId int
row, err := g_ds.QueryRow(sqlrpdmid)
if err != nil {
l := log.Error("select rpdmid from DH_DP_RPDM_MAP error:", err)
logq.LogPutqueue(l)
return nil, err
}
row.Scan(&rpdmId)
tagname = strings.Replace(tagname, "*", "%", -1)
log.Println(tagname)
sql := fmt.Sprintf(`SELECT TAGNAME FROM DH_RPDM_TAG_MAP WHERE TAGNAME LIKE '%s' AND RPDMID=%d AND STATUS='A';`, tagname, rpdmId)
//var tagnames []string
tagsname := make([]string, 0)
rows, err := g_ds.QueryRows(sql)
if err != nil {
l := log.Error("batch delete tag from DH_RPDM_TAG_MAP error:", err)
logq.LogPutqueue(l)
return nil, err
}
for rows.Next() {
rows.Scan(&tagname)
tagsname = append(tagsname, tagname)
}
log.Println(tagsname)
/*if len(tagsname) == 0 {
return nil, errors.New("没有匹配的tag")
}*/
return tagsname, nil
}
示例2: DeleteItemOrTag
func DeleteItemOrTag(repo, item, tag string) (err error) {
uri := "/repositories/"
if len(tag) == 0 {
uri = uri + repo + "/" + item
} else {
uri = uri + repo + "/" + item + "/" + tag
}
log.Println(uri)
req, err := http.NewRequest("DELETE", DefaultServerAPI+uri, nil)
if len(loginAuthStr) > 0 {
req.Header.Set("Authorization", loginAuthStr)
}
if err != nil {
return err
}
//req.Header.Set("User", "admin")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
return nil
} else {
body, _ := ioutil.ReadAll(resp.Body)
log.Println(resp.StatusCode, string(body))
return errors.New(fmt.Sprintf("%d", resp.StatusCode))
}
return err
}
示例3: GetTagComment
func GetTagComment(repo, item, tag string) string {
path := "/api/repositories/" + repo + "/" + item + "/" + tag
resp, err := commToServerGetRsp("get", path, nil)
if err != nil {
log.Error(err)
return ""
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusBadRequest {
err = errors.New("unkown error")
log.Error("GET", path, resp.StatusCode)
return ""
}
result := ds.Response{}
struComment := &struct {
Comment string `json:"comment"`
}{}
result.Data = struComment
respbody, _ := ioutil.ReadAll(resp.Body)
log.Println(string(respbody))
unmarshalerr := json.Unmarshal(respbody, &result)
if unmarshalerr != nil {
log.Error(unmarshalerr)
return ""
}
log.Println(result)
return struComment.Comment
}
示例4: checkAccessToken
func checkAccessToken(tokenUrl string) (bool, string) {
log.Println("daemon: connecting to", DefaultServerAPI+tokenUrl)
req, err := http.NewRequest("GET", DefaultServerAPI+tokenUrl, nil)
if len(loginAuthStr) > 0 {
req.Header.Set("Authorization", loginAuthStr)
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return false, ""
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
type tokenDs struct {
Valid bool `json:"valid"`
}
tkresp := tokenDs{}
result := &ds.Result{Data: &tkresp}
if err = json.Unmarshal(body, &result); err != nil {
log.Println(err)
return false, ""
}
log.Trace(string(body))
return tkresp.Valid, result.Msg
}
示例5: RollBackTag
func RollBackTag(repo, item, tag string) {
//Delete /repository/repo/item tag
log.Println(repo, "/", item, ":", tag)
err := DeleteItemOrTag(repo, item, tag)
if err != nil {
log.Println("DeleteTag err ", err.Error())
}
}
示例6: RollBackItem
func RollBackItem(repo, item string) {
//Delete /repository/repo/item
log.Println(repo, "/", item)
err := DeleteItemOrTag(repo, item, "")
if err != nil {
log.Println("DeleteItem err ", err.Error())
}
}
示例7: rollbackDelTag
func rollbackDelTag(tagid int) error {
log.Println("TODO rollback delete tag from db")
log.Println(tagid)
sql := fmt.Sprintf(`UPDATE DH_RPDM_TAG_MAP SET STATUS='A' WHERE TAGID=%d`, tagid)
_, err := g_ds.Update(sql)
if err != nil {
l := log.Error("rollback delete tag error:", err)
logq.LogPutqueue(l)
return err
}
return nil
}
示例8: GetDataPoolStatusByID
func GetDataPoolStatusByID(dpid int) (status string) {
sqlGetDpStatus := fmt.Sprintf("SELECT STATUS FROM DH_DP WHERE DPID=%d", dpid)
row, err := g_ds.QueryRow(sqlGetDpStatus)
if err != nil {
log.Println(sqlGetDpStatus)
log.Println(err.Error())
return
}
row.Scan(&status)
if status != "A" {
log.Println("dpid:", dpid, " status:", status)
}
return
}
示例9: GetSampleData
func GetSampleData(itempath string) (sample string) {
var filename string
for _, v := range SampleFiles {
filename = itempath + "/" + v
if isFileExists(filename) == true {
if bytes, err := ioutil.ReadFile(filename); err == nil {
sample = string(bytes)
return sample
} else {
l := log.Error(err)
logq.LogPutqueue(l)
}
}
}
d, err := os.Open(itempath) //ppen dir
if err != nil {
log.Println(err)
return ""
}
defer d.Close()
ff, _ := d.Readdir(10) // return []fileinfo
for i, fi := range ff {
log.Printf("sample filename %d: %+v\n", i, fi.Name())
filename = strings.ToLower(fi.Name())
if filename != "sample.md" && filename != "meta.md" && filename != PriceFile {
f, err := os.Open(itempath + "/" + fi.Name())
log.Println("filename:", itempath+"/"+fi.Name())
if err != nil {
continue
}
defer f.Close()
scanner := bufio.NewScanner(f)
scanner.Split(bufio.ScanLines)
var i = 0
for scanner.Scan() {
if i > 9 {
break
}
i++
sample += scanner.Text() + " \n" //md " \n" is a new line
//log.Println(scanner.Text())
}
break
}
}
log.Debug("sample data:", sample)
//need lenth check
return sample
}
示例10: InsertItemToDb
func InsertItemToDb(repo, item, datapool, itemdesc, createTime string) (err error) {
log.Println("Insert item to db")
dpid := GetDataPoolDpid(datapool)
if dpid > 0 {
//sqlInsertItem := fmt.Sprintf(`INSERT INTO DH_DP_RPDM_MAP (RPDMID, REPOSITORY, DATAITEM, ITEMDESC, DPID, PUBLISH, CREATE_TIME, STATUS)
// VALUES (null, '%s', '%s', '%s', %d, 'Y', datetime('now'), 'A')`, repo, item, itemdesc, dpid)
sqlInsertItem := fmt.Sprintf(`INSERT INTO DH_DP_RPDM_MAP (RPDMID, REPOSITORY, DATAITEM, ITEMDESC, DPID, PUBLISH, CREATE_TIME, STATUS)
VALUES (null, '%s', '%s', '%s', %d, 'Y', '%s', 'A')`, repo, item, itemdesc, dpid, createTime)
_, err = g_ds.Insert(sqlInsertItem)
log.Println(sqlInsertItem)
} else {
err = errors.New("dpid is not found")
}
return err
}
示例11: InsertTagToDb
func InsertTagToDb(dpexist bool, p ds.DsPull, tagcom string) (err error) {
if dpexist == false {
return
}
DpId := GetDataPoolDpid(p.Datapool)
if DpId == 0 {
return
}
rpdmid := GetRepoItemId(p.Repository, p.Dataitem)
if rpdmid == 0 {
sqlInsertRpdm := fmt.Sprintf(`INSERT INTO DH_DP_RPDM_MAP
(RPDMID ,REPOSITORY, DATAITEM, DPID, PUBLISH ,CREATE_TIME ,STATUS, ITEMDESC)
VALUES (null, '%s', '%s', %d, 'N', datetime('now'), 'A', '%s')`,
p.Repository, p.Dataitem, DpId, p.ItemDesc)
g_ds.Insert(sqlInsertRpdm)
rpdmid = GetRepoItemId(p.Repository, p.Dataitem)
}
sqlInsertTag := fmt.Sprintf(`INSERT INTO DH_RPDM_TAG_MAP(TAGID, TAGNAME ,RPDMID ,DETAIL,CREATE_TIME, STATUS, COMMENT)
VALUES (null, '%s', %d, '%s', datetime('now'), 'A', '%s')`,
p.Tag, rpdmid, p.DestName, tagcom)
log.Println(sqlInsertTag)
_, err = g_ds.Insert(sqlInsertTag)
return err
}
示例12: dl
func dl(uri, ip string, p ds.DsPull, w http.ResponseWriter, c chan int) error {
if len(ip) == 0 {
ip = "http://localhost:65535"
//TODO return
}
target := ip + uri
log.Println(target)
n, err := download(target, p, w, c)
if err != nil {
log.Printf("[%d bytes returned.]\n", n)
log.Println(err)
}
return err
}
示例13: delTagsForDelItem
func delTagsForDelItem(reponame, itemname string) error {
log.Println("Begin to remove tags for remove item from db")
sqlrpdmid := fmt.Sprintf(`SELECT RPDMID FROM DH_DP_RPDM_MAP WHERE REPOSITORY='%s' AND DATAITEM='%s' AND STATUS='A';`, reponame, itemname)
row, err := g_ds.QueryRow(sqlrpdmid)
if err != nil {
l := log.Error("select rpdmid from DH_DP_RPDM_MAP error:", err)
logq.LogPutqueue(l)
return err
}
var rpdmId int
row.Scan(&rpdmId)
if rpdmId == 0 {
log.Debug(reponame, itemname, "not exist.")
return nil
}
sqldeltag := fmt.Sprintf(`UPDATE DH_RPDM_TAG_MAP SET STATUS='N' WHERE RPDMID=%d`, rpdmId)
_, err = g_ds.Update(sqldeltag)
log.Info("sqldeltag", sqldeltag)
if err != nil {
l := log.Error("delete tag error:", err)
logq.LogPutqueue(l)
return err
}
return nil
}
示例14: saveDaemonID
func saveDaemonID(id string) {
log.Println("TODO save daemonid to db when srv returns code 0.")
count := `SELECT COUNT(*) FROM DH_DAEMON;`
row, err := g_ds.QueryRow(count)
if err != nil {
l := log.Error(count, "error.", err)
logq.LogPutqueue(l)
}
var c int
row.Scan(&c)
if c > 0 {
Update := fmt.Sprintf(`UPDATE DH_DAEMON SET DAEMONID='%s';`, id)
log.Debug(Update)
if _, e := g_ds.Update(Update); e != nil {
l := log.Error(Update, "error.", e)
logq.LogPutqueue(l)
}
} else {
Insert := fmt.Sprintf(`INSERT INTO DH_DAEMON (DAEMONID) VALUES ('%s');`, id)
log.Debug(c, Insert)
if _, e := g_ds.Insert(Insert); e != nil {
l := log.Error(Insert, "error.", e)
logq.LogPutqueue(l)
}
}
}
示例15: repoItemHandler
func repoItemHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
log.Println(r.URL.Path, "(repo/item)")
reqBody, _ := ioutil.ReadAll(r.Body)
commToServer("get", r.URL.Path+"?size=-1", reqBody, w)
return
}