本文整理汇总了Golang中fmt.Fprint函数的典型用法代码示例。如果您正苦于以下问题:Golang Fprint函数的具体用法?Golang Fprint怎么用?Golang Fprint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Fprint函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetPod

// list specific pod details
func GetPod(w http.ResponseWriter, r *http.Request) {
    vars := mux.Vars(r)
    // node name from user.
    podName := vars["podName"]
    fmt.Fprint(w, string(podName))
    // to do need to read api and port of api server from configuration file
    // TODO: change namespace to flexible.
    var dat map[string]interface{}
    res, err := http.Get(thoth.KubeApi + "/api/v1/namespaces/default/pods/" + podName)
    if err != nil {
        panic(err)
    }
    body, err := ioutil.ReadAll(res.Body)
    res.Body.Close()
    if err != nil {
        panic(err)
    }
    if err := json.Unmarshal(body, &dat); err != nil {
        panic(err)
    }
    pretty_body, err := json.MarshalIndent(dat, "", "  ")
    if err != nil {
        panic(err)
    }
    fmt.Fprint(w, string(pretty_body))
}

开发者ID:SOUP-CE-KMITL,项目名称:Thoth,代码行数:27,代码来源:handler.go

示例2: Encode

// Encode transforms a Tag into a plumbing.EncodedObject.
func (t *Tag) Encode(o plumbing.EncodedObject) error {
    o.SetType(plumbing.TagObject)
    w, err := o.Writer()
    if err != nil {
        return err
    }
    defer ioutil.CheckClose(w, &err)

    if _, err = fmt.Fprintf(w,
        "object %s\ntype %s\ntag %s\ntagger ",
        t.Target.String(), t.TargetType.Bytes(), t.Name); err != nil {
        return err
    }

    if err = t.Tagger.Encode(w); err != nil {
        return err
    }

    if _, err = fmt.Fprint(w, "\n\n"); err != nil {
        return err
    }

    if _, err = fmt.Fprint(w, t.Message); err != nil {
        return err
    }

    return err
}

开发者ID:src-d,项目名称:go-git,代码行数:29,代码来源:tag.go

示例3: describeObjects

// describeObjects prints out information about the objects of a template
func (d *TemplateDescriber) describeObjects(objects []runtime.Object, out *tabwriter.Writer) {
    formatString(out, "Objects", " ")
    indent := "    "
    for _, obj := range objects {
        if d.ObjectDescriber != nil {
            output, err := d.DescribeObject(obj)
            if err != nil {
                fmt.Fprintf(out, "error: %v\n", err)
                continue
            }
            fmt.Fprint(out, output)
            fmt.Fprint(out, "\n")
            continue
        }

        _, kind, _ := d.ObjectTyper.ObjectVersionAndKind(obj)
        meta := kapi.ObjectMeta{}
        meta.Name, _ = d.MetadataAccessor.Name(obj)
        fmt.Fprintf(out, fmt.Sprintf("%s%s\t%s\n", indent, kind, meta.Name))
        //meta.Annotations, _ = d.MetadataAccessor.Annotations(obj)
        //meta.Labels, _ = d.MetadataAccessor.Labels(obj)
        /*if len(meta.Labels) > 0 {
            formatString(out, indent+"Labels", formatLabels(meta.Labels))
        }
        formatAnnotations(out, meta, indent)*/
    }
}

开发者ID:dctse,项目名称:openshift-cucumber,代码行数:28,代码来源:describer.go

示例4: newRow

func newRow(w io.Writer, row string, first bool) {
    if !first {
        fmt.Fprint(w, "  </tr>\n")
    }
    fmt.Fprint(w, "  <tr>\n")
    fmt.Fprintf(w, "    <td>%s:</td>\n", row)
}

开发者ID:keep94,项目名称:Dominator,代码行数:7,代码来源:showSubs.go

示例5: AddFileHandler

// AddFileHandler adds the file path to the database. It should be usually be given to an POST endpoint
// with id as the parameter
// Ex: /file/:id
func AddFileHandler(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
    decoder := json.NewDecoder(r.Body)
    // TODO: ps is there for checking emptiness. Should be replaced
    var js, ps jsonStruct
    if err := decoder.Decode(&js); err != nil || js == ps {
        w.WriteHeader(400)
        return
    }

    couchServer, err := couchdb.NewClient("http://127.0.0.1:5984", nil)
    db, _ := couchServer.CreateDB("files")
    userID := memberlist.DefaultWANConfig().Name

    _, err = db.Put(p.ByName("id"), file{UUID: uuid.NewV4().String(), Fname: path.Base(js.Path), UserID: userID}, "")
    if err != nil {
        w.WriteHeader(500)
        fmt.Fprint(w, err)
        return
    }

    // TODO: Send 409 for conflict
    if err := AddFile(p.ByName("id"), js.Path); err != nil {
        w.WriteHeader(500)
        fmt.Fprint(w, err)
        return
    }

    w.WriteHeader(201)
}

开发者ID:Gouthamve,项目名称:fshare,代码行数:32,代码来源:fhandlers.1.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng