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

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

示例1: xmlToSocketLogWriter

func xmlToSocketLogWriter(filename string, props []xmlProperty, enabled bool) (SocketLogWriter, bool) {
    endpoint := ""
    protocol := "udp"

    for _, prop := range props {
        switch prop.Name {
        case "endpoint":
            endpoint = strings.Trim(prop.Value, " \r\n")
        case "protocol":
            protocol = strings.Trim(prop.Value, " \r\n")
        default:
            fmt.Fprintf(os.Stderr, "LoadConfiguration: Warning: Unknown property \"%s\" for file filter in %s\n", prop.Name, filename)
        }
    }

    if len(endpoint) == 0 {
        fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required property \"%s\" for file filter missing in %s\n", "endpoint", filename)
        return nil, false
    }

    if !enabled {
        return nil, true
    }

    return NewSocketLogWriter(protocol, endpoint), true
}

开发者ID:pengswift,项目名称:libonepiece,代码行数:26,代码来源:config.go

示例2: identityConfig

// identityConfig initializes a new identity.
func identityConfig(out io.Writer, nbits int) (Identity, error) {
    // TODO guard higher up
    ident := Identity{}
    if nbits < 1024 {
        return ident, errors.New("Bitsize less than 1024 is considered unsafe.")
    }

    fmt.Fprintf(out, "generating %v-bit RSA keypair...", nbits)
    sk, pk, err := ci.GenerateKeyPair(ci.RSA, nbits)
    if err != nil {
        return ident, err
    }
    fmt.Fprintf(out, "done\n")

    // currently storing key unencrypted. in the future we need to encrypt it.
    // TODO(security)
    skbytes, err := sk.Bytes()
    if err != nil {
        return ident, err
    }
    ident.PrivKey = base64.StdEncoding.EncodeToString(skbytes)

    id, err := peer.IDFromPublicKey(pk)
    if err != nil {
        return ident, err
    }
    ident.PeerID = id.Pretty()
    fmt.Fprintf(out, "peer identity: %s\n", ident.PeerID)
    return ident, nil
}

开发者ID:kpcyrd,项目名称:go-ipfs,代码行数:31,代码来源:init.go

示例3: printText

func (p *Addr) printText(w io.Writer, codeblockEnd int) {
    switch p.Type {
    case None:
    case Reg, Xmm:
        name := p.Value.(Register).String()
        io.WriteString(w, name)
    case Ind:
        name := p.Value.(Register).String()
        if p.Disp != 0 {
            fmt.Fprintf(w, "%x+(%s)", p.Disp, name)
        } else {
            fmt.Fprintf(w, "(%s)", name)
        }
    case Rel8, Rel16, Rel32:
        if codeblockEnd != 0 {
            // We know where we are, print the absolute jump point.
            blk := int64(codeblockEnd) + p.valueInt64()
            fmt.Fprintf(w, "%s:(%06x)", p.Name, blk)
        } else {
            fmt.Fprintf(w, "%s:(%x)", p.Name, p.Value)
        }
    case Imm8, Imm16, Imm32, Imm64:
        fmt.Fprintf(w, "0x%x", p.Value)
    case Label:
        fmt.Fprint(w, p.Name)
    default:
        panic(fmt.Sprintf("unknown addr type: %v", p.Type))
    }
}

开发者ID:chai2010-playground,项目名称:asm,代码行数:29,代码来源:addr.go

示例4: check_fatal

func check_fatal(err error) {
    if err != nil {
        fmt.Fprintf(os.Stderr, "**** KURWA!!! ****\n")
        fmt.Fprintf(os.Stderr, "Error encountered was of FATAL. Is of wrong. Gib correct config pl0x.\n")
        panic(err)
    }
}

开发者ID:kaustavha,项目名称:kirisurf,代码行数:7,代码来源:common.go

示例5: postscript

func postscript(out *bytes.Buffer, name string) {
    fmt.Fprintf(out, "__start_%s()\n", name)
    fmt.Fprintf(out, `{
    local cur prev words cword split
    _init_completion -s || return

    local completions_func
    local c=0
    local flags=()
    local two_word_flags=()
    local flags_with_completion=()
    local flags_completion=()
    local commands=("%s")
    local must_have_one_flag=()
    local must_have_one_noun=()
    local last_command
    local nouns=()

    __handle_word
}

`, name)
    fmt.Fprintf(out, "complete -F __start_%s %s\n", name, name)
    fmt.Fprintf(out, "# ex: ts=4 sw=4 et filetype=sh\n")
}

开发者ID:Castcloud,项目名称:castcloud-go-server,代码行数:25,代码来源:bash_completions.go

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