當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


GO ParseAddress用法及代碼示例

GO語言"net/mail"包中"ParseAddress"函數的用法及代碼示例。

用法:

func ParseAddress(address string)(*Address, error)

ParseAddress 解析單個 RFC 5322 地址,例如“巴裏·吉布斯 <bg@example.com>”

例子:

package main

import (
    "fmt"
    "log"
    "net/mail"
)

func main() {
    e, err := mail.ParseAddress("Alice <alice@example.com>")
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(e.Name, e.Address)

}

輸出:

Alice alice@example.com

相關用法


注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 ParseAddress。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。